判断手机号是否存在,如果存在抛出异常

This commit is contained in:
chc
2024-07-24 10:37:41 +08:00
parent aaa0748409
commit d677aabbf4
2 changed files with 5 additions and 0 deletions

View File

@@ -167,9 +167,13 @@ public class MemberBuyerController {
@RequestHeader String uuid) {
if (smsUtil.verifyCode(mobile, VerificationEnums.BIND_MOBILE, uuid, code)) {
Member member = memberService.findByUsername(username);
Member memberByMobile = memberService.findByMobile(mobile);
if (member == null) {
throw new ServiceException(ResultCode.USER_NOT_EXIST);
}
if(memberByMobile != null){
throw new ServiceException(ResultCode.USER_MOBILE_REPEATABLE_ERROR);
}
return ResultUtil.data(memberService.changeMobile(member.getId(), mobile));
} else {
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);