更换手机号 参考代码 步骤(一) 发送短信验证码



controller




/**

* 发送短信验证码

*

* @return

*/

@PostMapping("phone/sendVerificationCode")

public ResponseEntity sendVerificationCode(@RequestHeader("Authorization") String token) {

try {

boolean bool = this.myCenterService.sendVerificationCode(token);

if (bool) {

return ResponseEntity.ok(null);

}

} catch (Exception e) {

e.printStackTrace();

}

return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();

}






=============================================================




service


import com.tanhua.common.pojo.User;

import com.tanhua.sso.vo.ErrorResult;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

@Service

public class MyCenterService {

@Autowired

private UserService userService;

@Autowired

private SmsService smsService;

public Boolean sendVerificationCode(String token) {

//校验token

User user = this.userService.queryUserByToken(token);

if(ObjectUtil.isEmpty(user)){

return false;

}

ErrorResult errorResult = this.smsService.sendCheckCode(user.getMobile());

return errorResult == null;

}

}

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章