fix: 用户字段大小写问题

This commit is contained in:
萌狼蓝天 2024-11-05 16:09:26 +08:00
parent a75c4c3bd5
commit e7ee5ec89f
3 changed files with 8 additions and 6 deletions

View File

@ -59,7 +59,7 @@ public class UserController {
description = "加载可以分配的角色,以供用户添加子用户", description = "加载可以分配的角色,以供用户添加子用户",
tags = {"用户相关接口"} tags = {"用户相关接口"}
) )
@PostMapping("/add/roleList") @GetMapping("/add/roleList")
public ResponseEntity getRoleListWhenAddUser(@RequestParam String role){ public ResponseEntity getRoleListWhenAddUser(@RequestParam String role){
/* /*
@ -75,6 +75,8 @@ public class UserController {
) )
@PostMapping("/add") @PostMapping("/add")
public ResponseEntity addUser(@RequestBody ParamUserAdd userAddParam){ public ResponseEntity addUser(@RequestBody ParamUserAdd userAddParam){
// System.out.println("==============得到数据=======");
// System.out.println(userAddParam.toString());
return ResponseEntity.ok(userService.addUser(userAddParam)); return ResponseEntity.ok(userService.addUser(userAddParam));
} }

View File

@ -9,7 +9,7 @@ public class ParamUserAdd {
// 创建人 // 创建人
Long creatorId; Long creatorId;
String name; String name;
String userName; String username;
String password; String password;
String email; String email;
String telphone; String telphone;

View File

@ -141,7 +141,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public ResponseResult addUser(ParamUserAdd userAddParam) { public ResponseResult addUser(ParamUserAdd userAddParam) {
// 先根据用户账号username查询用户是否存在避免重复 // 先根据用户账号username查询用户是否存在避免重复
UserInfo userInfo = getUserByAccount(userAddParam.getUserName()); UserInfo userInfo = getUserByAccount(userAddParam.getUsername());
if (userInfo != null) { if (userInfo != null) {
return ResponseResult.error("用户账号已存在"); return ResponseResult.error("用户账号已存在");
} }
@ -185,19 +185,19 @@ public class UserServiceImpl implements UserService {
@Override @Override
public ResponseResult registerUser(ParamUserAdd userAddParam) { public ResponseResult registerUser(ParamUserAdd userAddParam) {
// 1 确保有数据数据要正确符合要求 账号应当不长于64位字符 // 1 确保有数据数据要正确符合要求 账号应当不长于64位字符
if(userAddParam.getUserName() == null || userAddParam.getUserName().length() > 64) if(userAddParam.getUsername() == null || userAddParam.getUsername().length() > 64)
return ResponseResult.error("账号长度应当不超过64位字符"); return ResponseResult.error("账号长度应当不超过64位字符");
// 2 验证码要查询数据库确保验证码时间在有效期内容且正确 根据用户账号去查询验证码表 // 2 验证码要查询数据库确保验证码时间在有效期内容且正确 根据用户账号去查询验证码表
LogCaptcha logCaptcha = new LogCaptcha(); LogCaptcha logCaptcha = new LogCaptcha();
logCaptcha.setCode(userAddParam.getCode()); logCaptcha.setCode(userAddParam.getCode());
logCaptcha.setUsername(userAddParam.getUserName()); logCaptcha.setUsername(userAddParam.getUsername());
logCaptcha.setCreateTime(LocalDateTime.now()); logCaptcha.setCreateTime(LocalDateTime.now());
logCaptcha.setStatus("1"); logCaptcha.setStatus("1");
List<LogCaptcha> logCaptchaList = logCaptchaMapper.verifyCode(logCaptcha); List<LogCaptcha> logCaptchaList = logCaptchaMapper.verifyCode(logCaptcha);
if(logCaptchaList.size() == 0) if(logCaptchaList.size() == 0)
return ResponseResult.error("验证码错误或已过期"); return ResponseResult.error("验证码错误或已过期");
//3 确保数据不重复应当判断账号是否唯一不允许重复注册 //3 确保数据不重复应当判断账号是否唯一不允许重复注册
UserInfo userByAccount = userMapper.getUserByAccount(userAddParam.getUserName()); UserInfo userByAccount = userMapper.getUserByAccount(userAddParam.getUsername());
if(userByAccount != null) if(userByAccount != null)
return ResponseResult.error("账号已存在"); return ResponseResult.error("账号已存在");
//4 密码应当使用加密工具加密后再存储 //4 密码应当使用加密工具加密后再存储