Skip to content

Commit

Permalink
[hotfix] refactor: 프로필 수정 시 닉네임 중복 체크 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
elive7 committed Jan 13, 2025
1 parent 6b38b44 commit c2c29b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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 @@ -121,7 +121,9 @@ public void signOut(long userId) {
public void update(UserUpdate update, long id) {

User user = userRepository.findById(id);
validateDuplicateNickname(user, update.nickname());
if (!user.getNickname().equals(update.nickname())) {
validateDuplicateNickname(update.nickname());
}
user.update(update);

userRepository.save(user);
Expand Down Expand Up @@ -151,13 +153,6 @@ 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 c2c29b1

Please sign in to comment.