controller
/**
* 发送短信验证码
*
* @return
*/
@PostMapping("phone/sendVerificationCode")
public ResponseEntity
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 条评论) “” |