Skip to content

Commit

Permalink
[feat] #5 닉네임 중복 예외추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seokjun01 committed Jan 2, 2025
1 parent 77ec8e2 commit 52a2bc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public Void completeRegistration(MemberSignUpRequestDto signUpRequestDto, UserDe
String email = userDetails.getUsername();
// 이메일로 기존 사용자 조회
Member member = memberRepository.findByEmail(email)
.orElseThrow(() -> new CommonException(ErrorCode.USER_NOT_FOUND)); // 추가 정보 업데이트
.orElseThrow(() -> new CommonException(ErrorCode.USER_NOT_FOUND));

if (memberRepository.existsByNickname(signUpRequestDto.getNickname())) {
throw new CommonException(ErrorCode.DUPLICATE_NICKNAME); // 닉네임 중복 예외 발생
}

member.updateMemberDetails(signUpRequestDto.getNickname(), signUpRequestDto.getPhoneNumber(), signUpRequestDto.getStudentNumber(), signUpRequestDto.getGender(), BirthDate.of(signUpRequestDto.getYear(), signUpRequestDto.getMonth(), signUpRequestDto.getDay()), signUpRequestDto.getMbti());
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public enum ErrorCode {
USER_NOT_FOUND(404, "USER_NOT_FOUND", "유저를 찾을 수 없습니다."),

//중복된 회원
MEMBER_ALREADY_EXISTS(409, "MEMBER_ALREADY_EXISTS", "이미 가입된 이메일입니다.");
MEMBER_ALREADY_EXISTS(409, "MEMBER_ALREADY_EXISTS", "이미 가입된 이메일입니다."),

//중복 닉네임
DUPLICATE_NICKNAME(409, "NICKNAME_ALREADY_EXISTS", "이미 존재하는 닉네임입니다.");

private final int status;
private final String code;
Expand Down

0 comments on commit 52a2bc8

Please sign in to comment.