Skip to content

Commit

Permalink
Merge pull request #38 from MoodBuddy/feature/#36
Browse files Browse the repository at this point in the history
[Chore] Allow Origin 추가해라 - Feature/#36
  • Loading branch information
zzammin authored Nov 26, 2024
2 parents 5bec259 + 5d05ec3 commit 88ced28
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("api/v1/user")
@RequestMapping("api/v2/user")
public class OAuthController {

private final KakaoService kakaoService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
@NoArgsConstructor
public class UserReqLoginDTO {
@Schema(description = "임시로 사용할 자체 로그인이기 때문에 kakaoId 으로만 로그인이 가능하게 한다.", example = "12342")
private Long userId;
private Long kakaoId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface UserRepository extends JpaRepository<User, Long> {
@Query("select u from User u where u.userId = :userId")
Optional<User> findByUserIdWithPessimisticLock(@Param("userId") Long userId);

@Query("select u from User u where u.kakaoId = :kakaoId")
Optional<User> findByKakaoId(@Param("kakaoId") Long kakaoId);
// @Modifying
// @Transactional
// @Query("update User u set u.userCurDiaryNums = :curDiaryNums where u.userId = :userId")
Expand All @@ -32,11 +34,11 @@ public interface UserRepository extends JpaRepository<User, Long> {
// @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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ public interface UserService {
UserResLoginDTO login(UserReqLoginDTO userReqLoginDTO);
UserResSaveDTO save(UserReqSaveDTO userReqSaveDTO);
User getUserById(Long userId);
User getUserByKakaoId(Long kakaoId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

/** 테스트를 위한 임시 자체 회원가입 **/
Expand All @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 88ced28

Please sign in to comment.