feat: bindMobile

main
wangqing 8 months ago
parent ee744bfd7b
commit c2825ca973

@ -447,8 +447,6 @@ public class MyController extends BaseController {
}
@ApiOperation(value = "12 注销账号", notes = "注销账号")
@PostMapping ("/logOff")
public Result<Void> logOff(@RequestHeader(value = "Authorization", required = true) String authorization, @VerifyParam LogoffReq logoffReq) {
@ -474,6 +472,32 @@ public class MyController extends BaseController {
}
@ApiOperation(value = "13 绑定手机号", notes = "绑定手机号")
@PostMapping ("/bindMobile")
public Result<Void> bindMobile(@RequestHeader(value = "Authorization", required = true) String authorization, @VerifyParam LoginReq loginReq) {
//验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) {
return Result.unauthorized(null);
}
String userId = userLoginDto.getUserId();
// 得到缓存中的验证码
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + loginReq.getDeviceId();
String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey);
if (StringTools.isEmpty(redisMobileCheckCode)) {
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED);
}
if (!redisMobileCheckCode.equals(loginReq.getMobileCheckCode())) {
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_MISMATCH);
}
UserInfo userInfo = userInfoService.findById(userId);
userInfo.setMobile(loginReq.getMobile());
userInfoService.update(userInfo);
return Result.success();
}
private Integer getIndex(UserInfo u) {
return Integer.valueOf(Arrays.stream(u.getBadges().split(",")).filter(s->s.startsWith(String.valueOf(UserBadgeEnum.CONTRIBUTOR.getCode()))).findFirst().get().split("_")[1]);

@ -327,4 +327,9 @@ public class UserInfoService {
return userInfoDao.getThanks();
}
public void bindMobile(UserInfo userInfo){
userInfoDao.save(userInfo);
}
}

Loading…
Cancel
Save