diff --git a/src/main/java/moodbuddy/moodbuddy/domain/diary/controller/emotion/DiaryEmotionApiController.java b/src/main/java/moodbuddy/moodbuddy/domain/diary/controller/emotion/DiaryEmotionApiController.java index 9511c472..66eff3bc 100644 --- a/src/main/java/moodbuddy/moodbuddy/domain/diary/controller/emotion/DiaryEmotionApiController.java +++ b/src/main/java/moodbuddy/moodbuddy/domain/diary/controller/emotion/DiaryEmotionApiController.java @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/api/v1/member/diary") +@RequestMapping("/api/v2/member/diary") @Tag(name = "Diary", description = "일기 감정 관련 API") @RequiredArgsConstructor public class DiaryEmotionApiController { diff --git a/src/main/java/moodbuddy/moodbuddy/domain/letter/controller/LetterApiController.java b/src/main/java/moodbuddy/moodbuddy/domain/letter/controller/LetterApiController.java index e9b76c3a..5796aef4 100644 --- a/src/main/java/moodbuddy/moodbuddy/domain/letter/controller/LetterApiController.java +++ b/src/main/java/moodbuddy/moodbuddy/domain/letter/controller/LetterApiController.java @@ -21,7 +21,7 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api/v1/member/letter") +@RequestMapping("/api/v2/member/letter") @Tag(name = "letter-controller", description = "Letter API") public class LetterApiController { diff --git a/src/main/java/moodbuddy/moodbuddy/domain/user/controller/OAuthController.java b/src/main/java/moodbuddy/moodbuddy/domain/user/controller/OAuthController.java index 0ae385e4..2d09a645 100644 --- a/src/main/java/moodbuddy/moodbuddy/domain/user/controller/OAuthController.java +++ b/src/main/java/moodbuddy/moodbuddy/domain/user/controller/OAuthController.java @@ -15,7 +15,7 @@ @Slf4j @RestController @RequiredArgsConstructor -@RequestMapping("api/v1/user") +@RequestMapping("api/v2/user") public class OAuthController { private final KakaoService kakaoService; diff --git a/src/main/java/moodbuddy/moodbuddy/domain/user/dto/request/UserReqLoginDTO.java b/src/main/java/moodbuddy/moodbuddy/domain/user/dto/request/UserReqLoginDTO.java index 1454f7a9..188fe738 100644 --- a/src/main/java/moodbuddy/moodbuddy/domain/user/dto/request/UserReqLoginDTO.java +++ b/src/main/java/moodbuddy/moodbuddy/domain/user/dto/request/UserReqLoginDTO.java @@ -10,5 +10,5 @@ @NoArgsConstructor public class UserReqLoginDTO { @Schema(description = "임시로 사용할 자체 로그인이기 때문에 kakaoId 으로만 로그인이 가능하게 한다.", example = "12342") - private Long userId; + private Long kakaoId; } diff --git a/src/main/java/moodbuddy/moodbuddy/domain/user/repository/UserRepository.java b/src/main/java/moodbuddy/moodbuddy/domain/user/repository/UserRepository.java index a967e366..ebdc9433 100644 --- a/src/main/java/moodbuddy/moodbuddy/domain/user/repository/UserRepository.java +++ b/src/main/java/moodbuddy/moodbuddy/domain/user/repository/UserRepository.java @@ -24,6 +24,8 @@ public interface UserRepository extends JpaRepository { @Query("select u from User u where u.userId = :userId") Optional findByUserIdWithPessimisticLock(@Param("userId") Long userId); + @Query("select u from User u where u.kakaoId = :kakaoId") + Optional findByKakaoId(@Param("kakaoId") Long kakaoId); // @Modifying // @Transactional // @Query("update User u set u.userCurDiaryNums = :curDiaryNums where u.userId = :userId") @@ -32,11 +34,11 @@ public interface UserRepository extends JpaRepository { // @Modifying // @Transactional // @Query("update User u set u.userLastDiaryNums = :curDiaryNums where u.userId = :userId") + // void updateLastDiaryNumsById(@Param("userId") Long userId, @Param("curDiaryNums") Integer curDiaryNums); @Modifying @Transactional @Query("update User u set u.letterAlarm = :letterAlarm where u.userId = :userId") void updateLetterAlarmByUserId(@Param("userId") Long userId, @Param("letterAlarm") boolean letterAlarm); - } diff --git a/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserService.java b/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserService.java index 44d907ee..2bf7dc31 100644 --- a/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserService.java +++ b/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserService.java @@ -61,4 +61,5 @@ public interface UserService { UserResLoginDTO login(UserReqLoginDTO userReqLoginDTO); UserResSaveDTO save(UserReqSaveDTO userReqSaveDTO); User getUserById(Long userId); + User getUserByKakaoId(Long kakaoId); } diff --git a/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserServiceImpl.java b/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserServiceImpl.java index 64ffd960..43892c5f 100644 --- a/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserServiceImpl.java +++ b/src/main/java/moodbuddy/moodbuddy/domain/user/service/UserServiceImpl.java @@ -522,7 +522,7 @@ public void setUserCheckTodayDairy(Long userId, Boolean check) { /** 테스트를 위한 임시 자체 로그인 **/ @Override public UserResLoginDTO login(UserReqLoginDTO userReqLoginDTO) { - return UserMapper.toUserResLoginDTO(getUserById(userReqLoginDTO.getUserId())); + return UserMapper.toUserResLoginDTO(getUserByKakaoId(userReqLoginDTO.getKakaoId())); } /** 테스트를 위한 임시 자체 회원가입 **/ @@ -534,7 +534,13 @@ public UserResSaveDTO save(UserReqSaveDTO userReqSaveDTO) { @Override public User getUserById(Long userId) { - return userRepository.findById(userId) + return userRepository.findByUserId(userId) + .orElseThrow(()->new UserNotFoundByUserIdException(ErrorCode.NOT_FOUND_USER)); + } + + @Override + public User getUserByKakaoId(Long kakaoId) { + return userRepository.findByKakaoId(kakaoId) .orElseThrow(()->new UserNotFoundByUserIdException(ErrorCode.NOT_FOUND_USER)); } } \ No newline at end of file diff --git a/src/main/java/moodbuddy/moodbuddy/global/common/config/SecurityConfig.java b/src/main/java/moodbuddy/moodbuddy/global/common/config/SecurityConfig.java index eb092167..552c3464 100644 --- a/src/main/java/moodbuddy/moodbuddy/global/common/config/SecurityConfig.java +++ b/src/main/java/moodbuddy/moodbuddy/global/common/config/SecurityConfig.java @@ -44,10 +44,14 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { "http://react-app:3000", "http://localhost:5173", "http://localhost:3000", + "http://localhost:8080", + "http://52.79.54.242:8080", + "http://52.79.54.242:3000", "http://moodbuddy:8080", "https://moodbuddy.site", "http://moodbuddy.site", - "https://neon-cat-f70a98.netlify.app")); + "https://neon-cat-f70a98.netlify.app", + "https://main.d28mm6xwy7gaq8.amplifyapp.com/")); config.setAllowedHeaders(List.of("*")); config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE")); config.setAllowCredentials(true);