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

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);

View File

@ -152,6 +152,7 @@ public enum ResultCode {
CLERK_DISABLED_ERROR(20031, "店员已禁用"),
CLERK_CURRENT_SUPPER(20032, "无法删除当前登录店员"),
CANT_EDIT_CLERK_SHOPKEEPER(20033, "无法在店员管理编辑店员信息"),
USER_MOBILE_REPEATABLE_ERROR(20034, "该手机号已存在"),
/**
* 权限
*/