diff --git a/luoo_common/src/main/java/util/StringTools.java b/luoo_common/src/main/java/util/StringTools.java index 6e0490a..a0e1778 100644 --- a/luoo_common/src/main/java/util/StringTools.java +++ b/luoo_common/src/main/java/util/StringTools.java @@ -9,4 +9,12 @@ public class StringTools { } return false; } + public static String getFileSuffix(String fileName) { + Integer index = fileName.lastIndexOf("."); + if (index == -1) { + return ""; + } + String suffix = fileName.substring(index); + return suffix; + } } diff --git a/luoo_user/src/main/java/com/luoo/user/constants/Constants.java b/luoo_user/src/main/java/com/luoo/user/constants/Constants.java index 16e4cd9..1abd754 100644 --- a/luoo_user/src/main/java/com/luoo/user/constants/Constants.java +++ b/luoo_user/src/main/java/com/luoo/user/constants/Constants.java @@ -11,4 +11,7 @@ public class Constants { public static final String TOKEN_ROLE_APP_USER="user"; public static final String TOKEN_ROLE_ADMIN_USER="admin"; public static final String TOKEN_ROLE_TOURIST="tourist"; + + + public static final String FOLDER_AVATAR = "avatar/"; } diff --git a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java b/luoo_user/src/main/java/com/luoo/user/controller/UserController.java index 5eacdb4..99ffa2c 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/UserController.java @@ -90,7 +90,7 @@ public class UserController { return Result.success(map); } - @ApiOperation(value = "2.登录/注册",notes="成功后返回用户信息和token") + @ApiOperation(value = "2.登录/注册",notes="成功后返回token") @PostMapping("/appLogin/{mobile}/{mobileCheckCode}") @GlobalInterceptor 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); } 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); - userRespDTO.setToken(token); - return Result.success(userRespDTO); + return Result.success(token); }finally { redisTemplate.delete(redisMobileCheckCodeKey); } @@ -120,22 +117,18 @@ public class UserController { @ApiOperation(value = "3.游客登录返回token", notes = "token中的subject和roles均为tourist") @GetMapping("/touristLogin") - public Result touristLogin() { - UserRespDTO userRespDTO=new UserRespDTO(); - userRespDTO.setId(String.valueOf(idWorker.nextId())); + public Result touristLogin() { String nickName="游客-"+NickNameUtil.getRandomNickName(); - userRespDTO.setNickname("游客-"+NickNameUtil.getRandomNickName()); - String token = jwtUtil.createJWT(userRespDTO.getId(),nickName,Constants.TOKEN_ROLE_TOURIST); - userRespDTO.setToken(token); - return Result.success(userRespDTO); + String token = jwtUtil.createJWT(String.valueOf(idWorker.nextId()),nickName,Constants.TOKEN_ROLE_TOURIST); + return Result.success(token); } /** * 发送短信验证码 */ - @ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天最多发50次请求") + @ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一分钟内只能请求1次") @PostMapping("/sendsms/{mobile}") - @GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50) + @GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.MINUTE, requestFrequencyThreshold = 1) public Result sendSms(@PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE)String mobile) { userService.sendSms(mobile); return Result.success();