Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
feat: active profile 조회를 위한 controller 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
Hosick committed May 28, 2021
1 parent 972fddb commit 2c4ce2c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String getSecretKey() {
return credentials.getSecretKey();
}

public String getBrnadBucket() {
public String getBrandBucket() {
return s3.getBrand();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.flab.shoeauction.controller.common;

import edu.emory.mathcs.backport.java.util.Arrays;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
public class ProfileController {

private final Environment env;

@GetMapping("/profile")
public String profile() {
List<String> profiles = Arrays.asList(env.getActiveProfiles());
List<String> realProfiles = Arrays.asList(new String[]{"real", "real1", "real2"});
String defaultProfile = profiles.isEmpty() ? "default" : profiles.get(0);

return profiles.stream()
.filter(realProfiles::contains)
.findAny()
.orElse(defaultProfile);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void setS3Client() {
}

public String uploadBrandImage(MultipartFile file) {
return upload(file, awsProperties.getBrnadBucket());
return upload(file, awsProperties.getBrandBucket());
}

public String uploadProductImage(MultipartFile file) {
Expand Down Expand Up @@ -72,7 +72,7 @@ public String upload(MultipartFile file, String bucket) {
}

public void deleteBrandImage(String key) {
delete(awsProperties.getBrnadBucket(), key);
delete(awsProperties.getBrandBucket(), key);
}

public void deleteProductImage(String key) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# profile을 타지않는 전역 설정
# format_sql : query의 출력 내용을 서식에 맞게 가독성을 향상시켜 출

# format_sql : query의 출력 내용을 서식에 맞게 가독성을 향상시켜 출력

spring:
profiles:
active: dev

jpa:
properties:
hibernate:
format_sql: true
format_sql: true

0 comments on commit 2c4ce2c

Please sign in to comment.