Skip to content

Commit

Permalink
refactor(Member): 멤버 생성 API 중복 검사 로직 최적화
Browse files Browse the repository at this point in the history
  • Loading branch information
limehee committed May 6, 2024
1 parent b1b4390 commit 5dddfa4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ private void setRandomPasswordAndSendEmail(Member member) {
}

private void checkMemberUniqueness(MemberRequestDto requestDto) {
if (memberRepository.findById(requestDto.getId()).isPresent())
if (memberRepository.existsById(requestDto.getId()))
throw new DuplicateMemberIdException("이미 사용 중인 아이디입니다.");
if (memberRepository.findByContact(requestDto.getContact()).isPresent())
if (memberRepository.existsByContact(requestDto.getContact()))
throw new DuplicateMemberContactException("이미 사용 중인 연락처입니다.");
if (memberRepository.findByEmail(requestDto.getEmail()).isPresent())
if (memberRepository.existsByEmail(requestDto.getEmail()))
throw new DuplicateMemberEmailException("이미 사용 중인 이메일입니다.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
@Repository
public interface MemberRepository extends JpaRepository<Member, String>, MemberRepositoryCustom, QuerydslPredicateExecutor<Member> {

Optional<Member> findByContact(String contact);
boolean existsByContact(String contact);

boolean existsByEmail(String email);

Optional<Object> findByEmail(String email);

Expand Down

0 comments on commit 5dddfa4

Please sign in to comment.