mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	新增:部门管理对接用户信息(新增所属部门),并完善查看部门详情(增加上级部门显示)
This commit is contained in:
		| @@ -110,6 +110,18 @@ public class UserInfoVO implements Serializable { | ||||
|     @Schema(description = "注册日期") | ||||
|     private LocalDate registrationDate; | ||||
|  | ||||
|     /** | ||||
|      * 部门ID | ||||
|      */ | ||||
|     @Schema(description = "部门ID") | ||||
|     private Long deptId; | ||||
|  | ||||
|     /** | ||||
|      * 所属部门 | ||||
|      */ | ||||
|     @Schema(description = "所属名称") | ||||
|     private String deptName; | ||||
|  | ||||
|     /** | ||||
|      * 用户角色(临时 mock 用,写完角色体系后移除) | ||||
|      */ | ||||
|   | ||||
| @@ -26,10 +26,12 @@ import cn.hutool.core.bean.BeanUtil; | ||||
| import top.charles7c.cnadmin.auth.service.LoginService; | ||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.cnadmin.common.model.dto.LoginUser; | ||||
| import top.charles7c.cnadmin.common.util.ExceptionUtils; | ||||
| import top.charles7c.cnadmin.common.util.SecureUtils; | ||||
| import top.charles7c.cnadmin.common.util.helper.LoginHelper; | ||||
| import top.charles7c.cnadmin.common.util.validate.CheckUtils; | ||||
| import top.charles7c.cnadmin.system.model.entity.UserDO; | ||||
| import top.charles7c.cnadmin.system.service.DeptService; | ||||
| import top.charles7c.cnadmin.system.service.UserService; | ||||
|  | ||||
| /** | ||||
| @@ -43,6 +45,7 @@ import top.charles7c.cnadmin.system.service.UserService; | ||||
| public class LoginServiceImpl implements LoginService { | ||||
|  | ||||
|     private final UserService userService; | ||||
|     private final DeptService deptService; | ||||
|  | ||||
|     @Override | ||||
|     public String login(String username, String password) { | ||||
| @@ -54,6 +57,7 @@ public class LoginServiceImpl implements LoginService { | ||||
|  | ||||
|         // 登录 | ||||
|         LoginUser loginUser = BeanUtil.copyProperties(userDO, LoginUser.class); | ||||
|         loginUser.setDeptName(ExceptionUtils.exToNull(() -> deptService.get(loginUser.getDeptId()).getDeptName())); | ||||
|         LoginHelper.login(loginUser); | ||||
|  | ||||
|         // 返回令牌 | ||||
|   | ||||
| @@ -94,4 +94,9 @@ public class UserDO extends BaseDO { | ||||
|      * 最后一次修改密码的时间 | ||||
|      */ | ||||
|     private LocalDateTime pwdResetTime; | ||||
|  | ||||
|     /** | ||||
|      * 部门 ID | ||||
|      */ | ||||
|     private Long deptId; | ||||
| } | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.base.BaseDetailVO; | ||||
| import top.charles7c.cnadmin.common.config.easyexcel.ExcelBaseEnumConverter; | ||||
| @@ -79,4 +80,11 @@ public class DeptDetailVO extends BaseDetailVO { | ||||
|     @Schema(description = "状态(1启用 2禁用)") | ||||
|     @ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class) | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     /** | ||||
|      * 上级部门 | ||||
|      */ | ||||
|     @Schema(description = "上级部门") | ||||
|     @TableField(exist = false) | ||||
|     private String parentName; | ||||
| } | ||||
|   | ||||
| @@ -36,7 +36,6 @@ import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.lang.tree.Tree; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.base.BaseDetailVO; | ||||
| import top.charles7c.cnadmin.common.base.BaseServiceImpl; | ||||
| import top.charles7c.cnadmin.common.base.BaseVO; | ||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||
| @@ -211,16 +210,17 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO, | ||||
|     /** | ||||
|      * 填充详情数据 | ||||
|      * | ||||
|      * @param baseDetailVO | ||||
|      * @param detailVO | ||||
|      *            待填充详情信息 | ||||
|      */ | ||||
|     private void fillDetail(BaseDetailVO baseDetailVO) { | ||||
|         this.fill(baseDetailVO); | ||||
|     private void fillDetail(DeptDetailVO detailVO) { | ||||
|         this.fill(detailVO); | ||||
|  | ||||
|         Long updateUser = baseDetailVO.getUpdateUser(); | ||||
|         Long updateUser = detailVO.getUpdateUser(); | ||||
|         if (updateUser == null) { | ||||
|             return; | ||||
|         } | ||||
|         baseDetailVO.setUpdateUserString(ExceptionUtils.exToNull(() -> userService.getById(updateUser)).getNickname()); | ||||
|         detailVO.setUpdateUserString(ExceptionUtils.exToNull(() -> userService.getById(updateUser)).getNickname()); | ||||
|         detailVO.setParentName(ExceptionUtils.exToNull(() -> this.get(detailVO.getParentId()).getDeptName())); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user