Skip to content

Commit 9b80717

Browse files
authored
Merge pull request #161 from ASSU-org/refactor/#160-phone-api-integration
[REFACTOR/#160] 전화번호 중복 가입 확인 API와 검증 번호 전송 API 통합
2 parents d2f3498 + e83537c commit 9b80717

File tree

7 files changed

+32
-56
lines changed

7 files changed

+32
-56
lines changed

src/main/java/com/assu/server/domain/auth/controller/AuthController.java

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,29 @@
3737
public class AuthController {
3838

3939
private final PhoneAuthService phoneAuthService;
40+
private final EmailAuthService emailAuthService;
4041
private final SignUpService signUpService;
4142
private final LoginService loginService;
4243
private final LogoutService logoutService;
4344
private final SSUAuthService ssuAuthService;
4445
private final WithdrawalService withdrawalService;
45-
private final VerificationService verificationService;
4646

4747
@Operation(
48-
summary = "휴대폰 인증번호 발송 API",
49-
description = "# [v1.0 (2025-09-03)](https://clumsy-seeder-416.notion.site/2241197c19ed801bbcd9f61c3e5f5457?source=copy_link)\n" +
48+
summary = "휴대폰 번호 중복가입 확인 및 인증번호 발송 API",
49+
description = "# [v1.1 (2025-09-25)](https://clumsy-seeder-416.notion.site/2241197c19ed801bbcd9f61c3e5f5457?source=copy_link)\n" +
5050
"- 입력한 휴대폰 번호로 1회용 인증번호(OTP)를 발송합니다.\n" +
51+
"- 중복된 전화번호가 있으면 에러를 반환합니다.\n" +
5152
"- 유효시간/재요청 제한 정책은 서버 설정에 따릅니다.\n" +
5253
"\n**Request Body:**\n" +
5354
" - `phoneNumber` (String, required): 인증번호를 받을 휴대폰 번호\n" +
5455
"\n**Response:**\n" +
5556
" - 성공 시 200(OK)과 성공 메시지 반환"
5657
)
57-
@PostMapping("/phone-verification/send")
58-
public BaseResponse<Void> sendAuthNumber(
58+
@PostMapping("/phone-verification/check-and-send")
59+
public BaseResponse<Void> checkPhoneAvailabilityAndSendAuthNumber(
5960
@RequestBody @Valid PhoneAuthRequestDTO.PhoneAuthSendRequest request
6061
) {
61-
phoneAuthService.sendAuthNumber(request.getPhoneNumber());
62+
phoneAuthService.checkAndSendAuthNumber(request.getPhoneNumber());
6263
return BaseResponse.onSuccess(SuccessStatus.SEND_AUTH_NUMBER_SUCCESS, null);
6364
}
6465

@@ -84,23 +85,7 @@ public BaseResponse<Void> checkAuthNumber(
8485
return BaseResponse.onSuccess(SuccessStatus.VERIFY_AUTH_NUMBER_SUCCESS, null);
8586
}
8687

87-
@Operation(summary = "전화번호 중복 체크 API",
88-
description = "# [v1.0 (2025-09-18)](https://clumsy-seeder-416.notion.site/2551197c19ed808a9757f7f0fc4cf09b?source=copy_link)\n" +
89-
"- 입력한 전화번호가 이미 가입된 사용자가 있는지 확인합니다.\n" +
90-
"- 중복된 전화번호가 있으면 에러를 반환합니다.\n" +
91-
"\n**Request Body:**\n" +
92-
" - `phoneNumber` (String, required): 확인할 전화번호 (010XXXXXXXX 형식)\n" +
93-
"\n**Response:**\n" +
94-
" - 성공 시 200(OK)과 사용 가능 메시지 반환\n" +
95-
" - 중복 시 404(NOT_FOUND)와 에러 메시지 반환")
96-
@PostMapping("/phone-verification/check")
97-
public BaseResponse<Void> checkPhoneNumberAvailability(
98-
@RequestBody @Valid VerificationRequestDTO.PhoneVerificationCheckRequest request) {
99-
verificationService.checkPhoneNumberAvailability(request);
100-
return BaseResponse.onSuccess(SuccessStatus._OK, null);
101-
}
102-
103-
@Operation(summary = "이메일 중복 체크 API",
88+
@Operation(summary = "이메일 형식 및 중복가입 확인 API",
10489
description = "# [v1.0 (2025-09-18)](https://clumsy-seeder-416.notion.site/2551197c19ed802d8f6dd373dd045f3a?source=copy_link)\n" +
10590
"- 입력한 이메일이 이미 가입된 사용자가 있는지 확인합니다.\n" +
10691
"- 중복된 이메일이 있으면 에러를 반환합니다.\n" +
@@ -112,7 +97,7 @@ public BaseResponse<Void> checkPhoneNumberAvailability(
11297
@PostMapping("/email-verification/check")
11398
public BaseResponse<Void> checkEmailAvailability(
11499
@RequestBody @Valid VerificationRequestDTO.EmailVerificationCheckRequest request) {
115-
verificationService.checkEmailAvailability(request);
100+
emailAuthService.checkEmailAvailability(request);
116101
return BaseResponse.onSuccess(SuccessStatus._OK, null);
117102
}
118103

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.assu.server.domain.auth.service;
2+
3+
import com.assu.server.domain.auth.dto.verification.VerificationRequestDTO;
4+
5+
public interface EmailAuthService {
6+
7+
void checkEmailAvailability(VerificationRequestDTO.EmailVerificationCheckRequest request);
8+
}

src/main/java/com/assu/server/domain/auth/service/VerificationServiceImpl.java renamed to src/main/java/com/assu/server/domain/auth/service/EmailAuthServiceImpl.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,18 @@
33
import com.assu.server.domain.auth.dto.verification.VerificationRequestDTO;
44
import com.assu.server.domain.auth.exception.CustomAuthException;
55
import com.assu.server.domain.auth.repository.CommonAuthRepository;
6-
import com.assu.server.domain.member.repository.MemberRepository;
76
import com.assu.server.global.apiPayload.code.status.ErrorStatus;
87
import lombok.RequiredArgsConstructor;
98
import org.springframework.stereotype.Service;
109

1110
@Service
1211
@RequiredArgsConstructor
13-
public class VerificationServiceImpl implements VerificationService {
12+
public class EmailAuthServiceImpl implements EmailAuthService {
1413

15-
private final MemberRepository memberRepository;
1614
private final CommonAuthRepository commonAuthRepository;
1715

1816
@Override
19-
public void checkPhoneNumberAvailability(
20-
VerificationRequestDTO.PhoneVerificationCheckRequest request) {
21-
22-
boolean exists = memberRepository.existsByPhoneNum(request.getPhoneNumber());
23-
24-
if (exists) {
25-
throw new CustomAuthException(ErrorStatus.EXISTED_PHONE);
26-
}
27-
}
28-
29-
@Override
30-
public void checkEmailAvailability(
31-
VerificationRequestDTO.EmailVerificationCheckRequest request) {
17+
public void checkEmailAvailability(VerificationRequestDTO.EmailVerificationCheckRequest request) {
3218

3319
boolean exists = commonAuthRepository.existsByEmail(request.getEmail());
3420

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.assu.server.domain.auth.service;
22

33
public interface PhoneAuthService {
4-
void sendAuthNumber(String phoneNumber);
4+
void checkAndSendAuthNumber(String phoneNumber);
55
void verifyAuthNumber(String phoneNumber, String authNumber);
66
}

src/main/java/com/assu/server/domain/auth/service/PhoneAuthServiceImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.assu.server.domain.auth.service;
22

3+
import com.assu.server.domain.member.repository.MemberRepository;
34
import com.assu.server.global.apiPayload.code.status.ErrorStatus;
45
import com.assu.server.global.util.RandomNumberUtil;
56
import com.assu.server.domain.auth.exception.CustomAuthException;
@@ -18,11 +19,18 @@ public class PhoneAuthServiceImpl implements PhoneAuthService {
1819

1920
private final StringRedisTemplate redisTemplate;
2021
private final AligoSmsClient aligoSmsClient;
22+
private final MemberRepository memberRepository;
2123

2224
private static final Duration AUTH_CODE_TTL = Duration.ofMinutes(5); // 인증번호 5분 유효
2325

2426
@Override
25-
public void sendAuthNumber(String phoneNumber) {
27+
public void checkAndSendAuthNumber(String phoneNumber) {
28+
boolean exists = memberRepository.existsByPhoneNum(phoneNumber);
29+
30+
if (exists) {
31+
throw new CustomAuthException(ErrorStatus.EXISTED_PHONE);
32+
}
33+
2634
String authNumber = RandomNumberUtil.generateSixDigit();
2735
redisTemplate.opsForValue().set(phoneNumber, authNumber, AUTH_CODE_TTL);
2836

src/main/java/com/assu/server/domain/auth/service/VerificationService.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/com/assu/server/global/apiPayload/code/status/ErrorStatus.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public enum ErrorStatus implements BaseErrorCode {
5353
NO_PAPER_FOR_STORE(HttpStatus.NOT_FOUND, "ADMIN_4005", "존재하지 않는 paper ID입니다."),
5454
NO_AVAILABLE_PARTNER(HttpStatus.NOT_FOUND, "MEMBER_4009", "제휴업체를 찾을 수 없습니다."),
5555
NO_SUCH_STORE_WITH_THAT_PARTNER(HttpStatus.NOT_FOUND,"MEMBER_4006","해당 store ID에 해당하는 partner ID가 존재하지 않습니다."),
56-
EXISTED_PHONE(HttpStatus.NOT_FOUND,"MEMBER_4007","이미 존재하는 전화번호입니다."),
57-
EXISTED_EMAIL(HttpStatus.NOT_FOUND,"MEMBER_4008","이미 존재하는 이메일입니다."),
58-
EXISTED_STUDENT(HttpStatus.NOT_FOUND,"MEMBER_4009","이미 존재하는 학번입니다."),
56+
EXISTED_PHONE(HttpStatus.CONFLICT,"MEMBER_4007","이미 존재하는 전화번호입니다."),
57+
EXISTED_EMAIL(HttpStatus.CONFLICT,"MEMBER_4008","이미 존재하는 이메일입니다."),
58+
EXISTED_STUDENT(HttpStatus.CONFLICT,"MEMBER_4009","이미 존재하는 학번입니다."),
5959

6060
MEMBER_ALREADY_WITHDRAWN(HttpStatus.BAD_REQUEST, "MEMBER_4010", "이미 탈퇴된 회원입니다."),
6161

0 commit comments

Comments
 (0)