Skip to content

Commit

Permalink
feat: 新增会员绑定手机号功能
Browse files Browse the repository at this point in the history
  • Loading branch information
lele0626 committed Dec 4, 2023
1 parent 71ed58e commit 071f153
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,28 @@ public ResultMessage<Object> smsLogin(@NotNull(message = "手机号为空") @Req
}
}

@ApiOperation(value = "绑定手机号")
@ApiImplicitParams({
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query"),
})
@PostMapping("/bindMobile")
public ResultMessage<Object> bindMobile(@NotNull(message = "用户名不能为空") @RequestParam String username,
@NotNull(message = "手机号为空") @RequestParam String mobile,
@NotNull(message = "验证码为空") @RequestParam String code,
@RequestHeader String uuid) {
if (smsUtil.verifyCode(mobile, VerificationEnums.BIND_MOBILE, uuid, code)) {
Member member = memberService.findByUsername(username);
if (member == null) {
throw new ServiceException(ResultCode.USER_NOT_EXIST);
}
return ResultUtil.data(memberService.changeMobile(member.getId(), mobile));
} else {
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
}
}

@ApiOperation(value = "注册用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void sendSmsCode(String mobile, VerificationEnums verificationEnums, Stri
break;
}
//注册
case BIND_MOBILE:
case REGISTER: {
templateCode = smsTemplateProperties.getREGISTER();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public enum VerificationEnums {
* 找回用户
* 修改密码
* 支付钱包密码
* 绑定手机号
*/
LOGIN,
REGISTER,
FIND_USER,
UPDATE_PASSWORD,
WALLET_PASSWORD;
WALLET_PASSWORD,
BIND_MOBILE;
}


0 comments on commit 071f153

Please sign in to comment.