From 5dddfa4f56f8ab7a0f727f93fc43be7df9efd820 Mon Sep 17 00:00:00 2001 From: limehee Date: Mon, 6 May 2024 16:24:55 +0900 Subject: [PATCH] =?UTF-8?q?refactor(Member):=20=EB=A9=A4=EB=B2=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20API=20=EC=A4=91=EB=B3=B5=20=EA=B2=80?= =?UTF-8?q?=EC=82=AC=20=EB=A1=9C=EC=A7=81=20=EC=B5=9C=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clab/api/domain/member/application/MemberService.java | 6 +++--- .../page/clab/api/domain/member/dao/MemberRepository.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/page/clab/api/domain/member/application/MemberService.java b/src/main/java/page/clab/api/domain/member/application/MemberService.java index b0c8eab2e..4de503bcb 100644 --- a/src/main/java/page/clab/api/domain/member/application/MemberService.java +++ b/src/main/java/page/clab/api/domain/member/application/MemberService.java @@ -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("이미 사용 중인 이메일입니다."); } diff --git a/src/main/java/page/clab/api/domain/member/dao/MemberRepository.java b/src/main/java/page/clab/api/domain/member/dao/MemberRepository.java index b88d98b6a..2a24bdbf3 100644 --- a/src/main/java/page/clab/api/domain/member/dao/MemberRepository.java +++ b/src/main/java/page/clab/api/domain/member/dao/MemberRepository.java @@ -12,7 +12,9 @@ @Repository public interface MemberRepository extends JpaRepository, MemberRepositoryCustom, QuerydslPredicateExecutor { - Optional findByContact(String contact); + boolean existsByContact(String contact); + + boolean existsByEmail(String email); Optional findByEmail(String email);