上一章我们整合了swagger和全局异常处理,到此项目需要的基础东西我们基本准备完毕。这一章我们开始用户管理模块的开发,用的表有用户表(admin_user)、用户角色关联表(user_role_mp)。
1. 创建工程目录我在admin-user工程下创建controller、service、dao、mapper、pojo目录
2. 新增用户创建 用户实体 字段有 id、account、username、password、phone、createTime、updateTime
@Setter
@Getter
@NoArgsConstructor
@TableName("admin_user")
public class DbAdminUserVo extends BaseVo {
private String id;
private String account;
private String userName;
private String password;
private String phone;
@TableField(value = "create_time",fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
public DbAdminUserVo(ReqAddAdminUserVo req) {
this.id = DbIdUtil.getInstance().nextUuid();
this.account = req.getAccount();
this.userName = req.getUserName();
this.password = SmUtil.sm3(req.getAccount() + DecryptPasswordUtil.e(req.getPassword()));
this.phone = req.getPhone();
}
public DbAdminUserVo(ReqUpdateAdminUserVo req) {
this.id = req.getId();
this.account = req.getAccount();
this.userName = req.getUserName();
this.phone = req.getPhone();
}
public DbAdminUserVo(DbAdminUserVo dbAdminUserVo, ReqChangePasswordAdminUserVo req) {
this.id = dbAdminUserVo.getId();
this.account = dbAdminUserVo.getAccount();
this.userName = dbAdminUserVo.getUserName();
this.password = SmUtil.sm3(dbAdminUserVo.getAccount() + DecryptPasswordUtil.e(req.getNewPassword()));
this.phone = dbAdminUserVo.getPhone();
}
}
创建用户和角色关联表实体,因为新增用户的时候需要绑定对应的角色,所以这边我们先把对应的用户角色关联关系先维护好,后续的角色我们到角色管理再说。
@Setter
@Getter
@NoArgsConstructor
@TableName("user_role_mp")
public class DbUserRoleMpVo extends BaseVo {
private String id;
private String userId;
private String roleId;
public DbUserRoleMpVo(String userId, String roleId) {
this.userId = userId;
this.roleId = roleId;
}
}



