Skip to content

Commit

Permalink
[�merge] 프로필 수정 시 닉네임 중복검사 로직 변경
Browse files Browse the repository at this point in the history
[fix] 프로필 수정 시 닉네임 중복검사 로직 변경
  • Loading branch information
bo-ram-bo-ram authored Sep 17, 2024
2 parents 0699457 + 94e13cb commit a93b2fb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void updateGuestNickname(Long guestId, GuestUpdateRequest guestUpdateRequ

public void isDuplicatedNickname(String nickname) {
if (hostRepository.existsByNickname(nickname) || guestRepository.existsByNickname(nickname) ||
submitterRepository.existsByNickname(nickname)) {
submitterRepository.existsByNicknameAndSubmitterState(nickname, "pending")) {
throw new CustomException(ErrorCode.DUPLICATION_NICKNAME);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public class HostCommandService {

public void updateHostProfile(Long hostId, HostUpdateRequest hostUpdateRequest) {
Host host = hostRepository.findHostByIdOrThrow(hostId);
if (!host.getNickname().equals(hostUpdateRequest.nickname()) && (hostRepository.existsByNickname(
hostUpdateRequest.nickname()) || guestRepository.existsByNickname(
hostUpdateRequest.nickname()) || submitterRepository.existsByNickname(hostUpdateRequest.nickname()))) {
if (!host.getNickname().equals(hostUpdateRequest.nickname())
&& (hostRepository.existsByNickname(hostUpdateRequest.nickname())
|| guestRepository.existsByNickname(hostUpdateRequest.nickname())
|| submitterRepository.existsByNicknameAndSubmitterState(hostUpdateRequest.nickname(), "pending"))) {
throw new CustomException(ErrorCode.DUPLICATION_NICKNAME);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ default Submitter findSubmitterByIdOrThrow(Long id) {
.orElseThrow(() -> new CustomException(ErrorCode.SUBMITTER_NOT_FOUND));
}

boolean existsByNickname(String nickname);

boolean existsByNicknameAndSubmitterState(String nickname, String submitterState);
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void isDuplicatedSubmission(Submitter submitter) {
private void isDuplicatedNickname(String nickname) {
if (hostRepository.existsByNickname(nickname)) {
throw new CustomException(ErrorCode.DUPLICATION_NICKNAME);
} else if (submitterRepository.existsByNickname(nickname)) {
} else if (submitterRepository.existsByNicknameAndSubmitterState(nickname, "pending")) {
throw new CustomException(ErrorCode.DUPLICATION_NICKNAME);
}
}
Expand Down

0 comments on commit a93b2fb

Please sign in to comment.