Skip to content

Commit

Permalink
[fix] service 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryeolee committed Mar 30, 2024
1 parent e536db3 commit 38b6360
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,11 @@ public BaseResponseDto<LoginResponseDto> kakaoLogin(String kakaoAccessToken) {
@Transactional
public BaseResponseDto<Void> logout(Long userId) {

redisTokenDelete(userId);
deleteredisToken(userId);
log.info("로그아웃 완료");
return BaseResponseDto.of(SuccessCode.SUCCESS,null);
}


private void redisTokenDelete(Long userId){
redisManager.deleteValueByKey(String.valueOf(userId));
}

@Transactional
public BaseResponseDto<TokenResponseDto> reissueToken(Long userId, String refreshToken) {

Expand All @@ -84,17 +79,25 @@ public BaseResponseDto<TokenResponseDto> reissueToken(Long userId, String refres
));
}

private void deleteredisToken(Long userId){
redisManager.deleteValueByKey(String.valueOf(userId));
}
private String getRedisToken(Long key){return redisManager.getValueByKey(key);}


private User findUser(Long userId) {
return userRepository.findUserData(Long.valueOf(userId));
}


private void validateRefreshToken(Long userId, String refreshToken) {

String redisRefreshToken = redisManager.getValueByKey(userId);
String redisRefreshToken = getRedisToken(userId);
if (!refreshToken.equals(redisRefreshToken)) {

throw new AuthRefreshTokenValidateException("일치하지 않는 토큰입니다.");
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public BaseResponseDto<Void> settingMotivation(@AuthenticationPrincipal CustomUs
@Validated @RequestBody SetMotivationRequest setMotivationRequest
) {
return onBoardingService.settingMotivation(
user.getUserId(),
User.createUserObject(user.getUserId()),
setMotivationRequest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public class OnBoardingService {
private final UserRepository userRepository;

@Transactional
public BaseResponseDto<Void> settingMotivation(Long userId, SetMotivationRequest setMotivationRequest) {

User user = findUser(userId);
public BaseResponseDto<Void> settingMotivation(User user, SetMotivationRequest setMotivationRequest) {

insertMotivation(user, setMotivationRequest);

Expand Down Expand Up @@ -57,7 +55,7 @@ private void updateCompleteBoarding(Long userId){
}


@Transactional

public void insertMotivation(User user, SetMotivationRequest setMotivationRequest) {
for (String motivation : setMotivationRequest.getMotivation()) {
insertOneMotivation(user, motivation);
Expand All @@ -67,6 +65,7 @@ public void insertMotivation(User user, SetMotivationRequest setMotivationReques
public void insertOneMotivation(User user, String motivation) {
UserMotivation newMotivation = UserMotivation.createUserMotivation(motivation, user);
user.addUserMotivation(newMotivation);

}

private void insertLevel(Long userId, String level){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ private void updateProfileAndNickname(Long userId, String imageUrl, String nickn
userRepository.selectProfileAndNickname(userId,imageUrl,nickname);
}





private Optional<User> selectUser(Long userId){
Optional<User> user = Optional.ofNullable(userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException("해당 유저가 존재하지 않습니다.")));
return user;
Expand Down

0 comments on commit 38b6360

Please sign in to comment.