|
|
@ -90,7 +90,7 @@ public class UserController {
|
|
|
|
return Result.success(map);
|
|
|
|
return Result.success(map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "2.登录/注册后返回token")
|
|
|
|
@ApiOperation(value = "2.登录/注册",notes="成功后返回用户信息和token")
|
|
|
|
@PostMapping("/appLogin/{mobile}/{mobileCheckCode}")
|
|
|
|
@PostMapping("/appLogin/{mobile}/{mobileCheckCode}")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
|
public Result appLogin( @PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE)String mobile,
|
|
|
|
public Result appLogin( @PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE)String mobile,
|
|
|
@ -135,7 +135,7 @@ public class UserController {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天最多发50次请求")
|
|
|
|
@ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天最多发50次请求")
|
|
|
|
@PostMapping("/sendsms/{mobile}")
|
|
|
|
@PostMapping("/sendsms/{mobile}")
|
|
|
|
@GlobalInterceptor(checkLogin = true, frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50)
|
|
|
|
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50)
|
|
|
|
public Result<Void> sendSms(@PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE)String mobile) {
|
|
|
|
public Result<Void> sendSms(@PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE)String mobile) {
|
|
|
|
userService.sendSms(mobile);
|
|
|
|
userService.sendSms(mobile);
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
@ -144,17 +144,17 @@ public class UserController {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* token 续期
|
|
|
|
* token 续期
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "5.token 续期,有效期7天")
|
|
|
|
@ApiOperation(value = "5.token续期", notes = "有效期7天")
|
|
|
|
@PostMapping("/autoLogin/{token}")
|
|
|
|
@PostMapping("/autoLogin")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
|
public Result<String> autoLogin(@PathVariable @VerifyParam(required = true) String token) {
|
|
|
|
public Result<String> autoLogin(@RequestHeader(value = "token", required = false) String token) {
|
|
|
|
return Result.success(userService.autoLogin(token));
|
|
|
|
return Result.success(userService.autoLogin(token));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取图行验证码
|
|
|
|
* 获取图行验证码
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "4.三次短信验证码失败后,获取图形验证码,有效期10分钟")
|
|
|
|
@ApiOperation(value="4.获取图形验证码", notes = "4.三次短信验证失败后,获取图形验证码,有效期10分钟")
|
|
|
|
@GetMapping("/imageCheckCode/{mobile}")
|
|
|
|
@GetMapping("/imageCheckCode/{mobile}")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
|
public void imageCheckCode(HttpServletResponse response,
|
|
|
|
public void imageCheckCode(HttpServletResponse response,
|
|
|
@ -179,18 +179,15 @@ public class UserController {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
String redisImageCheckCodeKey=Constants.REDIS_KEY_IMAGE_CHECK_CODE+mobile;
|
|
|
|
String redisImageCheckCodeKey=Constants.REDIS_KEY_IMAGE_CHECK_CODE+mobile;
|
|
|
|
try {
|
|
|
|
String redisImageCheckCode = (String) redisTemplate.opsForValue().get(redisImageCheckCodeKey);
|
|
|
|
String redisImageCheckCode = (String) redisTemplate.opsForValue().get(redisImageCheckCodeKey);
|
|
|
|
if (StringTools.isEmpty(redisImageCheckCode)) {
|
|
|
|
if (StringTools.isEmpty(redisImageCheckCode)) {
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_EXPIRED);
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_EXPIRED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!redisImageCheckCode.equalsIgnoreCase(imageCheckCode)) {
|
|
|
|
if (!redisImageCheckCode.equals(imageCheckCode)) {
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_MISMATCH);
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_MISMATCH);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return appLogin(mobile,mobileCheckCode);
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
|
|
|
redisTemplate.delete(redisImageCheckCodeKey);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
redisTemplate.delete(redisImageCheckCodeKey);
|
|
|
|
|
|
|
|
return appLogin(mobile,mobileCheckCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|