|
|
@ -107,8 +107,12 @@ 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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
return Result.success(token);
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
|
|
|
|
map.put("token", token);
|
|
|
|
|
|
|
|
return Result.success(map);
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
|
redisTemplate.delete(redisMobileCheckCodeKey);
|
|
|
|
redisTemplate.delete(redisMobileCheckCodeKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -117,10 +121,12 @@ 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<String> touristLogin() {
|
|
|
|
public Result<Map<String,String>> touristLogin() {
|
|
|
|
String nickName="游客-"+NickNameUtil.getRandomNickName();
|
|
|
|
String nickName="游客-"+NickNameUtil.getRandomNickName();
|
|
|
|
String token = jwtUtil.createJWT(String.valueOf(idWorker.nextId()),nickName,Constants.TOKEN_ROLE_TOURIST);
|
|
|
|
String token = jwtUtil.createJWT(String.valueOf(idWorker.nextId()),nickName,Constants.TOKEN_ROLE_TOURIST);
|
|
|
|
return Result.success(token);
|
|
|
|
Map<String,String> map=new HashMap<>();
|
|
|
|
|
|
|
|
map.put("token", token);
|
|
|
|
|
|
|
|
return Result.success(map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -140,8 +146,10 @@ public class UserController {
|
|
|
|
@ApiOperation(value = "5.token续期", notes = "有效期7天")
|
|
|
|
@ApiOperation(value = "5.token续期", notes = "有效期7天")
|
|
|
|
@PostMapping("/autoLogin")
|
|
|
|
@PostMapping("/autoLogin")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
|
public Result<String> autoLogin(@RequestHeader(value = "token", required = false) String token) {
|
|
|
|
public Result<Map<String, String>> autoLogin(@RequestHeader(value = "token", required = false) String token) {
|
|
|
|
return Result.success(userService.autoLogin(token));
|
|
|
|
Map<String,String> map=new HashMap<>();
|
|
|
|
|
|
|
|
map.put("token", userService.autoLogin(token));
|
|
|
|
|
|
|
|
return Result.success(map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|