diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java index fd33c48e..ac927b44 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java @@ -79,6 +79,16 @@ public class LoginUser implements Serializable { */ private LocalDateTime pwdResetTime; + /** + * 部门 ID + */ + private Long deptId; + + /** + * 部门名称 + */ + private String deptName; + /** * 创建时间 */ diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java index b748004d..e60b6412 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java @@ -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 用,写完角色体系后移除) */ diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java index a8f8b8de..adbd6922 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java @@ -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); // 返回令牌 diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java index 577273e7..7296cf58 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java @@ -94,4 +94,9 @@ public class UserDO extends BaseDO { * 最后一次修改密码的时间 */ private LocalDateTime pwdResetTime; + + /** + * 部门 ID + */ + private Long deptId; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java index 4425cb4e..cf6c44b8 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java index 00266e32..a1557aea 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java @@ -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 userService.getById(updateUser)).getNickname()); + detailVO.setUpdateUserString(ExceptionUtils.exToNull(() -> userService.getById(updateUser)).getNickname()); + detailVO.setParentName(ExceptionUtils.exToNull(() -> this.get(detailVO.getParentId()).getDeptName())); } } diff --git a/continew-admin-ui/src/api/monitor/log.ts b/continew-admin-ui/src/api/monitor/log.ts index 38cef1f3..b5db5cbe 100644 --- a/continew-admin-ui/src/api/monitor/log.ts +++ b/continew-admin-ui/src/api/monitor/log.ts @@ -65,7 +65,7 @@ export interface OperationLogParam extends Partial { page: number; size: number; sort: Array; - uid?: string; + uid?: number; } export interface OperationLogListRes { diff --git a/continew-admin-ui/src/api/system/dept.ts b/continew-admin-ui/src/api/system/dept.ts index d78c4b71..3ce6b252 100644 --- a/continew-admin-ui/src/api/system/dept.ts +++ b/continew-admin-ui/src/api/system/dept.ts @@ -14,7 +14,8 @@ export interface DeptRecord { createTime?: string; updateUserString?: string; updateTime?: string; - children?: Array, + children?: Array; + parentName?: string; } export interface DeptParam { diff --git a/continew-admin-ui/src/assets/style/global.less b/continew-admin-ui/src/assets/style/global.less index 9aa31a64..c26ff970 100644 --- a/continew-admin-ui/src/assets/style/global.less +++ b/continew-admin-ui/src/assets/style/global.less @@ -67,7 +67,7 @@ body { .header { margin-bottom: 16px; &-query { - margin-bottom: 8px; + margin-bottom: 10px; } &-operation { &-right { diff --git a/continew-admin-ui/src/store/modules/login/index.ts b/continew-admin-ui/src/store/modules/login/index.ts index a35c7bcf..5bf4c2f5 100644 --- a/continew-admin-ui/src/store/modules/login/index.ts +++ b/continew-admin-ui/src/store/modules/login/index.ts @@ -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: '低调星人', diff --git a/continew-admin-ui/src/store/modules/login/types.ts b/continew-admin-ui/src/store/modules/login/types.ts index 301e5635..1e3e3d63 100644 --- a/continew-admin-ui/src/store/modules/login/types.ts +++ b/continew-admin-ui/src/store/modules/login/types.ts @@ -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; diff --git a/continew-admin-ui/src/views/system/dept/index.vue b/continew-admin-ui/src/views/system/dept/index.vue index 07425e9e..8282dc3f 100644 --- a/continew-admin-ui/src/views/system/dept/index.vue +++ b/continew-admin-ui/src/views/system/dept/index.vue @@ -5,8 +5,8 @@
-
- +
+ {{ dept.deptName }} + + + + + {{ dept.parentName || '无' }} + @@ -199,6 +205,12 @@ 禁用 + + + + + {{ dept.deptSort }} + @@ -262,6 +274,7 @@ createTime: '', updateUserString: '', updateTime: '', + parentName: '', }); const ids = ref>([]); const title = ref(''); diff --git a/continew-admin-ui/src/views/system/user/center/components/user-panel.vue b/continew-admin-ui/src/views/system/user/center/components/user-panel.vue index f57aa4c1..6f6ab5f6 100644 --- a/continew-admin-ui/src/views/system/user/center/components/user-panel.vue +++ b/continew-admin-ui/src/views/system/user/center/components/user-panel.vue @@ -46,6 +46,7 @@ {{ loginStore.phone }} {{ loginStore.email }} + {{ loginStore.deptName }} {{ loginStore.registrationDate }} diff --git a/continew-admin-ui/src/views/system/user/center/locale/en-US.ts b/continew-admin-ui/src/views/system/user/center/locale/en-US.ts index 1f527949..ed674c00 100644 --- a/continew-admin-ui/src/views/system/user/center/locale/en-US.ts +++ b/continew-admin-ui/src/views/system/user/center/locale/en-US.ts @@ -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', diff --git a/continew-admin-ui/src/views/system/user/center/locale/zh-CN.ts b/continew-admin-ui/src/views/system/user/center/locale/zh-CN.ts index 06c95f1c..c5a7eedb 100644 --- a/continew-admin-ui/src/views/system/user/center/locale/zh-CN.ts +++ b/continew-admin-ui/src/views/system/user/center/locale/zh-CN.ts @@ -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': '女', diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_data.sql index fd22fdda..2c5c59d2 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_data.sql @@ -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()); diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_table.sql b/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_table.sql index 086b1974..cd1481dc 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_table.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/v0.0.1/continew-admin_table.sql @@ -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='用户表';