新增:部门管理对接用户信息(新增所属部门),并完善查看部门详情(增加上级部门显示)
This commit is contained in:
parent
908af28235
commit
c44503b7ea
@ -79,6 +79,16 @@ public class LoginUser implements Serializable {
|
||||
*/
|
||||
private LocalDateTime pwdResetTime;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export interface OperationLogParam extends Partial<OperationLogRecord> {
|
||||
page: number;
|
||||
size: number;
|
||||
sort: Array<string>;
|
||||
uid?: string;
|
||||
uid?: number;
|
||||
}
|
||||
|
||||
export interface OperationLogListRes {
|
||||
|
@ -14,7 +14,8 @@ export interface DeptRecord {
|
||||
createTime?: string;
|
||||
updateUserString?: string;
|
||||
updateTime?: string;
|
||||
children?: Array<DeptRecord>,
|
||||
children?: Array<DeptRecord>;
|
||||
parentName?: string;
|
||||
}
|
||||
|
||||
export interface DeptParam {
|
||||
|
@ -67,7 +67,7 @@ body {
|
||||
.header {
|
||||
margin-bottom: 16px;
|
||||
&-query {
|
||||
margin-bottom: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
&-operation {
|
||||
&-right {
|
||||
|
@ -13,7 +13,7 @@ import useAppStore from '../app';
|
||||
|
||||
const useLoginStore = defineStore('user', {
|
||||
state: (): UserState => ({
|
||||
userId: '',
|
||||
userId: 0,
|
||||
username: '',
|
||||
nickname: '',
|
||||
gender: 0,
|
||||
@ -23,11 +23,11 @@ const useLoginStore = defineStore('user', {
|
||||
description: undefined,
|
||||
pwdResetTime: undefined,
|
||||
registrationDate: undefined,
|
||||
deptId: 0,
|
||||
deptName: '',
|
||||
|
||||
job: 'backend',
|
||||
jobName: '后端艺术家',
|
||||
organization: 'Backend',
|
||||
organizationName: '后端',
|
||||
location: 'beijing',
|
||||
locationName: '北京',
|
||||
introduction: '低调星人',
|
||||
|
@ -1,6 +1,6 @@
|
||||
export type RoleType = '' | '*' | 'admin' | 'user';
|
||||
export interface UserState {
|
||||
userId: string;
|
||||
userId: number;
|
||||
username: string;
|
||||
nickname: string;
|
||||
gender: number;
|
||||
@ -10,11 +10,11 @@ export interface UserState {
|
||||
description?: string;
|
||||
pwdResetTime?: string;
|
||||
registrationDate?: string;
|
||||
deptId?: number;
|
||||
deptName?: string;
|
||||
|
||||
job?: string;
|
||||
jobName?: string;
|
||||
organization?: string;
|
||||
organizationName?: string;
|
||||
location?: string;
|
||||
locationName?: string;
|
||||
introduction?: string;
|
||||
|
@ -5,8 +5,8 @@
|
||||
<!-- 头部区域 -->
|
||||
<div class="header">
|
||||
<!-- 搜索栏 -->
|
||||
<div class="header-query">
|
||||
<a-form ref="queryRef" :model="queryParams" layout="inline" v-show="showQuery">
|
||||
<div class="header-query" v-if="showQuery">
|
||||
<a-form ref="queryRef" :model="queryParams" layout="inline">
|
||||
<a-form-item field="deptName" hide-label>
|
||||
<a-input
|
||||
v-model="queryParams.deptName"
|
||||
@ -190,6 +190,12 @@
|
||||
</a-skeleton>
|
||||
<span v-else>{{ dept.deptName }}</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="上级部门">
|
||||
<a-skeleton v-if="detailLoading" :animation="true">
|
||||
<a-skeleton-line :rows="1" />
|
||||
</a-skeleton>
|
||||
<span v-else>{{ dept.parentName || '无' }}</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="状态">
|
||||
<a-skeleton v-if="detailLoading" :animation="true">
|
||||
<a-skeleton-line :rows="1" />
|
||||
@ -199,6 +205,12 @@
|
||||
<a-tag v-else color="red"><span class="circle fail"></span>禁用</a-tag>
|
||||
</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="部门排序">
|
||||
<a-skeleton v-if="detailLoading" :animation="true">
|
||||
<a-skeleton-line :rows="1" />
|
||||
</a-skeleton>
|
||||
<span v-else>{{ dept.deptSort }}</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="创建人">
|
||||
<a-skeleton v-if="detailLoading" :animation="true">
|
||||
<a-skeleton-line :rows="1" />
|
||||
@ -262,6 +274,7 @@
|
||||
createTime: '',
|
||||
updateUserString: '',
|
||||
updateTime: '',
|
||||
parentName: '',
|
||||
});
|
||||
const ids = ref<Array<number>>([]);
|
||||
const title = ref('');
|
||||
|
@ -46,6 +46,7 @@
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.phone')">{{ loginStore.phone }}</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.email')">{{ loginStore.email }}</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.deptName')">{{ loginStore.deptName }}</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.registrationDate')">{{ loginStore.registrationDate }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</a-space>
|
||||
|
@ -10,6 +10,7 @@ export default {
|
||||
'userCenter.panel.label.gender': 'Gender :',
|
||||
'userCenter.panel.label.phone': 'Phone :',
|
||||
'userCenter.panel.label.email': 'Email :',
|
||||
'userCenter.panel.label.deptName': 'Dept Name :',
|
||||
'userCenter.panel.label.registrationDate': 'Registration Date :',
|
||||
'userCenter.panel.male': 'male',
|
||||
'userCenter.panel.female': 'female',
|
||||
|
@ -10,6 +10,7 @@ export default {
|
||||
'userCenter.panel.label.gender': '性别 :',
|
||||
'userCenter.panel.label.phone': '手机号码 :',
|
||||
'userCenter.panel.label.email': '邮箱 :',
|
||||
'userCenter.panel.label.deptName': '所属部门 :',
|
||||
'userCenter.panel.label.registrationDate': '注册日期 :',
|
||||
'userCenter.panel.male': '男',
|
||||
'userCenter.panel.female': '女',
|
||||
|
@ -12,5 +12,5 @@ INSERT IGNORE INTO `sys_dept` VALUES (7, '研发一组', 3, 1, NULL, 1, 1, NOW()
|
||||
INSERT IGNORE INTO `sys_dept` VALUES (8, '研发二组', 3, 2, NULL, 2, 1, NOW(), 1, NOW());
|
||||
|
||||
-- 初始化默认用户:admin/admin123;test/123456
|
||||
INSERT IGNORE INTO `sys_user` VALUES (1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, '18888888888', 'charles7c@126.com', NULL, NULL, 1, NOW(), 1, NOW(), 1, NOW());
|
||||
INSERT IGNORE INTO `sys_user` VALUES (2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 0, NULL, NULL, NULL, NULL, 2, NOW(), 1, NOW(), 1, NOW());
|
||||
INSERT IGNORE INTO `sys_user` VALUES (1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, '18888888888', 'charles7c@126.com', NULL, NULL, 1, NOW(), 1, 1, NOW(), 1, NOW());
|
||||
INSERT IGNORE INTO `sys_user` VALUES (2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 0, NULL, NULL, NULL, NULL, 2, NOW(), 2, 1, NOW(), 1, NOW());
|
||||
|
@ -30,6 +30,7 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
|
||||
`description` varchar(512) DEFAULT NULL COMMENT '描述',
|
||||
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态(1启用 2禁用)',
|
||||
`pwd_reset_time` datetime DEFAULT NULL COMMENT '最后一次修改密码的时间',
|
||||
`dept_id` bigint(20) unsigned DEFAULT NULL COMMENT '部门ID',
|
||||
`create_user` bigint(20) unsigned NOT NULL COMMENT '创建人',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) unsigned NOT NULL COMMENT '修改人',
|
||||
@ -38,6 +39,7 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
|
||||
UNIQUE INDEX `uk_username`(`username`) USING BTREE,
|
||||
UNIQUE INDEX `uk_email`(`email`) USING BTREE,
|
||||
INDEX `idx_create_user`(`create_user`) USING BTREE,
|
||||
INDEX `idx_dept_id`(`dept_id`) USING BTREE,
|
||||
INDEX `idx_update_user`(`update_user`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user