Skip to content

Commit

Permalink
[hotfix] fix: 닉네임 똑같은 경우, 닉네임 중복 체크 안하도록 수정
Browse files Browse the repository at this point in the history
- validateDuplicateNickname함수를 오버로딩하여 사용
  • Loading branch information
elive7 committed Jan 13, 2025
1 parent f36dd32 commit 36de95b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public interface UserService {
// query
UserProfile getProfile(long targetUserId, long userId);
void validateDuplicateNickname(String nickname);
void validateDuplicateNickname(User user, String nickname);
Slice<UserInfo> getSubscribingUserInfos(long userId, Long cursor, int size);
Slice<UserInfo> getSubscribedUserInfos(long userId, Long cursor, int size);
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public void signOut(long userId) {
@Transactional
@Override
public void update(UserUpdate update, long id) {
validateDuplicateNickname(update.nickname());

User user = userRepository.findById(id);
validateDuplicateNickname(user, update.nickname());
user.update(update);

userRepository.save(user);
Expand Down Expand Up @@ -151,6 +151,13 @@ public void validateDuplicateNickname(String nickname) {
}
}

@Override
public void validateDuplicateNickname(User user, String nickname) {
if (!user.getNickname().equals(nickname) && userRepository.existsByNickname(nickname)) {
throw new UserException(ErrorMessage.DUPLICATE_NICKNAME);
}
}

@Override
public Slice<UserInfo> getSubscribingUserInfos(long userId, Long cursor, int size) {
return userRepository.findFollowings(userId, cursor, size);
Expand Down

0 comments on commit 36de95b

Please sign in to comment.