Skip to content

Commit

Permalink
feat: verify-code api 응답으로 회원가입 여부 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
twoosky committed Oct 17, 2023
1 parent d171150 commit 4051438
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.tago.api.infra.sms.domain.dto.SmsRequest;
import com.tago.api.infra.sms.domain.dto.SmsResponse;
import com.tago.api.infra.sms.util.VerificationCodeUtil;
import com.tago.domain.member.handler.MemberQueryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

Expand All @@ -13,14 +14,21 @@ public class SmsService {

private final SmsClient smsClient;
private final VerificationCodeUtil verificationCodeUtil;
private final MemberQueryService memberQueryService;

public void send(SmsRequest.Send request) {
smsClient.send(request);
}

public SmsResponse.VerifyCode verifyCode(SmsRequest.VerifyCode request) {
verificationCodeUtil.verify(request.getNumber(), request.getCode());
return new SmsResponse.VerifyCode(true);
return new SmsResponse.VerifyCode(true, isSignUp(request.getNumber()));
}

public Boolean isSignUp(String number) {
String regEx = "(\\d{3})(\\d{3,4})(\\d{4})";
String phoneNumber = number.replaceAll(regEx, "$1-$2-$3");
return memberQueryService.existsByPhoneNumber(phoneNumber);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class SmsResponse {
@AllArgsConstructor
@Schema(name = "AuthSmsVerifyCodeResponse")
public static class VerifyCode {
private boolean isVerify;
private Boolean isVerify;
private Boolean isSignUp;
}
}

0 comments on commit 4051438

Please sign in to comment.