From e7ee5ec89fd84a1d42d6af2c656b440f99f69205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Tue, 5 Nov 2024 16:09:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guaiguailang/harmony/controller/UserController.java | 4 +++- .../com/guaiguailang/harmony/domain/dto/ParamUserAdd.java | 2 +- .../harmony/service/impl/UserServiceImpl.java | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/guaiguailang/harmony/controller/UserController.java b/src/main/java/com/guaiguailang/harmony/controller/UserController.java index 9fd640a..e4e5d7a 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/UserController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/UserController.java @@ -59,7 +59,7 @@ public class UserController { description = "加载可以分配的角色,以供用户添加子用户", tags = {"用户相关接口"} ) - @PostMapping("/add/roleList") + @GetMapping("/add/roleList") public ResponseEntity getRoleListWhenAddUser(@RequestParam String role){ /* @@ -75,6 +75,8 @@ public class UserController { ) @PostMapping("/add") public ResponseEntity addUser(@RequestBody ParamUserAdd userAddParam){ +// System.out.println("==============得到数据======="); +// System.out.println(userAddParam.toString()); return ResponseEntity.ok(userService.addUser(userAddParam)); } diff --git a/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserAdd.java b/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserAdd.java index bc942dd..01c9e1b 100644 --- a/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserAdd.java +++ b/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserAdd.java @@ -9,7 +9,7 @@ public class ParamUserAdd { // 创建人 Long creatorId; String name; - String userName; + String username; String password; String email; String telphone; diff --git a/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java b/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java index 027bc47..2d6c18c 100644 --- a/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java +++ b/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java @@ -141,7 +141,7 @@ public class UserServiceImpl implements UserService { @Override public ResponseResult addUser(ParamUserAdd userAddParam) { // 先根据用户账号username查询用户是否存在,避免重复 - UserInfo userInfo = getUserByAccount(userAddParam.getUserName()); + UserInfo userInfo = getUserByAccount(userAddParam.getUsername()); if (userInfo != null) { return ResponseResult.error("用户账号已存在"); } @@ -185,19 +185,19 @@ public class UserServiceImpl implements UserService { @Override public ResponseResult registerUser(ParamUserAdd userAddParam) { // 1 确保有数据,数据要正确(符合要求 账号应当不长于64位字符)。 - if(userAddParam.getUserName() == null || userAddParam.getUserName().length() > 64) + if(userAddParam.getUsername() == null || userAddParam.getUsername().length() > 64) return ResponseResult.error("账号长度应当不超过64位字符"); // 2 验证码要查询数据库,确保验证码时间在有效期内容且正确。 根据用户账号去查询验证码表。 LogCaptcha logCaptcha = new LogCaptcha(); logCaptcha.setCode(userAddParam.getCode()); - logCaptcha.setUsername(userAddParam.getUserName()); + logCaptcha.setUsername(userAddParam.getUsername()); logCaptcha.setCreateTime(LocalDateTime.now()); logCaptcha.setStatus("1"); List logCaptchaList = logCaptchaMapper.verifyCode(logCaptcha); if(logCaptchaList.size() == 0) return ResponseResult.error("验证码错误或已过期"); //3 确保数据不重复,应当判断账号是否唯一,不允许重复注册 - UserInfo userByAccount = userMapper.getUserByAccount(userAddParam.getUserName()); + UserInfo userByAccount = userMapper.getUserByAccount(userAddParam.getUsername()); if(userByAccount != null) return ResponseResult.error("账号已存在"); //4 密码应当使用加密工具加密后再存储