diff --git a/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java b/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java index 8e7017fb..ba29ad37 100644 --- a/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java @@ -11,6 +11,7 @@ import tify.server.domain.domains.question.domain.FavorAnswer; import tify.server.domain.domains.question.domain.FavorQuestionCategory; import tify.server.domain.domains.question.dto.model.FavorAnswerCategoryDto; +import tify.server.domain.domains.user.domain.DetailCategory; import tify.server.domain.domains.user.domain.SmallCategory; import tify.server.domain.domains.user.vo.FavorAnswerContentVo; import tify.server.domain.domains.user.vo.UserAnswerVo; @@ -50,30 +51,35 @@ public List execute(Long userId, List smallCategory .getFavorQuestion() .getNumber(), favorAnswer.getAnswerContent()))); - int userAnswerCategorySize = + + List userAnswerCategories = favorAnswerCategoryDTOs.stream() .filter( dto -> dto.getSmallCategory() .equals(smallCategory)) - .toList() - .size(); - // smallCategory와 같은 smallCategory를 가지는 favorAnswerCategoryDTO의 개수 + .toList(); + // smallCategory와 같은 smallCategory를 가지는 favorAnswerCategoryDTO + + List answeredDetailCategories = + userAnswerCategories.stream() + .map(FavorAnswerCategoryDto::getDetailCategory) + .toList(); - int size = - favorQuestionCategories.stream() + List notAnsweredDetailCategories = + DetailCategory.getDetailCategoriesBySmallCategory(smallCategory) + .stream() .filter( - category -> - category.getSmallCategory() - .equals(smallCategory)) - .toList() - .size(); - // smallCategory와 같은 smallCategory를 가지는 detailCategory의 개수 + detailCategory -> + !answeredDetailCategories.contains( + detailCategory)) + .toList(); return UserAnswerVo.of( smallCategory, favorAnswerContentList, - userAnswerCategorySize == size); + notAnsweredDetailCategories.isEmpty(), + notAnsweredDetailCategories); }) .toList(); } diff --git a/Core/src/main/java/tify/server/core/jwt/JwtTokenProvider.java b/Core/src/main/java/tify/server/core/jwt/JwtTokenProvider.java index d987dae0..cd776e24 100644 --- a/Core/src/main/java/tify/server/core/jwt/JwtTokenProvider.java +++ b/Core/src/main/java/tify/server/core/jwt/JwtTokenProvider.java @@ -8,10 +8,8 @@ import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.security.Keys; -import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; import java.security.Key; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; @@ -167,19 +165,8 @@ public String buildAppleClientSecret() public PrivateKey getPrivateKey() throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { - String result = ""; - - if (hashMap.get("apple") == null) { - File file = new File(appleKeyPath); - result = new String(Files.readAllBytes(file.toPath())); - hashMap.put("apple", result); - } else { - result = hashMap.get("apple"); - } - String key = - result.replace("-----BEGIN PRIVATE KEY-----\n", "") - .replace("-----END PRIVATE KEY-----", ""); + String key = oauthProperties.getAppleKey(); byte[] encoded = Base64.decodeBase64(key.getBytes()); diff --git a/Core/src/main/java/tify/server/core/properties/OauthProperties.java b/Core/src/main/java/tify/server/core/properties/OauthProperties.java index 977c15ec..a37a7e66 100644 --- a/Core/src/main/java/tify/server/core/properties/OauthProperties.java +++ b/Core/src/main/java/tify/server/core/properties/OauthProperties.java @@ -36,6 +36,7 @@ public static class AppleSecret { private String clientUrl; private String redirectUrl; private String keyPath; + private String key; } // base url @@ -86,4 +87,8 @@ public String getAppleRedirectUrl() { public String getAppleKeyPath() { return apple.getKeyPath(); } + + public String getAppleKey() { + return apple.getKey(); + } } diff --git a/Core/src/main/resources/application-core.yml b/Core/src/main/resources/application-core.yml index 5b0b2e22..7ff4af24 100644 --- a/Core/src/main/resources/application-core.yml +++ b/Core/src/main/resources/application-core.yml @@ -21,3 +21,4 @@ oauth2: log-in-key: ${APPLE_LOGIN_KEY} redirect-url: ${APPLE_REDIRECT} key-path: ${APPLE_KEY_PATH} + key: ${APPLE_KEY} \ No newline at end of file diff --git a/Domain/src/main/java/tify/server/domain/domains/user/domain/DetailCategory.java b/Domain/src/main/java/tify/server/domain/domains/user/domain/DetailCategory.java index ab4fad38..b59a7d5a 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/domain/DetailCategory.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/domain/DetailCategory.java @@ -33,6 +33,13 @@ public static List getDetailCategories() { return Arrays.stream(DetailCategory.values()).toList(); } + public static List getDetailCategoriesBySmallCategory( + SmallCategory smallCategory) { + return Arrays.stream(DetailCategory.values()) + .filter(detailCategory -> detailCategory.getSmallCategory().equals(smallCategory)) + .toList(); + } + final String value; final SmallCategory smallCategory; } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java index b6a7e50d..08526449 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java @@ -4,6 +4,7 @@ import java.util.List; import lombok.Builder; import lombok.Getter; +import tify.server.domain.domains.user.domain.DetailCategory; import tify.server.domain.domains.user.domain.SmallCategory; @Getter @@ -16,14 +17,18 @@ public class UserAnswerVo { private final boolean isAllDetailCategoryAnswered; + private final List notAnsweredDetailCategories; + public static UserAnswerVo of( SmallCategory smallCategory, List answerContentList, - boolean isAllDetailCategoryAnswered) { + boolean isAllDetailCategoryAnswered, + List detailCategories) { return UserAnswerVo.builder() .smallCategory(smallCategory) .answerContentList(answerContentList) .isAllDetailCategoryAnswered(isAllDetailCategoryAnswered) + .notAnsweredDetailCategories(detailCategories) .build(); } }