-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from JECT-Study/release/1.1.0
release: 1.1.0
- Loading branch information
Showing
224 changed files
with
5,324 additions
and
9,203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/org/chzz/market/common/config/OAuth2ClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.chzz.market.common.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient; | ||
import org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient; | ||
import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest; | ||
|
||
@Configuration | ||
public class OAuth2ClientConfig { | ||
|
||
@Bean | ||
public OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient() { | ||
return new DefaultAuthorizationCodeTokenResponseClient(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/chzz/market/common/config/RestClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.chzz.market.common.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.client.RestClient; | ||
|
||
@Configuration | ||
public class RestClientConfig { | ||
@Bean | ||
RestClient restClient() { | ||
return RestClient.create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../chzz/market/common/config/AWSConfig.java → ...z/market/common/config/aws/AWSConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/org/chzz/market/common/config/aws/BucketPrefix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.chzz.market.common.config.aws; | ||
|
||
import java.util.Arrays; | ||
import java.util.UUID; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum BucketPrefix { | ||
AUCTION("auction"), | ||
PROFILE("profile"); | ||
private final String name; | ||
|
||
public static boolean hasNameOf(String name) { | ||
return Arrays.stream(values()) | ||
.anyMatch(bucketFolderName -> bucketFolderName.name.equals(name)); | ||
} | ||
|
||
public String createPath(final String fileName) { | ||
String fileId = UUID.randomUUID().toString(); | ||
return String.format("%s/%s/%s", this.name, fileId, fileName); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/chzz/market/common/config/aws/S3PrefixVerifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.chzz.market.common.config.aws; | ||
|
||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.model.ListObjectsV2Request; | ||
import com.amazonaws.services.s3.model.ListObjectsV2Result; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* 이미지가 업로드 가능한 파일 목록 세팅 | ||
*/ | ||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class S3PrefixVerifier { | ||
private static final String DELIMITER = "/"; | ||
|
||
private final AmazonS3 s3; | ||
private final String bucket; | ||
|
||
@EventListener(ApplicationReadyEvent.class) | ||
private boolean verifyPrefix() { | ||
ListObjectsV2Request req = new ListObjectsV2Request() | ||
.withBucketName(bucket) | ||
.withDelimiter(DELIMITER); | ||
ListObjectsV2Result result = s3.listObjectsV2(req); | ||
return result.getCommonPrefixes().stream() | ||
.map(prefix -> prefix.split(DELIMITER)[0]) | ||
.peek(prefix -> log.info("bucket prefix: {}", prefix)) | ||
.allMatch(BucketPrefix::hasNameOf); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/org/chzz/market/common/util/ApplicationContextProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.chzz.market.common.util; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ApplicationContextProvider implements ApplicationContextAware { | ||
|
||
private static ApplicationContext context; | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext ctx) throws BeansException { | ||
context = ctx; | ||
} | ||
|
||
public static <T> T getBean(Class<T> clazz) { | ||
return context.getBean(clazz); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/chzz/market/common/util/StringCaseConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.chzz.market.common.util; | ||
|
||
public class StringCaseConverter { | ||
|
||
/** | ||
* 문자열을 대문자로 변환하고, '-'를 '_'로 바꿈 예: "example-string" -> "EXAMPLE_STRING" | ||
* 요청에서 Enum값을 매칭할때 클라이언트에선 소문자와 하이푼을 쓰기 때문에 변환 | ||
* | ||
* @param source 변환할 입력 문자열 | ||
* @return 변환된 문자열 | ||
*/ | ||
public static String toUpperCaseWithUnderscores(String source) { | ||
if (source == null) { | ||
return null; | ||
} | ||
return source.trim().toUpperCase().replace("-", "_"); | ||
} | ||
|
||
/** | ||
* 문자열을 소문자로 변환하고, '_'를 '-'로 바꿈 예: "EXAMPLE_STRING" -> "example-string" | ||
* Enum값을 내보낼때, 클라이언트에선 소문자와 하이푼을 쓰기 때문에 변환 | ||
* | ||
* @param source 변환할 입력 문자열 | ||
* @return 변환된 문자열 | ||
*/ | ||
public static String toLowerCaseWithHyphens(String source) { | ||
if (source == null) { | ||
return null; | ||
} | ||
return source.trim().toLowerCase().replace("_", "-"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.