From 52dbe961678ff2757ce47ee12c75eb48634904a1 Mon Sep 17 00:00:00 2001 From: Gary Date: Sun, 14 Jan 2024 23:03:18 +0800 Subject: [PATCH] 1.change default nick name --- .../main/java/com/luoo/user/controller/UserController.java | 2 +- .../main/java/com/luoo/user/dto/response/UserRespDTO.java | 2 +- .../src/main/java/com/luoo/user/service/UserService.java | 2 +- .../src/main/java/com/luoo/user/util/NickNameUtil.java | 6 +----- 4 files changed, 4 insertions(+), 8 deletions(-) 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 1310299..8ba1b22 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 @@ -120,7 +120,7 @@ public class UserController { public Result touristLogin() { UserRespDTO userRespDTO=new UserRespDTO(); userRespDTO.setId(String.valueOf(idWorker.nextId())); - userRespDTO.setNickname("游客"+NickNameUtil.getRandomNickName()); + userRespDTO.setNickname("游客-"+NickNameUtil.getRandomNickName()); String token = jwtUtil.createJWT(userRespDTO.getId(),"tourist","tourist"); userRespDTO.setToken(token); return Result.success(userRespDTO); diff --git a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java index e8de653..3dbac49 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java @@ -6,7 +6,7 @@ import lombok.Data; public class UserRespDTO { @ApiModelProperty(value = "ID") private String id;//ID - @ApiModelProperty(value = "昵称,首次注册登录,登录用户随机为“雀乐XXX”,游客为“游客XXX”",example="雀乐XXX") + @ApiModelProperty(value = "昵称,首次注册登录,登录用户随机为“雀乐-XXX”,游客为“游客-XXX”, XXX 为2~4位中文昵称",example="雀乐-XXX") private String nickname;//昵称 @ApiModelProperty(value = "性别,0为男,1 为女,首次注册登录,留空不显示",example="0") private String sex;//性别 diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserService.java b/luoo_user/src/main/java/com/luoo/user/service/UserService.java index f933606..82ddd04 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserService.java @@ -269,7 +269,7 @@ public class UserService { user = new User(); user.setId(String.valueOf(idWorker.nextId())); user.setMobile(mobile); - user.setNickname("雀乐" + NickNameUtil.getRandomNickName()); + user.setNickname("雀乐-" + NickNameUtil.getRandomNickName()); userDao.save(user); } else { user.setLastdate(new Date()); diff --git a/luoo_user/src/main/java/com/luoo/user/util/NickNameUtil.java b/luoo_user/src/main/java/com/luoo/user/util/NickNameUtil.java index f5f3966..f65db86 100644 --- a/luoo_user/src/main/java/com/luoo/user/util/NickNameUtil.java +++ b/luoo_user/src/main/java/com/luoo/user/util/NickNameUtil.java @@ -4,10 +4,6 @@ import com.apifan.common.random.RandomSource; public class NickNameUtil { public static String getRandomNickName() { - String rawNickName=RandomSource.personInfoSource().randomChineseNickName(3); - if(rawNickName.length()>3) { - return rawNickName.substring(0, 3); - } - return rawNickName; + return RandomSource.personInfoSource().randomChineseNickName(4); } }