From c7c930ee3093286f1eacca99625c95d1b649ca45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=A7=80=EC=9B=90?= Date: Thu, 25 Jul 2024 11:22:38 +0900 Subject: [PATCH] =?UTF-8?q?chore=20:=20dev=20=ED=99=98=EA=B2=BD=EB=8F=84?= =?UTF-8?q?=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EA=B0=80=20=EB=8F=99=EC=9E=91?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EC=88=98=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 다시초기화 dev 환경에서도 돌아가게하려면 카카오 앱을 하나 더 만들어야함.. --- application/app-api/build.gradle | 2 -- .../core/startup/mealtoktok/api/auth/AuthApi.java | 14 ++++++++------ .../startup/mealtoktok/api/auth/AuthApiDocs.java | 6 +++--- .../mealtoktok/api/auth/response/OAuthLogin.java | 9 --------- .../mealtoktok/api/dto/OAuthLoginResponse.java | 9 +++++++++ .../api/{auth/request => dto}/SignupRequest.java | 2 +- common/src/main/resources/application-common.yml | 1 + .../startup/mealtoktok/domain/user/UserReader.java | 8 +++++--- .../mealtoktok/infra/user/config/RedisConfig.java | 2 ++ 9 files changed, 29 insertions(+), 24 deletions(-) delete mode 100644 application/app-api/src/main/java/core/startup/mealtoktok/api/auth/response/OAuthLogin.java create mode 100644 application/app-api/src/main/java/core/startup/mealtoktok/api/dto/OAuthLoginResponse.java rename application/app-api/src/main/java/core/startup/mealtoktok/api/{auth/request => dto}/SignupRequest.java (91%) diff --git a/application/app-api/build.gradle b/application/app-api/build.gradle index 0295c53..2ba355f 100644 --- a/application/app-api/build.gradle +++ b/application/app-api/build.gradle @@ -14,8 +14,6 @@ dependencies { //aop implementation 'org.springframework.boot:spring-boot-starter-aop' - - //spring-json implementation 'org.springframework.boot:spring-boot-configuration-processor' //JWT diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApi.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApi.java index ed1292f..6be1d2a 100644 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApi.java +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApi.java @@ -1,7 +1,7 @@ package core.startup.mealtoktok.api.auth; -import core.startup.mealtoktok.api.auth.request.SignupRequest; -import core.startup.mealtoktok.api.auth.response.OAuthLogin; +import core.startup.mealtoktok.api.dto.SignupRequest; +import core.startup.mealtoktok.api.dto.OAuthLoginResponse; import core.startup.mealtoktok.common.dto.Response; import core.startup.mealtoktok.domain.auth.AuthService; import core.startup.mealtoktok.domain.auth.JwtTokens; @@ -9,11 +9,13 @@ import core.startup.mealtoktok.api.global.security.JwtTokenizer; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/auth") +@Slf4j public class AuthApi implements AuthApiDocs { private final AuthService authService; @@ -38,13 +40,13 @@ public Response signUp(@RequestBody SignupRequest signupRequest, HttpServl } @GetMapping("/oauth/login/link") - public Response oauthLoginLink() { - OAuthLogin oAuthLogin = OAuthLogin.from(authService.getKakaoLoginLink()); - return Response.success(oAuthLogin); + public Response oauthLoginLink() { + OAuthLoginResponse oAuthLoginResponse = OAuthLoginResponse.from(authService.getKakaoLoginLink()); + return Response.success(oAuthLoginResponse); } @GetMapping("/login/oauth2/code/kakao") - public Response credentialTest(@RequestParam String code) { + public Response credentialTest(@RequestParam("code") String code) { authService.getCredentialTest(code); return Response.success("테스트 성공"); } diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApiDocs.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApiDocs.java index 71c24b3..9be99de 100644 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApiDocs.java +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/AuthApiDocs.java @@ -1,7 +1,7 @@ package core.startup.mealtoktok.api.auth; -import core.startup.mealtoktok.api.auth.request.SignupRequest; -import core.startup.mealtoktok.api.auth.response.OAuthLogin; +import core.startup.mealtoktok.api.dto.SignupRequest; +import core.startup.mealtoktok.api.dto.OAuthLoginResponse; import core.startup.mealtoktok.common.dto.Response; import core.startup.mealtoktok.domain.auth.OAuthTokens; import io.swagger.v3.oas.annotations.Operation; @@ -22,7 +22,7 @@ public interface AuthApiDocs { Response login(OAuthTokens oAuthTokens, HttpServletResponse response); @Operation(summary = "OAuth 링크발급(백엔드 개발 테스트용입니다)") - Response oauthLoginLink(); + Response oauthLoginLink(); @Operation(summary = "OAuth code를 통한 테스트(백엔드 개발 테스트용입니다)") Response credentialTest(@RequestParam String code); diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/response/OAuthLogin.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/response/OAuthLogin.java deleted file mode 100644 index 55f170d..0000000 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/response/OAuthLogin.java +++ /dev/null @@ -1,9 +0,0 @@ -package core.startup.mealtoktok.api.auth.response; - -public record OAuthLogin( - String link -) { - public static OAuthLogin from(String link) { - return new OAuthLogin(link); - } -} diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/dto/OAuthLoginResponse.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/dto/OAuthLoginResponse.java new file mode 100644 index 0000000..8755922 --- /dev/null +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/dto/OAuthLoginResponse.java @@ -0,0 +1,9 @@ +package core.startup.mealtoktok.api.dto; + +public record OAuthLoginResponse( + String link +) { + public static OAuthLoginResponse from(String link) { + return new OAuthLoginResponse(link); + } +} diff --git a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/request/SignupRequest.java b/application/app-api/src/main/java/core/startup/mealtoktok/api/dto/SignupRequest.java similarity index 91% rename from application/app-api/src/main/java/core/startup/mealtoktok/api/auth/request/SignupRequest.java rename to application/app-api/src/main/java/core/startup/mealtoktok/api/dto/SignupRequest.java index 8abf8c2..da719d1 100644 --- a/application/app-api/src/main/java/core/startup/mealtoktok/api/auth/request/SignupRequest.java +++ b/application/app-api/src/main/java/core/startup/mealtoktok/api/dto/SignupRequest.java @@ -1,4 +1,4 @@ -package core.startup.mealtoktok.api.auth.request; +package core.startup.mealtoktok.api.dto; import core.startup.mealtoktok.domain.auth.OAuthTokens; import core.startup.mealtoktok.domain.user.AddressWithCoordinate; diff --git a/common/src/main/resources/application-common.yml b/common/src/main/resources/application-common.yml index 2b2755e..5da3c4f 100644 --- a/common/src/main/resources/application-common.yml +++ b/common/src/main/resources/application-common.yml @@ -10,6 +10,7 @@ oauth: app-id: ${KAKAO_APP_ID} admin-key: ${KAKAO_ADMIN_KEY} service-key: ${KAKAO_REST_API_KEY} + --- spring: config: diff --git a/domain/src/main/java/core/startup/mealtoktok/domain/user/UserReader.java b/domain/src/main/java/core/startup/mealtoktok/domain/user/UserReader.java index dbaa204..658a884 100644 --- a/domain/src/main/java/core/startup/mealtoktok/domain/user/UserReader.java +++ b/domain/src/main/java/core/startup/mealtoktok/domain/user/UserReader.java @@ -12,9 +12,11 @@ public class UserReader { private final UserCacheManager userCacheManager; public User read(TargetUser targetUser) { - return userCacheManager.read(targetUser).orElseGet( () -> - userRepository.findById(targetUser) - ); + return userCacheManager.read(targetUser).orElseGet( () ->{ + User user = userRepository.findById(targetUser); + userCacheManager.cache(user); + return user; + }); } public boolean isAlreadyRegistered(OAuthInfo oAuthInfo) { diff --git a/infra/src/main/java/core/startup/mealtoktok/infra/user/config/RedisConfig.java b/infra/src/main/java/core/startup/mealtoktok/infra/user/config/RedisConfig.java index 1ff3c6d..faf98f6 100644 --- a/infra/src/main/java/core/startup/mealtoktok/infra/user/config/RedisConfig.java +++ b/infra/src/main/java/core/startup/mealtoktok/infra/user/config/RedisConfig.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; @@ -58,6 +59,7 @@ public RedisTemplate tokenRedisTemplate() { } @Bean + @Primary public RedisTemplate banTokenRedisTemplate() { RedisTemplate redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(redisConnectionFactory());