|
|
@ -90,7 +90,7 @@ public class UserController {
|
|
|
|
return Result.success(map);
|
|
|
|
return Result.success(map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "2.登录/注册",notes="成功后返回用户信息和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,
|
|
|
@ -107,11 +107,8 @@ public class UserController {
|
|
|
|
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_MISMATCH);
|
|
|
|
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_MISMATCH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
User user = userService.loginOrRegister(mobile);
|
|
|
|
User user = userService.loginOrRegister(mobile);
|
|
|
|
UserRespDTO userRespDTO=new UserRespDTO();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(user, userRespDTO);
|
|
|
|
|
|
|
|
String token = jwtUtil.createJWT(user.getId(),user.getNickname(),Constants.TOKEN_ROLE_APP_USER);
|
|
|
|
String token = jwtUtil.createJWT(user.getId(),user.getNickname(),Constants.TOKEN_ROLE_APP_USER);
|
|
|
|
userRespDTO.setToken(token);
|
|
|
|
return Result.success(token);
|
|
|
|
return Result.success(userRespDTO);
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
|
redisTemplate.delete(redisMobileCheckCodeKey);
|
|
|
|
redisTemplate.delete(redisMobileCheckCodeKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -120,22 +117,18 @@ public class UserController {
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "3.游客登录返回token", notes = "token中的subject和roles均为tourist")
|
|
|
|
@ApiOperation(value = "3.游客登录返回token", notes = "token中的subject和roles均为tourist")
|
|
|
|
@GetMapping("/touristLogin")
|
|
|
|
@GetMapping("/touristLogin")
|
|
|
|
public Result<UserRespDTO> touristLogin() {
|
|
|
|
public Result<String> touristLogin() {
|
|
|
|
UserRespDTO userRespDTO=new UserRespDTO();
|
|
|
|
|
|
|
|
userRespDTO.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
|
|
|
|
String nickName="游客-"+NickNameUtil.getRandomNickName();
|
|
|
|
String nickName="游客-"+NickNameUtil.getRandomNickName();
|
|
|
|
userRespDTO.setNickname("游客-"+NickNameUtil.getRandomNickName());
|
|
|
|
String token = jwtUtil.createJWT(String.valueOf(idWorker.nextId()),nickName,Constants.TOKEN_ROLE_TOURIST);
|
|
|
|
String token = jwtUtil.createJWT(userRespDTO.getId(),nickName,Constants.TOKEN_ROLE_TOURIST);
|
|
|
|
return Result.success(token);
|
|
|
|
userRespDTO.setToken(token);
|
|
|
|
|
|
|
|
return Result.success(userRespDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 发送短信验证码
|
|
|
|
* 发送短信验证码
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天最多发50次请求")
|
|
|
|
@ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一分钟内只能请求1次")
|
|
|
|
@PostMapping("/sendsms/{mobile}")
|
|
|
|
@PostMapping("/sendsms/{mobile}")
|
|
|
|
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50)
|
|
|
|
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.MINUTE, requestFrequencyThreshold = 1)
|
|
|
|
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();
|
|
|
|