fix: 添加用户bug修复

This commit is contained in:
bunny 2024-10-09 14:58:49 +08:00
parent 25d01f0317
commit 73f8f42dd7
2 changed files with 10 additions and 2 deletions

View File

@ -30,6 +30,10 @@ public class AdminUserAddDto {
@Schema(name = "phone", title = "手机号") @Schema(name = "phone", title = "手机号")
private String phone; private String phone;
@Schema(name = "password", title = "密码")
@NotBlank(message = "密码不能为空")
private String password = "123456";
@Schema(name = "avatar", title = "头像") @Schema(name = "avatar", title = "头像")
private String avatar; private String avatar;
@ -37,7 +41,7 @@ public class AdminUserAddDto {
private Byte sex = 1; private Byte sex = 1;
@Schema(name = "summary", title = "个人描述") @Schema(name = "summary", title = "个人描述")
private String summary; private String summary = "这个人很懒,没有介绍";
@Schema(name = "deptId", title = "部门") @Schema(name = "deptId", title = "部门")
@NotNull(message = "部门不能为空") @NotNull(message = "部门不能为空")

View File

@ -300,9 +300,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
*/ */
@Override @Override
public void addAdminUser(@Valid AdminUserAddDto dto) { public void addAdminUser(@Valid AdminUserAddDto dto) {
// 对密码加密
String md5Password = DigestUtils.md5DigestAsHex(dto.getPassword().getBytes());
// 保存数据 // 保存数据
AdminUser adminUser = new AdminUser(); AdminUser adminUser = new AdminUser();
BeanUtils.copyProperties(dto, adminUser); BeanUtils.copyProperties(dto, adminUser);
adminUser.setPassword(md5Password);
save(adminUser); save(adminUser);
// 插入用户部门关系表 // 插入用户部门关系表