Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #119 프로필 수정 시 닉네임 중복 체크 추가 #119

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public MemberResponseDto getMember(Long currentId){
@Transactional
public MemberResponseDto updateMemberInfo(Long currentId, MemberInfoRequestDto dto){
Members member = findById(currentId);
checkDuplicatedNickName(dto.nickName(), member);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

PR에 적어주신 내용 관련해서 제 생각은, 똑같은 닉네임이라면 별도의 예외를 발생시키지 않는 것이 더 자연스러운 흐름이 아닐까라는 생각이 있고 똑같은 닉네임 입력 시 프론트에서 "현재 닉네임과 동일합니다" 와 비슷한 메세지를 주는 건 유저 입장에서 좋아보입니다 !

예외 처리는 보통 비정상적인 상황을 방지하기 위한 목적으로 사용된다고 이해하고 있어서,
닉네임 수정의 경우에도 기존 닉네임과 동일하게 입력했을 때 예외를 발생시키기보다는, 단순히 변경이 이루어지지 않도록 처리해주는 지금 방식이 적절한거 같습니다 !


member.updateMemberInfo(dto);

chattingMessageMongoRepository.updateMemberInfo(member);
Expand Down Expand Up @@ -122,4 +124,12 @@ private void checkDuplicatedNickName(String nickName) {
});
}

private void checkDuplicatedNickName(String nickName, Members member) {
memberRepository.findByNickname(nickName).ifPresent(m -> {
if (!m.equals(member)) {
throw new DuplicatedNickNameException();
}
});
}

}