用户表增加unitId字段,新建运维单位账号绑定unitId
| | |
| | | @ApiModelProperty("单位名称") |
| | | private String unitName; |
| | | |
| | | @NotBlank(message = "单位联系人不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("单位联系人") |
| | | private String unitContact; |
| | | |
| | | @NotBlank(message = "单位联系人电话不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("单位联系人电话") |
| | | private String unitContactPhone; |
| | | |
| | | @NotBlank(message = "单位管理员账号不能为空", groups = {Add.class, Update.class}) |
| | | @NotBlank(message = "单位账号不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("单位管理员账号") |
| | | private String unitAdminAccount; |
| | | |
| | | @NotBlank(message = "备注不能为空", groups = {Add.class, Update.class}) |
| | | @NotBlank(message = "账号密码不能为空") |
| | | @ApiModelProperty("账号密码") |
| | | private String password; |
| | | |
| | | @ApiModelProperty("备注") |
| | | private String remark; |
| | | |
| | |
| | | /** 用户ID */ |
| | | private Long userId; |
| | | |
| | | /** 单位ID */ |
| | | private Integer unitId; |
| | | |
| | | /** 部门ID */ |
| | | private Long deptId; |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | public Integer getUnitId() { |
| | | return unitId; |
| | | } |
| | | |
| | | public void setUnitId(Integer unitId) { |
| | | this.unitId = unitId; |
| | | } |
| | | |
| | | public Short getFirstLogin() { |
| | | return firstLogin; |
| | | } |
| | |
| | | // 新增运维人员账号 |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setDeptId(null); |
| | | sysUser.setUnitId(entity.getId()); |
| | | sysUser.setUserName(entity.getUnitAdminAccount()); |
| | | sysUser.setNickName(entity.getUnitContact()); |
| | | sysUser.setPhonenumber(entity.getUnitContactPhone()); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword("123456")); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(form.getPassword())); |
| | | sysUser.setDelFlag(0); |
| | | sysUserMapper.insertUser(sysUser); |
| | | // 获取运维人员角色 |
| | | SysRole sysRole = sysRoleMapper.selectRoleByKey("yw_user"); |
| | | if (Objects.isNull(sysRole)) { return Result.error("运维角色不存在"); } |
| | | if (Objects.isNull(sysRole)) { throw new RuntimeException("运维角色不存在"); } |
| | | // 绑定账号角色关系 |
| | | SysUserRole sysUserRole = new SysUserRole(); |
| | | sysUserRole.setRoleId(sysRole.getRoleId()); |
| | |
| | | |
| | | <resultMap type="com.ycl.system.entity.SysUser" id="SysUserResult"> |
| | | <id property="userId" column="user_id" /> |
| | | <result property="unitId" column="unit_id" /> |
| | | <result property="deptId" column="dept_id" /> |
| | | <result property="userName" column="user_name" /> |
| | | <result property="nickName" column="nick_name" /> |
| | |
| | | <sql id="selectUserVo"> |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.first_login, |
| | | d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, |
| | | r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status |
| | | r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status, u.unit_id |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | |
| | | </sql> |
| | | |
| | | <select id="selectUserList" parameterType="com.ycl.system.entity.SysUser" resultMap="SysUserResult"> |
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u |
| | | select u.user_id, u.unit_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | where u.del_flag = 0 |
| | | <if test="userId != null and userId != 0"> |
| | |
| | | <if test="status != null and status != ''">status,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="unitId != null">unit_id,</if> |
| | | create_time |
| | | )values( |
| | | <if test="userId != null and userId != ''">#{userId},</if> |
| | |
| | | <if test="status != null and status != ''">#{status},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="unitId != null">#{unitId},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | |
| | | <if test="loginDate != null">login_date = #{loginDate},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | <if test="unitId != null">unit_id = #{unitId},</if> |
| | | <if test="firstLogin !=null ">first_login = #{firstLogin}</if> |
| | | </set> |
| | | where user_id = #{userId} |