Skip to content

Commit

Permalink
[FEAT] 폰 번호 중복 확인
Browse files Browse the repository at this point in the history
  • Loading branch information
sectionr0 committed Aug 18, 2023
1 parent 7f39cc2 commit 2702e12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/plub/plubserver/domain/account/dto/AuthDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public record SignUpRequest(
List<Long> categoryList,
@ApiModelProperty(value = "FCM 토큰", example = "f7mGlaDUTNSx5NOJ8k39bW:APA91bEogtcJPEcYrk5JGxU9GTOB1vq38oI3Jkntu0RgIjSe5pjfr1tAS_oD75ihUBg8Fr2bJ-sy9b_eIzWlbb26MdcpM_dqGVEYzXoVjgXi3P1FlsgpzxbjKPq40iX4Vnxil3GH-7-b")
String fcmToken,
@ApiModelProperty(value = "전화번호", example = "01012345678")
String phone
) {
@Builder
Expand Down Expand Up @@ -107,6 +108,7 @@ public Account toAccount(String email, String socialType, String phone, Password
.joinDate(LocalDateTime.now())
.profileImage(profileImage)
.isReceivedPushNotification(true)
.phone(phone)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface AccountRepository extends JpaRepository<Account, Long>, Account
Optional<Account> findByNickname(String nickname);
boolean existsByEmail(String email);
boolean existsByNickname(String nickname);
boolean existsByPhone(String phone);

/**
* 관리자페이지
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public SignAuthMessage signUp(SignUpRequest signUpRequest) {
policyCheckList.put("usePolicy", usePolicy);
policyCheckList.put("marketPolicy", marketPolicy);

checkDuplicationPhone(phone);
checkDuplicationEmailAndNickName(email, nickname);
Account account = signUpRequest.toAccount(email, socialType, phone, passwordEncoder);

Expand Down Expand Up @@ -159,6 +160,12 @@ public SignAuthMessage signUp(SignUpRequest signUpRequest) {
);
}

private void checkDuplicationPhone(String phone) {
if (accountRepository.existsByPhone(phone)) {
throw new AccountException(StatusCode.ALREADY_EXIST_PHONE);
}
}

private void checkDuplicationEmailAndNickName(String email, String nickname) {
if (accountRepository.existsByEmail(email)) {
throw new AccountException(StatusCode.EMAIL_DUPLICATION);
Expand Down

0 comments on commit 2702e12

Please sign in to comment.