|
@@ -717,9 +717,11 @@ public class JobUserApiController {
|
|
|
@ApiOperation(value = "根据用户手机号获取短信验证码")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "telephone", value = "电话", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "status", value = "是否需要验证(1需要0不需要)", required = true, paramType = "query"),
|
|
|
})
|
|
|
public MessageResult<String> getVerifyCodeByTel(
|
|
|
- String telephone,
|
|
|
+ @RequestParam(value="telephone",defaultValue="") String telephone,
|
|
|
+ @RequestParam(value="status",defaultValue="0") String status,
|
|
|
String token,
|
|
|
@RequestAttribute String subject) {
|
|
|
MessageResult<String> messageResult = new MessageResult<>();
|
|
@@ -730,8 +732,10 @@ public class JobUserApiController {
|
|
|
throw new Exception("未登录!");
|
|
|
}
|
|
|
|
|
|
- if(!jobUser.getTel().equals(telephone)){
|
|
|
- throw new Exception("号码不符!");
|
|
|
+ if("1".equals(status)) {
|
|
|
+ if (!jobUser.getTel().equals(telephone)) {
|
|
|
+ throw new Exception("号码不符!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
String key = "SMS_" + jobUser.getTel();
|
|
@@ -759,6 +763,44 @@ public class JobUserApiController {
|
|
|
return messageResult;
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("validateCodeByTel")
|
|
|
+ @ApiOperation(value = "根据用户手机号验证短信验证码")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "telephone", value = "电话", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "verifyCode", value = "验证码", required = true, paramType = "query"),
|
|
|
+ })
|
|
|
+ public MessageResult<String> validateCodeByTel(
|
|
|
+ @RequestParam(value="verifyCode",defaultValue="") String verifyCode,
|
|
|
+ String telephone,
|
|
|
+ String token,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ String smsKey = "SMS_" + telephone;
|
|
|
+
|
|
|
+ String beforeVerifyCode = (String) valueOperations.get(smsKey);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(beforeVerifyCode)) {
|
|
|
+ throw new Exception("验证码已过期!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!beforeVerifyCode.equals(verifyCode)) {
|
|
|
+ throw new Exception("验证码错误!");
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setData("正确");
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage());
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("logout")
|
|
|
@ApiOperation(value = "登出")
|
|
|
public MessageResult<String> logout(
|