From a075adea36d772fcd3be04f8046a204bb23b6554 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 27 Nov 2024 15:25:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=8B=AC=E7=AB=8B=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 +- sql/wfc-user-platform/wfc-user-platform.sql | 504 ++++++++++++++++ wfc-modules/wfc-modules-user/pom.xml | 32 +- .../user/controller/UConfigController.java | 127 ++++ .../wfc/user/controller/UDeptController.java | 128 +++++ .../user/controller/UDictDataController.java | 116 ++++ .../user/controller/UDictTypeController.java | 126 ++++ .../controller/ULogininforController.java | 87 +++ .../wfc/user/controller/UMenuController.java | 153 +++++ .../user/controller/UOperlogController.java | 73 +++ .../wfc/user/controller/UPostController.java | 124 ++++ .../user/controller/UProfileController.java | 153 +++++ .../wfc/user/controller/URoleController.java | 233 ++++++++ .../wfc/user/controller/UUserController.java | 360 ++++++++++-- .../controller/UUserOnlineController.java | 80 +++ .../java/org/wfc/user/domain/UConfig.java | 112 ++++ .../main/java/org/wfc/user/domain/UMenu.java | 287 +++++++++ .../main/java/org/wfc/user/domain/UPost.java | 125 ++++ .../java/org/wfc/user/domain/URoleDept.java | 46 ++ .../java/org/wfc/user/domain/URoleMenu.java | 46 ++ .../main/java/org/wfc/user/domain/UUser.java | 212 ------- .../java/org/wfc/user/domain/UUserOnline.java | 100 ++++ .../java/org/wfc/user/domain/UUserPost.java | 46 ++ .../java/org/wfc/user/domain/UUserRole.java | 46 ++ .../java/org/wfc/user/domain/vo/MetaVo.java | 106 ++++ .../java/org/wfc/user/domain/vo/RouterVo.java | 150 +++++ .../org/wfc/user/domain/vo/TreeSelect.java | 78 +++ .../org/wfc/user/mapper/UConfigMapper.java | 77 +++ .../java/org/wfc/user/mapper/UDeptMapper.java | 119 ++++ .../org/wfc/user/mapper/UDictDataMapper.java | 96 ++++ .../org/wfc/user/mapper/UDictTypeMapper.java | 84 +++ .../wfc/user/mapper/ULogininforMapper.java | 43 ++ .../java/org/wfc/user/mapper/UMenuMapper.java | 126 ++++ .../org/wfc/user/mapper/UOperLogMapper.java | 49 ++ .../java/org/wfc/user/mapper/UPostMapper.java | 100 ++++ .../org/wfc/user/mapper/URoleDeptMapper.java | 45 ++ .../java/org/wfc/user/mapper/URoleMapper.java | 108 ++++ .../org/wfc/user/mapper/URoleMenuMapper.java | 45 ++ .../java/org/wfc/user/mapper/UUserMapper.java | 127 +++- .../org/wfc/user/mapper/UUserPostMapper.java | 45 ++ .../org/wfc/user/mapper/UUserRoleMapper.java | 63 ++ .../org/wfc/user/service/IUConfigService.java | 83 +++ .../org/wfc/user/service/IUDeptService.java | 125 ++++ .../wfc/user/service/IUDictDataService.java | 61 ++ .../wfc/user/service/IUDictTypeService.java | 99 ++++ .../wfc/user/service/IULogininforService.java | 41 ++ .../org/wfc/user/service/IUMenuService.java | 145 +++++ .../wfc/user/service/IUOperLogService.java | 50 ++ .../wfc/user/service/IUPermissionService.java | 29 + .../org/wfc/user/service/IUPostService.java | 100 ++++ .../org/wfc/user/service/IURoleService.java | 176 ++++++ .../wfc/user/service/IUUserOnlineService.java | 48 ++ .../org/wfc/user/service/IUUserService.java | 204 ++++++- .../wfc/user/service/UUserServiceImpl.java | 96 ---- .../user/service/impl/UConfigServiceImpl.java | 214 +++++++ .../user/service/impl/UDeptServiceImpl.java | 337 +++++++++++ .../service/impl/UDictDataServiceImpl.java | 112 ++++ .../service/impl/UDictTypeServiceImpl.java | 224 ++++++++ .../service/impl/ULogininforServiceImpl.java | 66 +++ .../user/service/impl/UMenuServiceImpl.java | 516 +++++++++++++++++ .../service/impl/UOperLogServiceImpl.java | 78 +++ .../service/impl/UPermissionServiceImpl.java | 92 +++ .../user/service/impl/UPostServiceImpl.java | 179 ++++++ .../user/service/impl/URoleServiceImpl.java | 422 ++++++++++++++ .../service/impl/UUserOnlineServiceImpl.java | 89 +++ .../user/service/impl/UUserServiceImpl.java | 544 ++++++++++++++++++ .../src/main/resources/application.yml | 52 +- .../resources/mapper/user/UConfigMapper.xml | 117 ++++ .../resources/mapper/user/UDeptMapper.xml | 161 ++++++ .../resources/mapper/user/UDictDataMapper.xml | 124 ++++ .../resources/mapper/user/UDictTypeMapper.xml | 105 ++++ .../mapper/user/ULogininforMapper.xml | 54 ++ .../resources/mapper/user/UMenuMapper.xml | 211 +++++++ .../resources/mapper/user/UOperLogMapper.xml | 86 +++ .../resources/mapper/user/UPostMapper.xml | 122 ++++ .../resources/mapper/user/URoleDeptMapper.xml | 34 ++ .../resources/mapper/user/URoleMapper.xml | 152 +++++ .../resources/mapper/user/URoleMenuMapper.xml | 34 ++ .../resources/mapper/user/UUserMapper.xml | 335 +++++++---- .../resources/mapper/user/UUserPostMapper.xml | 34 ++ .../resources/mapper/user/UUserRoleMapper.xml | 44 ++ 81 files changed, 10017 insertions(+), 563 deletions(-) create mode 100644 sql/wfc-user-platform/wfc-user-platform.sql create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UConfigController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDeptController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictDataController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictTypeController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/ULogininforController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UMenuController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOperlogController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UPostController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UProfileController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/URoleController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserOnlineController.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UConfig.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UMenu.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UPost.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleDept.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleMenu.java delete mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUser.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserOnline.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserPost.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserRole.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/MetaVo.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/RouterVo.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/TreeSelect.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UConfigMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDeptMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictDataMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictTypeMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/ULogininforMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UMenuMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UOperLogMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UPostMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleDeptMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMenuMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserPostMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserRoleMapper.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUConfigService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDeptService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictDataService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictTypeService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IULogininforService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUMenuService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUOperLogService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPermissionService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPostService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IURoleService.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserOnlineService.java delete mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/UUserServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UConfigServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDeptServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictDataServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictTypeServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/ULogininforServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UMenuServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOperLogServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPermissionServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPostServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/URoleServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserOnlineServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserServiceImpl.java create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UConfigMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDeptMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictDataMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictTypeMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/ULogininforMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UMenuMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UOperLogMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UPostMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleDeptMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMenuMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserPostMapper.xml create mode 100644 wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserRoleMapper.xml diff --git a/pom.xml b/pom.xml index 66d8166..6220e58 100644 --- a/pom.xml +++ b/pom.xml @@ -276,6 +276,13 @@ ${wfc.version} + + + org.wfc + wfc-api-user + ${wfc.version} + + org.wfc @@ -289,7 +296,6 @@ javax.mail ${mail.version} - diff --git a/sql/wfc-user-platform/wfc-user-platform.sql b/sql/wfc-user-platform/wfc-user-platform.sql new file mode 100644 index 0000000..6255a80 --- /dev/null +++ b/sql/wfc-user-platform/wfc-user-platform.sql @@ -0,0 +1,504 @@ +/* + Navicat Premium Data Transfer + Source Server Type : MySQL + Source Server Version : 80039 (8.0.39) + Source Schema : wfc-user-platform + Date: 27/11/2024 10:17:56 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for u_config +-- ---------------------------- +DROP TABLE IF EXISTS `u_config`; +CREATE TABLE `u_config` ( + `config_id` int NOT NULL AUTO_INCREMENT COMMENT '参数主键', + `config_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数名称', + `config_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数键名', + `config_value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数键值', + `config_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'N' COMMENT '系统内置(Y是 N否)', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`config_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_参数配置表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_config +-- ---------------------------- +INSERT INTO `u_config` VALUES (1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', '2024-05-08 21:50:55', '', NULL, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow'); +INSERT INTO `u_config` VALUES (2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', '2024-05-08 21:50:55', '', NULL, '初始化密码 123456'); +INSERT INTO `u_config` VALUES (3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', '2024-05-08 21:50:55', '', NULL, '深色主题theme-dark,浅色主题theme-light'); +INSERT INTO `u_config` VALUES (4, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 'admin', '2024-05-08 21:50:55', '', NULL, '是否开启注册用户功能(true开启,false关闭)'); +INSERT INTO `u_config` VALUES (5, '用户登录-黑名单列表', 'sys.login.blackIPList', '', 'Y', 'admin', '2024-05-08 21:50:55', '', NULL, '设置登录IP黑名单限制,多个匹配项以;分隔,支持匹配(*通配、网段)'); + +-- ---------------------------- +-- Table structure for u_dept +-- ---------------------------- +DROP TABLE IF EXISTS `u_dept`; +CREATE TABLE `u_dept` ( + `dept_id` bigint NOT NULL AUTO_INCREMENT COMMENT '部门id', + `parent_id` bigint NULL DEFAULT 0 COMMENT '父部门id', + `ancestors` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '祖级列表', + `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部门名称', + `order_num` int NULL DEFAULT 0 COMMENT '显示顺序', + `leader` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '负责人', + `phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系电话', + `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '部门状态(0正常 1停用)', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`dept_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 202 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_部门表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_dept +-- ---------------------------- +INSERT INTO `u_dept` VALUES (100, 0, '0', '若依科技', 0, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (101, 100, '0,100', '深圳总公司', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (102, 100, '0,100', '长沙分公司', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (103, 101, '0,100,101', '研发部门', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (104, 101, '0,100,101', '市场部门', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (105, 101, '0,100,101', '测试部门', 3, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (106, 101, '0,100,101', '财务部门', 4, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (107, 101, '0,100,101', '运维部门', 5, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (108, 102, '0,100,102', '市场部门', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (109, 102, '0,100,102', '财务部门', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, NULL); +INSERT INTO `u_dept` VALUES (200, 100, '0,100', '嵌入式部门', 1, '小美', '19939926438', '19939926438@163.com', '1', '0', 'ryadmin', '2024-06-02 16:16:37', 'admin', '2024-06-02 17:24:11', 'ttt'); +INSERT INTO `u_dept` VALUES (201, 100, '0,100', '后端部门', 3, '小黑', '19939926438', NULL, '0', '2', 'admin', '2024-06-02 16:52:12', '', NULL, '测试111'); + +-- ---------------------------- +-- Table structure for u_dict_data +-- ---------------------------- +DROP TABLE IF EXISTS `u_dict_data`; +CREATE TABLE `u_dict_data` ( + `dict_code` bigint NOT NULL AUTO_INCREMENT COMMENT '字典编码', + `dict_sort` int NULL DEFAULT 0 COMMENT '字典排序', + `dict_label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典标签', + `dict_value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典键值', + `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型', + `css_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '样式属性(其他样式扩展)', + `list_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '表格回显样式', + `is_default` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'N' COMMENT '是否默认(Y是 N否)', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '状态(0正常 1停用)', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`dict_code`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_字典数据表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_dict_data +-- ---------------------------- +INSERT INTO `u_dict_data` VALUES (1, 1, '男', '0', 'u_user_sex', '', '', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '性别男'); +INSERT INTO `u_dict_data` VALUES (2, 2, '女', '1', 'u_user_sex', '', '', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '性别女'); +INSERT INTO `u_dict_data` VALUES (3, 3, '未知', '2', 'u_user_sex', '', '', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '性别未知'); +INSERT INTO `u_dict_data` VALUES (4, 1, '显示', '0', 'u_show_hide', '', 'primary', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '显示菜单'); +INSERT INTO `u_dict_data` VALUES (5, 2, '隐藏', '1', 'u_show_hide', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '隐藏菜单'); +INSERT INTO `u_dict_data` VALUES (6, 1, '正常', '0', 'u_normal_disable', '', 'primary', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '正常状态'); +INSERT INTO `u_dict_data` VALUES (7, 2, '停用', '1', 'u_normal_disable', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '停用状态'); +INSERT INTO `u_dict_data` VALUES (8, 1, '正常', '0', 'u_job_status', '', 'primary', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '正常状态'); +INSERT INTO `u_dict_data` VALUES (9, 2, '暂停', '1', 'u_job_status', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '停用状态'); +INSERT INTO `u_dict_data` VALUES (10, 1, '默认', 'DEFAULT', 'u_job_group', '', '', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '默认分组'); +INSERT INTO `u_dict_data` VALUES (11, 2, '系统', 'SYSTEM', 'u_job_group', '', '', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '系统分组'); +INSERT INTO `u_dict_data` VALUES (12, 1, '是', 'Y', 'u_yes_no', '', 'primary', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '系统默认是'); +INSERT INTO `u_dict_data` VALUES (13, 2, '否', 'N', 'u_yes_no', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '系统默认否'); +INSERT INTO `u_dict_data` VALUES (14, 1, '通知', '1', 'u_notice_type', '', 'warning', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '通知'); +INSERT INTO `u_dict_data` VALUES (15, 2, '公告', '2', 'u_notice_type', '', 'success', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '公告'); +INSERT INTO `u_dict_data` VALUES (16, 1, '正常', '0', 'u_notice_status', '', 'primary', 'Y', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '正常状态'); +INSERT INTO `u_dict_data` VALUES (17, 2, '关闭', '1', 'u_notice_status', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '关闭状态'); +INSERT INTO `u_dict_data` VALUES (18, 99, '其他', '0', 'u_oper_type', '', 'info', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '其他操作'); +INSERT INTO `u_dict_data` VALUES (19, 1, '新增', '1', 'u_oper_type', '', 'info', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '新增操作'); +INSERT INTO `u_dict_data` VALUES (20, 2, '修改', '2', 'u_oper_type', '', 'info', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '修改操作'); +INSERT INTO `u_dict_data` VALUES (21, 3, '删除', '3', 'u_oper_type', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '删除操作'); +INSERT INTO `u_dict_data` VALUES (22, 4, '授权', '4', 'u_oper_type', '', 'primary', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '授权操作'); +INSERT INTO `u_dict_data` VALUES (23, 5, '导出', '5', 'u_oper_type', '', 'warning', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '导出操作'); +INSERT INTO `u_dict_data` VALUES (24, 6, '导入', '6', 'u_oper_type', '', 'warning', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '导入操作'); +INSERT INTO `u_dict_data` VALUES (25, 7, '强退', '7', 'u_oper_type', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '强退操作'); +INSERT INTO `u_dict_data` VALUES (26, 8, '生成代码', '8', 'u_oper_type', '', 'warning', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '生成操作'); +INSERT INTO `u_dict_data` VALUES (27, 9, '清空数据', '9', 'u_oper_type', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '清空操作'); +INSERT INTO `u_dict_data` VALUES (28, 1, '成功', '0', 'u_common_status', '', 'primary', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '正常状态'); +INSERT INTO `u_dict_data` VALUES (29, 2, '失败', '1', 'u_common_status', '', 'danger', 'N', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '停用状态'); + +-- ---------------------------- +-- Table structure for u_dict_type +-- ---------------------------- +DROP TABLE IF EXISTS `u_dict_type`; +CREATE TABLE `u_dict_type` ( + `dict_id` bigint NOT NULL AUTO_INCREMENT COMMENT '字典主键', + `dict_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典名称', + `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '状态(0正常 1停用)', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`dict_id`) USING BTREE, + UNIQUE INDEX `dict_type`(`dict_type` ASC) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 101 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_字典类型表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_dict_type +-- ---------------------------- +INSERT INTO `u_dict_type` VALUES (1, '用户性别', 'u_user_sex', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '用户性别列表'); +INSERT INTO `u_dict_type` VALUES (2, '菜单状态', 'u_show_hide', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '菜单状态列表'); +INSERT INTO `u_dict_type` VALUES (3, '系统开关', 'u_normal_disable', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '系统开关列表'); +INSERT INTO `u_dict_type` VALUES (4, '任务状态', 'u_job_status', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '任务状态列表'); +INSERT INTO `u_dict_type` VALUES (5, '任务分组', 'u_job_group', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '任务分组列表'); +INSERT INTO `u_dict_type` VALUES (6, '系统是否', 'u_yes_no', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '系统是否列表'); +INSERT INTO `u_dict_type` VALUES (7, '通知类型', 'u_notice_type', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '通知类型列表'); +INSERT INTO `u_dict_type` VALUES (8, '通知状态', 'u_notice_status', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '通知状态列表'); +INSERT INTO `u_dict_type` VALUES (9, '操作类型', 'u_oper_type', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '操作类型列表'); +INSERT INTO `u_dict_type` VALUES (10, '系统状态', 'u_common_status', '0', 'admin', '2024-05-08 21:50:55', '', NULL, '登录状态列表'); +INSERT INTO `u_dict_type` VALUES (100, '测试字典', 'u_test_type', '0', 'admin', '2024-06-09 22:46:22', '', NULL, 'dsadasd'); + +-- ---------------------------- +-- Table structure for u_logininfor +-- ---------------------------- +DROP TABLE IF EXISTS `u_logininfor`; +CREATE TABLE `u_logininfor` ( + `info_id` bigint NOT NULL AUTO_INCREMENT COMMENT '访问ID', + `user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户账号', + `ipaddr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录IP地址', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '登录状态(0成功 1失败)', + `msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '提示信息', + `access_time` datetime NULL DEFAULT NULL COMMENT '访问时间', + PRIMARY KEY (`info_id`) USING BTREE, + INDEX `idx_u_logininfor_s`(`status` ASC) USING BTREE, + INDEX `idx_u_logininfor_lt`(`access_time` ASC) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 209 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_系统访问记录' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_logininfor +-- ---------------------------- +INSERT INTO `u_logininfor` VALUES (100, 'admin', '127.0.0.1', '0', '登录成功', '2024-05-09 22:23:21'); +INSERT INTO `u_logininfor` VALUES (101, 'admin', '127.0.0.1', '0', '登录成功', '2024-05-10 20:06:29'); + +-- ---------------------------- +-- Table structure for u_menu +-- ---------------------------- +DROP TABLE IF EXISTS `u_menu`; +CREATE TABLE `u_menu` ( + `menu_id` bigint NOT NULL AUTO_INCREMENT COMMENT '菜单ID', + `menu_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单名称', + `parent_id` bigint NULL DEFAULT 0 COMMENT '父菜单ID', + `order_num` int NULL DEFAULT 0 COMMENT '显示顺序', + `path` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '路由地址', + `component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件路径', + `query` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '路由参数', + `is_frame` int NULL DEFAULT 1 COMMENT '是否为外链(0是 1否)', + `is_cache` int NULL DEFAULT 0 COMMENT '是否缓存(0缓存 1不缓存)', + `menu_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '菜单类型(M目录 C菜单 F按钮)', + `visible` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '菜单状态(0显示 1隐藏)', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '菜单状态(0正常 1停用)', + `perms` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限标识', + `icon` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '#' COMMENT '菜单图标', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注', + `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单key', + PRIMARY KEY (`menu_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2010 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_菜单权限表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_menu +-- ---------------------------- +INSERT INTO `u_menu` VALUES (1, '系统管理', 0, 1, '/manage', 'layout.base', '', 1, 0, 'M', '0', '0', '', 'carbon:cloud-service-management', 'admin', '2024-05-08 21:50:55', 'admin', '2024-05-12 23:46:57', '系统管理目录', 'manage'); +INSERT INTO `u_menu` VALUES (100, '用户管理', 1, 1, '/manage/user', 'view.manage_user', '', 1, 0, 'C', '0', '0', 'system:user:list', 'ic:round-manage-accounts', 'admin', '2024-05-08 21:50:55', 'admin', '2024-05-12 23:50:31', '用户管理菜单', 'manage_user'); +INSERT INTO `u_menu` VALUES (101, '角色管理', 1, 2, '/manage/role', 'view.manage_role', '', 1, 0, 'C', '0', '0', 'system:role:list', 'carbon:user-role', 'admin', '2024-05-08 21:50:55', '', NULL, '角色管理菜单', 'manage_role'); +INSERT INTO `u_menu` VALUES (102, '菜单管理', 1, 3, '/manage/menu', 'view.manage_menu', '', 1, 0, 'C', '0', '0', 'system:menu:list', 'material-symbols:route', 'admin', '2024-05-08 21:50:55', 'admin', '2024-05-12 23:46:12', '菜单管理菜单', 'manage_menu'); +INSERT INTO `u_menu` VALUES (103, '部门管理', 1, 4, '/manage/dept', 'view.manage_dept', '', 1, 0, 'C', '0', '0', 'system:dept:list', 'carbon:box', 'admin', '2024-05-08 21:50:55', 'ryadmin', '2024-05-30 23:17:41', '部门管理菜单', 'manage_dept'); +INSERT INTO `u_menu` VALUES (104, '岗位管理', 1, 5, '/manage/post', 'view.manage_post', NULL, 1, 0, 'C', '0', '0', 'system:post:list', 'carbon:group', 'admin', '2024-06-02 22:18:48', '', NULL, '', 'manage_post'); +INSERT INTO `u_menu` VALUES (105, '字典管理', 1, 6, '/manage/dict', 'view.manage_dict', NULL, 1, 0, 'C', '0', '0', 'system:dict:list', 'carbon:volume-block-storage', 'admin', '2024-06-02 23:13:40', '', NULL, '', 'manage_dict'); +INSERT INTO `u_menu` VALUES (1000, '用户查询', 100, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:user:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1001, '用户新增', 100, 2, '', '', '', 1, 0, 'F', '0', '0', 'system:user:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1002, '用户修改', 100, 3, '', '', '', 1, 0, 'F', '0', '0', 'system:user:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1003, '用户删除', 100, 4, '', '', '', 1, 0, 'F', '0', '0', 'system:user:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1004, '用户导出', 100, 5, '', '', '', 1, 0, 'F', '0', '0', 'system:user:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1005, '用户导入', 100, 6, '', '', '', 1, 0, 'F', '0', '0', 'system:user:import', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1006, '重置密码', 100, 7, '', '', '', 1, 0, 'F', '0', '0', 'system:user:resetPwd', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1007, '角色查询', 101, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:role:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1008, '角色新增', 101, 2, '', '', '', 1, 0, 'F', '0', '0', 'system:role:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1009, '角色修改', 101, 3, '', '', '', 1, 0, 'F', '0', '0', 'system:role:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1010, '角色删除', 101, 4, '', '', '', 1, 0, 'F', '0', '0', 'system:role:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1011, '角色导出', 101, 5, '', '', '', 1, 0, 'F', '0', '0', 'system:role:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1012, '菜单查询', 102, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:menu:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1013, '菜单新增', 102, 2, '', '', '', 1, 0, 'F', '0', '0', 'system:menu:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1014, '菜单修改', 102, 3, '', '', '', 1, 0, 'F', '0', '0', 'system:menu:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1015, '菜单删除', 102, 4, '', '', '', 1, 0, 'F', '0', '0', 'system:menu:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1016, '部门查询', 103, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:dept:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1017, '部门新增', 103, 2, '', '', '', 1, 0, 'F', '0', '0', 'system:dept:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1018, '部门修改', 103, 3, '', '', '', 1, 0, 'F', '0', '0', 'system:dept:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1019, '部门删除', 103, 4, '', '', '', 1, 0, 'F', '0', '0', 'system:dept:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1020, '岗位查询', 104, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:post:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1021, '岗位新增', 104, 2, '', '', '', 1, 0, 'F', '0', '0', 'system:post:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1022, '岗位修改', 104, 3, '', '', '', 1, 0, 'F', '0', '0', 'system:post:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1023, '岗位删除', 104, 4, '', '', '', 1, 0, 'F', '0', '0', 'system:post:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1024, '岗位导出', 104, 5, '', '', '', 1, 0, 'F', '0', '0', 'system:post:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1025, '字典查询', 105, 1, '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1026, '字典新增', 105, 2, '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1027, '字典修改', 105, 3, '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1028, '字典删除', 105, 4, '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1029, '字典导出', 105, 5, '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1030, '参数查询', 106, 1, '#', '', '', 1, 0, 'F', '0', '0', 'system:config:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1031, '参数新增', 106, 2, '#', '', '', 1, 0, 'F', '0', '0', 'system:config:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1032, '参数修改', 106, 3, '#', '', '', 1, 0, 'F', '0', '0', 'system:config:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1033, '参数删除', 106, 4, '#', '', '', 1, 0, 'F', '0', '0', 'system:config:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1034, '参数导出', 106, 5, '#', '', '', 1, 0, 'F', '0', '0', 'system:config:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1035, '公告查询', 107, 1, '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1036, '公告新增', 107, 2, '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1037, '公告修改', 107, 3, '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1038, '公告删除', 107, 4, '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1039, '操作查询', 500, 1, '#', '', '', 1, 0, 'F', '0', '0', 'system:operlog:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1040, '操作删除', 500, 2, '#', '', '', 1, 0, 'F', '0', '0', 'system:operlog:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1041, '日志导出', 500, 3, '#', '', '', 1, 0, 'F', '0', '0', 'system:operlog:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1042, '登录查询', 501, 1, '#', '', '', 1, 0, 'F', '0', '0', 'system:logininfor:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1043, '登录删除', 501, 2, '#', '', '', 1, 0, 'F', '0', '0', 'system:logininfor:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1044, '日志导出', 501, 3, '#', '', '', 1, 0, 'F', '0', '0', 'system:logininfor:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1045, '账户解锁', 501, 4, '#', '', '', 1, 0, 'F', '0', '0', 'system:logininfor:unlock', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1046, '在线查询', 109, 1, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1047, '批量强退', 109, 2, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:batchLogout', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1048, '单条强退', 109, 3, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:forceLogout', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1049, '任务查询', 110, 1, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1050, '任务新增', 110, 2, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1051, '任务修改', 110, 3, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1052, '任务删除', 110, 4, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1053, '状态修改', 110, 5, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:changeStatus', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1054, '任务导出', 110, 6, '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:export', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1055, '生成查询', 115, 1, '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:query', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1056, '生成修改', 115, 2, '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1057, '生成删除', 115, 3, '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:remove', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1058, '导入代码', 115, 2, '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:import', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1059, '预览代码', 115, 4, '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:preview', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); +INSERT INTO `u_menu` VALUES (1060, '生成代码', 115, 5, '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:code', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL); + +-- ---------------------------- +-- Table structure for u_oper_log +-- ---------------------------- +DROP TABLE IF EXISTS `u_oper_log`; +CREATE TABLE `u_oper_log` ( + `oper_id` bigint NOT NULL AUTO_INCREMENT COMMENT '日志主键', + `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模块标题', + `business_type` int NULL DEFAULT 0 COMMENT '业务类型(0其它 1新增 2修改 3删除)', + `method` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '方法名称', + `request_method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求方式', + `operator_type` int NULL DEFAULT 0 COMMENT '操作类别(0其它 1后台用户 2手机端用户)', + `oper_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作人员', + `dept_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部门名称', + `oper_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求URL', + `oper_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机地址', + `oper_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作地点', + `oper_param` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求参数', + `json_result` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '返回参数', + `status` int NULL DEFAULT 0 COMMENT '操作状态(0正常 1异常)', + `error_msg` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '错误消息', + `oper_time` datetime NULL DEFAULT NULL COMMENT '操作时间', + `cost_time` bigint NULL DEFAULT 0 COMMENT '消耗时间', + PRIMARY KEY (`oper_id`) USING BTREE, + INDEX `idx_u_oper_log_bt`(`business_type` ASC) USING BTREE, + INDEX `idx_u_oper_log_s`(`status` ASC) USING BTREE, + INDEX `idx_u_oper_log_ot`(`oper_time` ASC) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_操作日志记录' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Table structure for u_post +-- ---------------------------- +DROP TABLE IF EXISTS `u_post`; +CREATE TABLE `u_post` ( + `post_id` bigint NOT NULL AUTO_INCREMENT COMMENT '岗位ID', + `post_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位编码', + `post_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位名称', + `post_sort` int NOT NULL COMMENT '显示顺序', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态(0正常 1停用)', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`post_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_岗位信息表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_post +-- ---------------------------- +INSERT INTO `u_post` VALUES (1, 'ceo', '董事长', 1, '0', 'admin', '2024-05-08 21:50:54', '', NULL, ''); +INSERT INTO `u_post` VALUES (2, 'se', '项目经理', 2, '0', 'admin', '2024-05-08 21:50:54', '', NULL, ''); +INSERT INTO `u_post` VALUES (3, 'hr', '人力资源', 3, '0', 'admin', '2024-05-08 21:50:54', '', NULL, ''); +INSERT INTO `u_post` VALUES (4, 'user', '普通员工', 4, '0', 'admin', '2024-05-08 21:50:54', 'ryadmin', '2024-06-10 11:45:33', '反反复复'); + +-- ---------------------------- +-- Table structure for u_role +-- ---------------------------- +DROP TABLE IF EXISTS `u_role`; +CREATE TABLE `u_role` ( + `role_id` bigint NOT NULL AUTO_INCREMENT COMMENT '角色ID', + `role_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色名称', + `role_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色权限字符串', + `role_sort` int(4) not null comment '显示顺序', + `data_scope` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)', + `menu_check_strictly` tinyint(1) NULL DEFAULT 1 COMMENT '菜单树选择项是否关联显示', + `dept_check_strictly` tinyint(1) NULL DEFAULT 1 COMMENT '部门树选择项是否关联显示', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色状态(0正常 1停用)', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`role_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 106 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_角色信息表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_role +-- ---------------------------- +INSERT INTO `u_role` VALUES (1, '超级管理员', 'admin', '1', 1, 1, '0', '0', 'admin', '2024-05-08 21:50:54', '', NULL, '超级管理员'); +INSERT INTO `u_role` VALUES (2, '普通刺客', 'common', '2', 1, 1, '0', '0', 'admin', '2024-05-08 21:50:54', 'admin', '2024-06-02 23:14:56', '普通角色'); + +-- ---------------------------- +-- Table structure for u_role_dept +-- ---------------------------- +DROP TABLE IF EXISTS `u_role_dept`; +CREATE TABLE `u_role_dept` ( + `role_id` bigint NOT NULL COMMENT '角色ID', + `dept_id` bigint NOT NULL COMMENT '部门ID', + PRIMARY KEY (`role_id`, `dept_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_角色和部门关联表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_role_dept +-- ---------------------------- +INSERT INTO `u_role_dept` VALUES (2, 100); +INSERT INTO `u_role_dept` VALUES (2, 101); +INSERT INTO `u_role_dept` VALUES (2, 105); + +-- ---------------------------- +-- Table structure for u_role_menu +-- ---------------------------- +DROP TABLE IF EXISTS `u_role_menu`; +CREATE TABLE `u_role_menu` ( + `role_id` bigint NOT NULL COMMENT '角色ID', + `menu_id` bigint NOT NULL COMMENT '菜单ID', + PRIMARY KEY (`role_id`, `menu_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_角色和菜单关联表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_role_menu +-- ---------------------------- +INSERT INTO `u_role_menu` VALUES (2, 1); +INSERT INTO `u_role_menu` VALUES (2, 100); +INSERT INTO `u_role_menu` VALUES (2, 101); +INSERT INTO `u_role_menu` VALUES (2, 102); +INSERT INTO `u_role_menu` VALUES (2, 103); +INSERT INTO `u_role_menu` VALUES (2, 104); +INSERT INTO `u_role_menu` VALUES (2, 105); +INSERT INTO `u_role_menu` VALUES (2, 1000); +INSERT INTO `u_role_menu` VALUES (2, 1001); +INSERT INTO `u_role_menu` VALUES (2, 1002); +INSERT INTO `u_role_menu` VALUES (2, 1003); +INSERT INTO `u_role_menu` VALUES (2, 1004); +INSERT INTO `u_role_menu` VALUES (2, 1005); +INSERT INTO `u_role_menu` VALUES (2, 1006); +INSERT INTO `u_role_menu` VALUES (2, 1007); +INSERT INTO `u_role_menu` VALUES (2, 1008); +INSERT INTO `u_role_menu` VALUES (2, 1009); +INSERT INTO `u_role_menu` VALUES (2, 1010); +INSERT INTO `u_role_menu` VALUES (2, 1012); +INSERT INTO `u_role_menu` VALUES (2, 1013); +INSERT INTO `u_role_menu` VALUES (2, 1014); +INSERT INTO `u_role_menu` VALUES (2, 1015); +INSERT INTO `u_role_menu` VALUES (2, 1016); +INSERT INTO `u_role_menu` VALUES (2, 1017); +INSERT INTO `u_role_menu` VALUES (2, 1018); +INSERT INTO `u_role_menu` VALUES (2, 1019); +INSERT INTO `u_role_menu` VALUES (2, 1020); +INSERT INTO `u_role_menu` VALUES (2, 1021); +INSERT INTO `u_role_menu` VALUES (2, 1022); +INSERT INTO `u_role_menu` VALUES (2, 1023); +INSERT INTO `u_role_menu` VALUES (2, 1024); +INSERT INTO `u_role_menu` VALUES (2, 1025); +INSERT INTO `u_role_menu` VALUES (2, 1026); +INSERT INTO `u_role_menu` VALUES (2, 1027); +INSERT INTO `u_role_menu` VALUES (2, 1028); +INSERT INTO `u_role_menu` VALUES (2, 1029); + +-- ---------------------------- +-- Table structure for u_user +-- ---------------------------- +DROP TABLE IF EXISTS `u_user`; +CREATE TABLE `u_user` ( + `user_id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID', + `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID', + `user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户账号', + `nick_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户昵称', + `user_type` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '00' COMMENT '用户类型(00系统用户)', + `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户邮箱', + `phonenumber` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '手机号码', + `sex` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '用户性别(0男 1女 2未知)', + `avatar` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '头像地址', + `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '密码', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '帐号状态(0正常 1停用)', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `login_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '最后登录IP', + `login_date` datetime NULL DEFAULT NULL COMMENT '最后登录时间', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`user_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 102 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_用户信息表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_user +-- ---------------------------- +INSERT INTO `u_user` VALUES (1, 103, 'admin', '若依', '00', 'ry@163.com', '15888888888', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', '2024-05-08 21:50:54', 'admin', '2024-05-08 21:50:54', '', NULL, '管理员'); +INSERT INTO `u_user` VALUES (2, 105, 'ryadmin', '若依', '00', 'ry@qq.com', '15666666666', '1', '', '$2a$10$1o.S9fySem5/jcIfpUosNOb.WiDgWu2sAZQRR3JVyL/Yj.FWveMt2', '0', '2', '127.0.0.1', '2024-05-08 21:50:54', 'admin', '2024-05-08 21:50:54', 'admin', '2024-05-12 23:50:57', '测试员'); + +-- ---------------------------- +-- Table structure for u_user_post +-- ---------------------------- +DROP TABLE IF EXISTS `u_user_post`; +CREATE TABLE `u_user_post` ( + `user_id` bigint NOT NULL COMMENT '用户ID', + `post_id` bigint NOT NULL COMMENT '岗位ID', + PRIMARY KEY (`user_id`, `post_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_用户与岗位关联表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_user_post +-- ---------------------------- +INSERT INTO `u_user_post` VALUES (1, 1); +INSERT INTO `u_user_post` VALUES (101, 2); +INSERT INTO `u_user_post` VALUES (101, 3); + +-- ---------------------------- +-- Table structure for u_user_role +-- ---------------------------- +DROP TABLE IF EXISTS `u_user_role`; +CREATE TABLE `u_user_role` ( + `user_id` bigint NOT NULL COMMENT '用户ID', + `role_id` bigint NOT NULL COMMENT '角色ID', + PRIMARY KEY (`user_id`, `role_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户平台_用户和角色关联表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of u_user_role +-- ---------------------------- +INSERT INTO `u_user_role` VALUES (1, 1); +INSERT INTO `u_user_role` VALUES (101, 2); +INSERT INTO `u_user_role` VALUES (101, 105); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/wfc-modules/wfc-modules-user/pom.xml b/wfc-modules/wfc-modules-user/pom.xml index 2c0593b..d898913 100644 --- a/wfc-modules/wfc-modules-user/pom.xml +++ b/wfc-modules/wfc-modules-user/pom.xml @@ -15,25 +15,25 @@ - - + + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery - + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config - + com.alibaba.cloud spring-cloud-starter-alibaba-sentinel - + org.springframework.boot @@ -45,19 +45,31 @@ com.mysql mysql-connector-j - - + + + + org.wfc + wfc-common-datasource + + + org.wfc wfc-common-log - - + + org.wfc wfc-common-swagger - + + + + org.wfc + wfc-api-user + + diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UConfigController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UConfigController.java new file mode 100644 index 0000000..e9cc12c --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UConfigController.java @@ -0,0 +1,127 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.utils.poi.ExcelUtil; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.domain.UConfig; +import org.wfc.user.service.IUConfigService; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author wfc + */ +@RestController +@RequestMapping("/config") +public class UConfigController extends BaseController +{ + @Autowired + private IUConfigService configService; + + /** + * 获取参数配置列表 + */ + @RequiresPermissions("Utem:config:list") + @GetMapping("/list") + public TableDataInfo list(UConfig config) + { + startPage(); + List list = configService.selectConfigList(config); + return getDataTable(list); + } + + @Log(title = "参数管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:config:export") + @PostMapping("/export") + public void export(HttpServletResponse response, UConfig config) + { + List list = configService.selectConfigList(config); + ExcelUtil util = new ExcelUtil(UConfig.class); + util.exportExcel(response, list, "参数数据"); + } + + /** + * 根据参数编号获取详细信息 + */ + @GetMapping(value = "/{configId}") + public AjaxResult getInfo(@PathVariable Long configId) + { + return success(configService.selectConfigById(configId)); + } + + /** + * 根据参数键名查询参数值 + */ + @GetMapping(value = "/configKey/{configKey}") + public AjaxResult getConfigKey(@PathVariable String configKey) + { + return success(configService.selectConfigByKey(configKey)); + } + + /** + * 新增参数配置 + */ + @RequiresPermissions("Utem:config:add") + @Log(title = "参数管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody UConfig config) + { + if (!configService.checkConfigKeyUnique(config)) + { + return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setCreateBy(SecurityUtils.getUsername()); + return toAjax(configService.insertConfig(config)); + } + + /** + * 修改参数配置 + */ + @RequiresPermissions("Utem:config:edit") + @Log(title = "参数管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody UConfig config) + { + if (!configService.checkConfigKeyUnique(config)) + { + return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(configService.updateConfig(config)); + } + + /** + * 删除参数配置 + */ + @RequiresPermissions("Utem:config:remove") + @Log(title = "参数管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{configIds}") + public AjaxResult remove(@PathVariable Long[] configIds) + { + configService.deleteConfigByIds(configIds); + return success(); + } + + /** + * 刷新参数缓存 + */ + @RequiresPermissions("Utem:config:remove") + @Log(title = "参数管理", businessType = BusinessType.CLEAN) + @DeleteMapping("/refreshCache") + public AjaxResult refreshCache() + { + configService.resetConfigCache(); + return success(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDeptController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDeptController.java new file mode 100644 index 0000000..1364fa3 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDeptController.java @@ -0,0 +1,128 @@ +package org.wfc.user.controller; + +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.UDept; +import org.wfc.user.service.IUDeptService; + +import java.util.List; + +/** + * 部门信息 + * + * @author wfc + */ +@RestController +@RequestMapping("/dept") +public class UDeptController extends BaseController +{ + @Autowired + private IUDeptService deptService; + + /** + * 获取部门列表 + */ + @RequiresPermissions("Utem:dept:list") + @GetMapping("/list") + public TableDataInfo list(UDept dept) + { + List depts = deptService.selectDeptList(dept); + return getDataTable(depts); + } + + /** + * 查询部门列表(排除节点) + */ + @RequiresPermissions("Utem:dept:list") + @GetMapping("/list/exclude/{deptId}") + public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) + { + List depts = deptService.selectDeptList(new UDept()); + depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); + return success(depts); + } + + /** + * 根据部门编号获取详细信息 + */ + @RequiresPermissions("Utem:dept:query") + @GetMapping(value = "/{deptId}") + public AjaxResult getInfo(@PathVariable Long deptId) + { + deptService.checkDeptDataScope(deptId); + return success(deptService.selectDeptById(deptId)); + } + + /** + * 新增部门 + */ + @RequiresPermissions("Utem:dept:add") + @Log(title = "部门管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody UDept dept) + { + if (!deptService.checkDeptNameUnique(dept)) + { + return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + dept.setCreateBy(SecurityUtils.getUsername()); + return toAjax(deptService.insertDept(dept)); + } + + /** + * 修改部门 + */ + @RequiresPermissions("Utem:dept:edit") + @Log(title = "部门管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody UDept dept) + { + Long deptId = dept.getDeptId(); + deptService.checkDeptDataScope(deptId); + if (!deptService.checkDeptNameUnique(dept)) + { + return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + else if (dept.getParentId().equals(deptId)) + { + return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); + } + else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) + { + return error("该部门包含未停用的子部门!"); + } + dept.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(deptService.updateDept(dept)); + } + + /** + * 删除部门 + */ + @RequiresPermissions("Utem:dept:remove") + @Log(title = "部门管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{deptId}") + public AjaxResult remove(@PathVariable Long deptId) + { + if (deptService.hasChildByDeptId(deptId)) + { + return warn("存在下级部门,不允许删除"); + } + if (deptService.checkDeptExistUser(deptId)) + { + return warn("部门存在用户,不允许删除"); + } + deptService.checkDeptDataScope(deptId); + return toAjax(deptService.deleteDeptById(deptId)); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictDataController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictDataController.java new file mode 100644 index 0000000..eeaeeb6 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictDataController.java @@ -0,0 +1,116 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.core.utils.poi.ExcelUtil; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.UDictData; +import org.wfc.user.service.IUDictDataService; +import org.wfc.user.service.IUDictTypeService; + +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +/** + * 数据字典信息 + * + * @author wfc + */ +@RestController +@RequestMapping("/dict/data") +public class UDictDataController extends BaseController +{ + @Autowired + private IUDictDataService dictDataService; + + @Autowired + private IUDictTypeService dictTypeService; + + @RequiresPermissions("Utem:dict:list") + @GetMapping("/list") + public TableDataInfo list(UDictData dictData) + { + startPage(); + List list = dictDataService.selectDictDataList(dictData); + return getDataTable(list); + } + + @Log(title = "字典数据", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:dict:export") + @PostMapping("/export") + public void export(HttpServletResponse response, UDictData dictData) + { + List list = dictDataService.selectDictDataList(dictData); + ExcelUtil util = new ExcelUtil(UDictData.class); + util.exportExcel(response, list, "字典数据"); + } + + /** + * 查询字典数据详细 + */ + @RequiresPermissions("Utem:dict:query") + @GetMapping(value = "/{dictCode}") + public AjaxResult getInfo(@PathVariable Long dictCode) + { + return success(dictDataService.selectDictDataById(dictCode)); + } + + /** + * 根据字典类型查询字典数据信息 + */ + @GetMapping(value = "/type/{dictType}") + public AjaxResult dictType(@PathVariable String dictType) + { + List data = dictTypeService.selectDictDataByType(dictType); + if (StringUtils.isNull(data)) + { + data = new ArrayList(); + } + return success(data); + } + + /** + * 新增字典类型 + */ + @RequiresPermissions("Utem:dict:add") + @Log(title = "字典数据", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody UDictData dict) + { + dict.setCreateBy(SecurityUtils.getUsername()); + return toAjax(dictDataService.insertDictData(dict)); + } + + /** + * 修改保存字典类型 + */ + @RequiresPermissions("Utem:dict:edit") + @Log(title = "字典数据", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody UDictData dict) + { + dict.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(dictDataService.updateDictData(dict)); + } + + /** + * 删除字典类型 + */ + @RequiresPermissions("Utem:dict:remove") + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictCodes}") + public AjaxResult remove(@PathVariable Long[] dictCodes) + { + dictDataService.deleteDictDataByIds(dictCodes); + return success(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictTypeController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictTypeController.java new file mode 100644 index 0000000..87a5580 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UDictTypeController.java @@ -0,0 +1,126 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.utils.poi.ExcelUtil; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.UDictType; +import org.wfc.user.service.IUDictTypeService; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 数据字典信息 + * + * @author wfc + */ +@RestController +@RequestMapping("/dict/type") +public class UDictTypeController extends BaseController +{ + @Autowired + private IUDictTypeService dictTypeService; + + @RequiresPermissions("Utem:dict:list") + @GetMapping("/list") + public TableDataInfo list(UDictType dictType) + { + startPage(); + List list = dictTypeService.selectDictTypeList(dictType); + return getDataTable(list); + } + + @Log(title = "字典类型", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:dict:export") + @PostMapping("/export") + public void export(HttpServletResponse response, UDictType dictType) + { + List list = dictTypeService.selectDictTypeList(dictType); + ExcelUtil util = new ExcelUtil(UDictType.class); + util.exportExcel(response, list, "字典类型"); + } + + /** + * 查询字典类型详细 + */ + @RequiresPermissions("Utem:dict:query") + @GetMapping(value = "/{dictId}") + public AjaxResult getInfo(@PathVariable Long dictId) + { + return success(dictTypeService.selectDictTypeById(dictId)); + } + + /** + * 新增字典类型 + */ + @RequiresPermissions("Utem:dict:add") + @Log(title = "字典类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody UDictType dict) + { + if (!dictTypeService.checkDictTypeUnique(dict)) + { + return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setCreateBy(SecurityUtils.getUsername()); + return toAjax(dictTypeService.insertDictType(dict)); + } + + /** + * 修改字典类型 + */ + @RequiresPermissions("Utem:dict:edit") + @Log(title = "字典类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody UDictType dict) + { + if (!dictTypeService.checkDictTypeUnique(dict)) + { + return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(dictTypeService.updateDictType(dict)); + } + + /** + * 删除字典类型 + */ + @RequiresPermissions("Utem:dict:remove") + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictIds}") + public AjaxResult remove(@PathVariable Long[] dictIds) + { + dictTypeService.deleteDictTypeByIds(dictIds); + return success(); + } + + /** + * 刷新字典缓存 + */ + @RequiresPermissions("Utem:dict:remove") + @Log(title = "字典类型", businessType = BusinessType.CLEAN) + @DeleteMapping("/refreshCache") + public AjaxResult refreshCache() + { + dictTypeService.resetDictCache(); + return success(); + } + + /** + * 获取字典选择框列表 + */ + @GetMapping("/optionselect") + public AjaxResult optionselect() + { + List dictTypes = dictTypeService.selectDictTypeAll(); + return success(dictTypes); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/ULogininforController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/ULogininforController.java new file mode 100644 index 0000000..74dcc1c --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/ULogininforController.java @@ -0,0 +1,87 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.constant.CacheConstants; +import org.wfc.common.core.utils.poi.ExcelUtil; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.redis.service.RedisService; +import org.wfc.common.security.annotation.InnerAuth; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.user.api.domain.ULogininfor; +import org.wfc.user.service.IULogininforService; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 系统访问记录 + * + * @author wfc + */ +@RestController +@RequestMapping("/logininfor") +public class ULogininforController extends BaseController +{ + @Autowired + private IULogininforService logininforService; + + @Autowired + private RedisService redisService; + + @RequiresPermissions("Utem:logininfor:list") + @GetMapping("/list") + public TableDataInfo list(ULogininfor logininfor) + { + startPage(); + List list = logininforService.selectLogininforList(logininfor); + return getDataTable(list); + } + + @Log(title = "登录日志", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:logininfor:export") + @PostMapping("/export") + public void export(HttpServletResponse response, ULogininfor logininfor) + { + List list = logininforService.selectLogininforList(logininfor); + ExcelUtil util = new ExcelUtil(ULogininfor.class); + util.exportExcel(response, list, "登录日志"); + } + + @RequiresPermissions("Utem:logininfor:remove") + @Log(title = "登录日志", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) + { + return toAjax(logininforService.deleteLogininforByIds(infoIds)); + } + + @RequiresPermissions("Utem:logininfor:remove") + @Log(title = "登录日志", businessType = BusinessType.DELETE) + @DeleteMapping("/clean") + public AjaxResult clean() + { + logininforService.cleanLogininfor(); + return success(); + } + + @RequiresPermissions("Utem:logininfor:unlock") + @Log(title = "账户解锁", businessType = BusinessType.OTHER) + @GetMapping("/unlock/{userName}") + public AjaxResult unlock(@PathVariable("userName") String userName) + { + redisService.deleteObject(CacheConstants.PWD_ERR_CNT_KEY + userName); + return success(); + } + + @InnerAuth + @PostMapping + public AjaxResult add(@RequestBody ULogininfor logininfor) + { + return toAjax(logininforService.insertLogininfor(logininfor)); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UMenuController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UMenuController.java new file mode 100644 index 0000000..140a5e0 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UMenuController.java @@ -0,0 +1,153 @@ +package org.wfc.user.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.domain.UMenu; +import org.wfc.user.service.IUMenuService; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 菜单信息 + * + * @author wfc + */ +@RestController +@RequestMapping("/menu") +public class UMenuController extends BaseController { + private static final Logger logger = LoggerFactory.getLogger(UMenuController.class); + + @Autowired + private IUMenuService menuService; + + public enum RoutersType { + /** + * 菜单 + */ + MENU, + /** + * 按钮 + */ + MENU_CONSTANT + } + + /** + * 获取菜单列表 + */ + @RequiresPermissions("Utem:menu:list") + @GetMapping("/list") + public TableDataInfo list(UMenu menu) { + Long userId = SecurityUtils.getUserId(); + List menus = menuService.selectMenuList(menu, userId); + return getDataTable(menus); + } + + /** + * 根据菜单编号获取详细信息 + */ + @RequiresPermissions("Utem:menu:query") + @GetMapping(value = "/{menuId}") + public AjaxResult getInfo(@PathVariable Long menuId) { + return success(menuService.selectMenuById(menuId)); + } + + /** + * 获取菜单下拉树列表 + */ + @GetMapping("/treeselect") + public AjaxResult treeselect(UMenu menu) { + Long userId = SecurityUtils.getUserId(); + List menus = menuService.selectMenuList(menu, userId); + return success(menuService.buildMenuTreeSelect(menus)); + } + + /** + * 加载对应角色菜单列表树 + */ + @GetMapping(value = "/roleMenuTreeselect/{roleId}") + public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) { + Long userId = SecurityUtils.getUserId(); + List menus = menuService.selectMenuList(userId); + Map ajax = new HashMap<>(); + ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); + ajax.put("menus", menuService.buildMenuTreeSelect(menus)); + return AjaxResult.success(ajax); + } + + /** + * 新增菜单 + */ + @RequiresPermissions("Utem:menu:add") + @Log(title = "菜单管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody UMenu menu) { + if (!menuService.checkMenuNameUnique(menu)) { + return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { + return error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); + } + menu.setCreateBy(SecurityUtils.getUsername()); + return toAjax(menuService.insertMenu(menu)); + } + + /** + * 修改菜单 + */ + @RequiresPermissions("Utem:menu:edit") + @Log(title = "菜单管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody UMenu menu) { + if (!menuService.checkMenuNameUnique(menu)) { + return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { + return error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); + } else if (menu.getMenuId().equals(menu.getParentId())) { + return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); + } + menu.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(menuService.updateMenu(menu)); + } + + /** + * 删除菜单 + */ + @RequiresPermissions("Utem:menu:remove") + @Log(title = "菜单管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{menuId}") + public AjaxResult remove(@PathVariable("menuId") Long menuId) { + if (menuService.hasChildByMenuId(menuId)) { + return warn("存在子菜单,不允许删除"); + } + if (menuService.checkMenuExistRole(menuId)) { + return warn("菜单已分配,不允许删除"); + } + return toAjax(menuService.deleteMenuById(menuId)); + } + + /** + * 获取路由信息 + * + * @return 路由信息 + */ + @GetMapping("getRouters") + public AjaxResult getRouters() { + // @PathVariable("type") RoutersType type + Long userId = SecurityUtils.getUserId(); + List menus = menuService.selectMenuTreeByUserId(userId); + return success(menuService.buildMenus(menus)); + } +} \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOperlogController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOperlogController.java new file mode 100644 index 0000000..4f1487f --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOperlogController.java @@ -0,0 +1,73 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.utils.poi.ExcelUtil; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.InnerAuth; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.user.api.domain.UOperLog; +import org.wfc.user.service.IUOperLogService; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 操作日志记录 + * + * @author wfc + */ +@RestController +@RequestMapping("/operlog") +public class UOperlogController extends BaseController +{ + @Autowired + private IUOperLogService operLogService; + + @RequiresPermissions("Utem:operlog:list") + @GetMapping("/list") + public TableDataInfo list(UOperLog operLog) + { + startPage(); + List list = operLogService.selectOperLogList(operLog); + return getDataTable(list); + } + + @Log(title = "操作日志", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:operlog:export") + @PostMapping("/export") + public void export(HttpServletResponse response, UOperLog operLog) + { + List list = operLogService.selectOperLogList(operLog); + ExcelUtil util = new ExcelUtil(UOperLog.class); + util.exportExcel(response, list, "操作日志"); + } + + @Log(title = "操作日志", businessType = BusinessType.DELETE) + @RequiresPermissions("Utem:operlog:remove") + @DeleteMapping("/{operIds}") + public AjaxResult remove(@PathVariable Long[] operIds) + { + return toAjax(operLogService.deleteOperLogByIds(operIds)); + } + + @RequiresPermissions("Utem:operlog:remove") + @Log(title = "操作日志", businessType = BusinessType.CLEAN) + @DeleteMapping("/clean") + public AjaxResult clean() + { + operLogService.cleanOperLog(); + return success(); + } + + @InnerAuth + @PostMapping + public AjaxResult add(@RequestBody UOperLog operLog) + { + return toAjax(operLogService.insertOperlog(operLog)); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UPostController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UPostController.java new file mode 100644 index 0000000..883c2fe --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UPostController.java @@ -0,0 +1,124 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.utils.poi.ExcelUtil; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.domain.UPost; +import org.wfc.user.service.IUPostService; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 岗位信息操作处理 + * + * @author wfc + */ +@RestController +@RequestMapping("/post") +public class UPostController extends BaseController +{ + @Autowired + private IUPostService postService; + + /** + * 获取岗位列表 + */ + @RequiresPermissions("Utem:post:list") + @GetMapping("/list") + public TableDataInfo list(UPost post) + { + startPage(); + List list = postService.selectPostList(post); + return getDataTable(list); + } + + @Log(title = "岗位管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:post:export") + @PostMapping("/export") + public void export(HttpServletResponse response, UPost post) + { + List list = postService.selectPostList(post); + ExcelUtil util = new ExcelUtil(UPost.class); + util.exportExcel(response, list, "岗位数据"); + } + + /** + * 根据岗位编号获取详细信息 + */ + @RequiresPermissions("Utem:post:query") + @GetMapping(value = "/{postId}") + public AjaxResult getInfo(@PathVariable Long postId) + { + return success(postService.selectPostById(postId)); + } + + /** + * 新增岗位 + */ + @RequiresPermissions("Utem:post:add") + @Log(title = "岗位管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody UPost post) + { + if (!postService.checkPostNameUnique(post)) + { + return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + } + else if (!postService.checkPostCodeUnique(post)) + { + return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } + post.setCreateBy(SecurityUtils.getUsername()); + return toAjax(postService.insertPost(post)); + } + + /** + * 修改岗位 + */ + @RequiresPermissions("Utem:post:edit") + @Log(title = "岗位管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody UPost post) + { + if (!postService.checkPostNameUnique(post)) + { + return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + } + else if (!postService.checkPostCodeUnique(post)) + { + return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } + post.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(postService.updatePost(post)); + } + + /** + * 删除岗位 + */ + @RequiresPermissions("Utem:post:remove") + @Log(title = "岗位管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{postIds}") + public AjaxResult remove(@PathVariable Long[] postIds) + { + return toAjax(postService.deletePostByIds(postIds)); + } + + /** + * 获取岗位选择框列表 + */ + @GetMapping("/optionselect") + public AjaxResult optionselect() + { + List posts = postService.selectPostAll(); + return success(posts); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UProfileController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UProfileController.java new file mode 100644 index 0000000..942d06d --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UProfileController.java @@ -0,0 +1,153 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.wfc.common.core.domain.LoginUser; +import org.wfc.common.core.domain.R; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.core.utils.file.FileTypeUtils; +import org.wfc.common.core.utils.file.MimeTypeUtils; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.service.TokenService; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.RemoteUFileService; +import org.wfc.user.api.domain.UFile; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.service.IUUserService; + +import java.util.Arrays; + +/** + * 个人信息 业务处理 + * + * @author wfc + */ +@RestController +@RequestMapping("/user/profile") +public class UProfileController extends BaseController +{ + @Autowired + private IUUserService userService; + + @Autowired + private TokenService tokenService; + + @Autowired + private RemoteUFileService remoteUFileService; + + /** + * 个人信息 + */ + @GetMapping + public AjaxResult profile() + { + String username = SecurityUtils.getUsername(); + UUser user = userService.selectUserByUserName(username); + AjaxResult ajax = AjaxResult.success(user); + ajax.put("roleGroup", userService.selectUserRoleGroup(username)); + ajax.put("postGroup", userService.selectUserPostGroup(username)); + return ajax; + } + + /** + * 修改用户 + */ + @Log(title = "个人信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult updateProfile(@RequestBody UUser user) + { + LoginUser loginUser = SecurityUtils.getLoginUser(); + UUser currentUser = loginUser.getUser(); + currentUser.setNickName(user.getNickName()); + currentUser.setEmail(user.getEmail()); + currentUser.setPhonenumber(user.getPhonenumber()); + currentUser.setSex(user.getSex()); + if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) + { + return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在"); + } + if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) + { + return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在"); + } + if (userService.updateUserProfile(currentUser)) + { + // 更新缓存用户信息 + tokenService.setLoginUser(loginUser); + return success(); + } + return error("修改个人信息异常,请联系管理员"); + } + + /** + * 重置密码 + */ + @Log(title = "个人信息", businessType = BusinessType.UPDATE) + @PutMapping("/updatePwd") + public AjaxResult updatePwd(String oldPassword, String newPassword) + { + String username = SecurityUtils.getUsername(); + UUser user = userService.selectUserByUserName(username); + String password = user.getPassword(); + if (!SecurityUtils.matchesPassword(oldPassword, password)) + { + return error("修改密码失败,旧密码错误"); + } + if (SecurityUtils.matchesPassword(newPassword, password)) + { + return error("新密码不能与旧密码相同"); + } + newPassword = SecurityUtils.encryptPassword(newPassword); + if (userService.resetUserPwd(username, newPassword) > 0) + { + // 更新缓存用户密码 + LoginUser loginUser = SecurityUtils.getLoginUser(); + UUser uuser = loginUser.getUser(); + uuser.setPassword(newPassword); + loginUser.setUser(uuser); + tokenService.setLoginUser(loginUser); + return success(); + } + return error("修改密码异常,请联系管理员"); + } + + /** + * 头像上传 + */ + @Log(title = "用户头像", businessType = BusinessType.UPDATE) + @PostMapping("/avatar") + public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) + { + if (!file.isEmpty()) + { + LoginUser loginUser = SecurityUtils.getLoginUser(); + String extension = FileTypeUtils.getExtension(file); + if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) + { + return error("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式"); + } + R fileResult = remoteUFileService.upload(file); + if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData())) + { + return error("文件服务异常,请联系管理员"); + } + String url = fileResult.getData().getUrl(); + if (userService.updateUserAvatar(loginUser.getUsername(), url)) + { + AjaxResult ajax = AjaxResult.success(); + ajax.put("imgUrl", url); + // 更新缓存用户头像 + UUser uuser = loginUser.getUser(); + uuser.setAvatar(url); + loginUser.setUser(uuser); + tokenService.setLoginUser(loginUser); + return ajax; + } + } + return error("上传图片异常,请联系管理员"); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/URoleController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/URoleController.java new file mode 100644 index 0000000..24c8540 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/URoleController.java @@ -0,0 +1,233 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.utils.poi.ExcelUtil; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.UDept; +import org.wfc.user.api.domain.URole; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.domain.UUserRole; +import org.wfc.user.service.IUDeptService; +import org.wfc.user.service.IURoleService; +import org.wfc.user.service.IUUserService; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 角色信息 + * + * @author wfc + */ +@RestController +@RequestMapping("/role") +public class URoleController extends BaseController +{ + @Autowired + private IURoleService roleService; + + @Autowired + private IUUserService userService; + + @Autowired + private IUDeptService deptService; + + @RequiresPermissions("Utem:role:list") + @GetMapping("/list") + public TableDataInfo list(URole role) + { + startPage(); + List list = roleService.selectRoleList(role); + return getDataTable(list); + } + + @Log(title = "角色管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:role:export") + @PostMapping("/export") + public void export(HttpServletResponse response, URole role) + { + List list = roleService.selectRoleList(role); + ExcelUtil util = new ExcelUtil(URole.class); + util.exportExcel(response, list, "角色数据"); + } + + /** + * 根据角色编号获取详细信息 + */ + @RequiresPermissions("Utem:role:query") + @GetMapping(value = "/{roleId}") + public AjaxResult getInfo(@PathVariable Long roleId) + { + roleService.checkRoleDataScope(roleId); + return success(roleService.selectRoleById(roleId)); + } + + /** + * 新增角色 + */ + @RequiresPermissions("Utem:role:add") + @Log(title = "角色管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody URole role) + { + if (!roleService.checkRoleNameUnique(role)) + { + return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); + } + else if (!roleService.checkRoleKeyUnique(role)) + { + return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); + } + role.setCreateBy(SecurityUtils.getUsername()); + return toAjax(roleService.insertRole(role)); + + } + + /** + * 修改保存角色 + */ + @RequiresPermissions("Utem:role:edit") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody URole role) + { + roleService.checkRoleAllowed(role); + roleService.checkRoleDataScope(role.getRoleId()); + if (!roleService.checkRoleNameUnique(role)) + { + return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); + } + else if (!roleService.checkRoleKeyUnique(role)) + { + return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); + } + role.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(roleService.updateRole(role)); + } + + /** + * 修改保存数据权限 + */ + @RequiresPermissions("Utem:role:edit") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PutMapping("/dataScope") + public AjaxResult dataScope(@RequestBody URole role) + { + roleService.checkRoleAllowed(role); + roleService.checkRoleDataScope(role.getRoleId()); + return toAjax(roleService.authDataScope(role)); + } + + /** + * 状态修改 + */ + @RequiresPermissions("Utem:role:edit") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PutMapping("/changeStatus") + public AjaxResult changeStatus(@RequestBody URole role) + { + roleService.checkRoleAllowed(role); + roleService.checkRoleDataScope(role.getRoleId()); + role.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(roleService.updateRoleStatus(role)); + } + + /** + * 删除角色 + */ + @RequiresPermissions("Utem:role:remove") + @Log(title = "角色管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{roleIds}") + public AjaxResult remove(@PathVariable Long[] roleIds) + { + return toAjax(roleService.deleteRoleByIds(roleIds)); + } + + /** + * 获取角色选择框列表 + */ + @RequiresPermissions("Utem:role:query") + @GetMapping("/optionselect") + public AjaxResult optionselect() + { + return success(roleService.selectRoleAll()); + } + /** + * 查询已分配用户角色列表 + */ + @RequiresPermissions("Utem:role:list") + @GetMapping("/authUser/allocatedList") + public TableDataInfo allocatedList(UUser user) + { + startPage(); + List list = userService.selectAllocatedList(user); + return getDataTable(list); + } + + /** + * 查询未分配用户角色列表 + */ + @RequiresPermissions("Utem:role:list") + @GetMapping("/authUser/unallocatedList") + public TableDataInfo unallocatedList(UUser user) + { + startPage(); + List list = userService.selectUnallocatedList(user); + return getDataTable(list); + } + + /** + * 取消授权用户 + */ + @RequiresPermissions("Utem:role:edit") + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PutMapping("/authUser/cancel") + public AjaxResult cancelAuthUser(@RequestBody UUserRole userRole) + { + return toAjax(roleService.deleteAuthUser(userRole)); + } + + /** + * 批量取消授权用户 + */ + @RequiresPermissions("Utem:role:edit") + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PutMapping("/authUser/cancelAll") + public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) + { + return toAjax(roleService.deleteAuthUsers(roleId, userIds)); + } + + /** + * 批量选择用户授权 + */ + @RequiresPermissions("Utem:role:edit") + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PutMapping("/authUser/selectAll") + public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) + { + roleService.checkRoleDataScope(roleId); + return toAjax(roleService.insertAuthUsers(roleId, userIds)); + } + + /** + * 获取对应角色部门树列表 + */ + @RequiresPermissions("Utem:role:query") + @GetMapping(value = "/deptTree/{roleId}") + public AjaxResult deptTree(@PathVariable("roleId") Long roleId) + { + AjaxResult ajax = AjaxResult.success(); + ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); + ajax.put("depts", deptService.selectDeptTreeList(new UDept())); + return ajax; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserController.java index b202be3..c7ebb06 100644 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserController.java +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserController.java @@ -1,104 +1,358 @@ package org.wfc.user.controller; -import java.util.List; -import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.wfc.common.log.annotation.Log; -import org.wfc.common.log.enums.BusinessType; -import org.wfc.common.security.annotation.RequiresPermissions; -import org.wfc.user.domain.UUser; -import org.wfc.user.service.IUUserService; +import org.springframework.context.MessageSource; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.wfc.common.core.domain.LoginUser; +import org.wfc.common.core.domain.R; +import org.wfc.common.core.utils.MessageUtils; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.core.utils.poi.ExcelUtil; import org.wfc.common.core.web.controller.BaseController; import org.wfc.common.core.web.domain.AjaxResult; -import org.wfc.common.core.utils.poi.ExcelUtil; import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.security.annotation.InnerAuth; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.common.security.service.TokenService; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.UDept; +import org.wfc.user.api.domain.URole; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.service.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; /** - * 用户平台_用户信息Controller - * + * 用户信息 + * * @author wfc - * @date 2024-11-25 */ @RestController @RequestMapping("/user") public class UUserController extends BaseController { @Autowired - private IUUserService uUserService; + private IUUserService userService; + + @Autowired + private IURoleService roleService; + + @Autowired + private IUDeptService deptService; + + @Autowired + private IUPostService postService; + + @Autowired + private IUPermissionService permissionService; + + @Autowired + private IUConfigService configService; + + @Autowired + private TokenService tokenService; + + @Autowired + private MessageSource messageSource; /** - * 查询用户平台_用户信息列表 + * 获取用户列表 */ - @RequiresPermissions("user:user:list") + @GetMapping("/test") + public String test() + { + return MessageUtils.message("user.jcaptcha.error"); + } + + /** + * 获取用户列表 + */ + @RequiresPermissions("Utem:user:list") @GetMapping("/list") - public TableDataInfo list(UUser uUser) + public TableDataInfo list(UUser user) { startPage(); - List list = uUserService.selectUUserList(uUser); + List list = userService.selectUserList(user); return getDataTable(list); } - /** - * 导出用户平台_用户信息列表 - */ - @RequiresPermissions("user:user:export") - @Log(title = "用户平台_用户信息", businessType = BusinessType.EXPORT) + @Log(title = "用户管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("Utem:user:export") @PostMapping("/export") - public void export(HttpServletResponse response, UUser uUser) + public void export(HttpServletResponse response, UUser user) { - List list = uUserService.selectUUserList(uUser); + List list = userService.selectUserList(user); ExcelUtil util = new ExcelUtil(UUser.class); - util.exportExcel(response, list, "用户平台_用户信息数据"); + util.exportExcel(response, list, "用户数据"); } - /** - * 获取用户平台_用户信息详细信息 - */ - @RequiresPermissions("user:user:query") - @GetMapping(value = "/{userId}") - public AjaxResult getInfo(@PathVariable("userId") Long userId) + @Log(title = "用户管理", businessType = BusinessType.IMPORT) + @RequiresPermissions("Utem:user:import") + @PostMapping("/importData") + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { - return success(uUserService.selectUUserByUserId(userId)); + ExcelUtil util = new ExcelUtil(UUser.class); + List userList = util.importExcel(file.getInputStream()); + String operName = SecurityUtils.getUsername(); + String message = userService.importUser(userList, updateSupport, operName); + return success(message); + } + + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) throws IOException + { + ExcelUtil util = new ExcelUtil(UUser.class); + util.importTemplateExcel(response, "用户数据"); } /** - * 新增用户平台_用户信息 + * 获取当前用户信息 */ - @RequiresPermissions("user:user:add") - @Log(title = "用户平台_用户信息", businessType = BusinessType.INSERT) + @InnerAuth + @GetMapping("/info/{username}") + public R> info(@PathVariable("username") String username) + { + UUser user = userService.selectUserByUserName(username); + if (StringUtils.isNull(user)) + { + return R.fail("用户名或密码错误"); + } + // 角色集合 + Set roles = permissionService.getRolePermission(user); + // 权限集合 + Set permissions = permissionService.getMenuPermission(user); + LoginUser UUserVo = new LoginUser(); + UUserVo.setUser(user); + UUserVo.setRoles(roles); + UUserVo.setPermissions(permissions); + return R.ok(UUserVo); + } + + /** + * 注册用户信息 + */ + @InnerAuth + @PostMapping("/register") + public R register(@RequestBody UUser UUser) + { + String username = UUser.getUserName(); + if (!("true".equals(configService.selectConfigByKey("U.account.registerUser")))) + { + return R.fail("当前系统没有开启注册功能!"); + } + if (!userService.checkUserNameUnique(UUser)) + { + return R.fail("保存用户'" + username + "'失败,注册账号已存在"); + } + return R.ok(userService.registerUser(UUser)); + } + + /** + *记录用户登录IP地址和登录时间 + */ + @InnerAuth + @PutMapping("/recordlogin") + public R recordlogin(@RequestBody UUser UUser) + { + return R.ok(userService.updateUserProfile(UUser)); + } + + /** + * 获取用户信息 + * + * @return 用户信息 + */ + @GetMapping("getInfo") + public AjaxResult getInfo() + { + LoginUser loginUser = SecurityUtils.getLoginUser(); + UUser user = loginUser.getUser(); + // 角色集合 + Set roles = permissionService.getRolePermission(user); + // 权限集合 + Set permissions = permissionService.getMenuPermission(user); + if (!loginUser.getPermissions().equals(permissions)) + { + loginUser.setPermissions(permissions); + tokenService.refreshToken(loginUser); + } + Map data = new HashMap<>(); + + data.put("user", user); + data.put("roles", roles); + data.put("permissions", permissions); + + return AjaxResult.success(data); + } + + /** + * 根据用户编号获取详细信息 + */ + @RequiresPermissions("Utem:user:query") + @GetMapping(value = { "/", "/{userId}" }) + public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) + { + Map data = new HashMap<>(); + List roles = roleService.selectRoleAll(); + data.put("roles", UUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); + data.put("posts", postService.selectPostAll()); + if (StringUtils.isNotNull(userId)) + { + userService.checkUserDataScope(userId); + UUser UUser = userService.selectUserById(userId); + data.put(AjaxResult.DATA_TAG, UUser); + data.put("postIds", postService.selectPostListByUserId(userId)); + data.put("roleIds", UUser.getRoles().stream().map(URole::getRoleId).collect(Collectors.toList())); + } + return AjaxResult.success(data); + } + + /** + * 新增用户 + */ + @RequiresPermissions("Utem:user:add") + @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody UUser uUser) + public AjaxResult add(@Validated @RequestBody UUser user) { - return toAjax(uUserService.insertUUser(uUser)); + deptService.checkDeptDataScope(user.getDeptId()); + roleService.checkRoleDataScope(user.getRoleIds()); + if (!userService.checkUserNameUnique(user)) + { + return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); + } + else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) + { + return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) + { + return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + } + user.setCreateBy(SecurityUtils.getUsername()); + user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); + return toAjax(userService.insertUser(user)); } /** - * 修改用户平台_用户信息 + * 修改用户 */ - @RequiresPermissions("user:user:edit") - @Log(title = "用户平台_用户信息", businessType = BusinessType.UPDATE) + @RequiresPermissions("Utem:user:edit") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody UUser uUser) + public AjaxResult edit(@Validated @RequestBody UUser user) { - return toAjax(uUserService.updateUUser(uUser)); + userService.checkUserAllowed(user); + userService.checkUserDataScope(user.getUserId()); + deptService.checkDeptDataScope(user.getDeptId()); + roleService.checkRoleDataScope(user.getRoleIds()); + if (!userService.checkUserNameUnique(user)) + { + return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); + } + else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) + { + return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) + { + return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + } + user.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(userService.updateUser(user)); } /** - * 删除用户平台_用户信息 + * 删除用户 */ - @RequiresPermissions("user:user:remove") - @Log(title = "用户平台_用户信息", businessType = BusinessType.DELETE) + @RequiresPermissions("Utem:user:remove") + @Log(title = "用户管理", businessType = BusinessType.DELETE) @DeleteMapping("/{userIds}") public AjaxResult remove(@PathVariable Long[] userIds) { - return toAjax(uUserService.deleteUUserByUserIds(userIds)); + if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) + { + return error("当前用户不能删除"); + } + return toAjax(userService.deleteUserByIds(userIds)); + } + + /** + * 重置密码 + */ + @RequiresPermissions("Utem:user:edit") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @PutMapping("/resetPwd") + public AjaxResult resetPwd(@RequestBody UUser user) + { + userService.checkUserAllowed(user); + userService.checkUserDataScope(user.getUserId()); + user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); + user.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(userService.resetPwd(user)); + } + + /** + * 状态修改 + */ + @RequiresPermissions("Utem:user:edit") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @PutMapping("/changeStatus") + public AjaxResult changeStatus(@RequestBody UUser user) + { + userService.checkUserAllowed(user); + userService.checkUserDataScope(user.getUserId()); + user.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(userService.updateUserStatus(user)); + } + + /** + * 根据用户编号获取授权角色 + */ + @RequiresPermissions("Utem:user:query") + @GetMapping("/authRole/{userId}") + public AjaxResult authRole(@PathVariable("userId") Long userId) + { + AjaxResult ajax = AjaxResult.success(); + UUser user = userService.selectUserById(userId); + List roles = roleService.selectRolesByUserId(userId); + ajax.put("user", user); + ajax.put("roles", UUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); + return ajax; + } + + /** + * 用户授权角色 + */ + @RequiresPermissions("Utem:user:edit") + @Log(title = "用户管理", businessType = BusinessType.GRANT) + @PutMapping("/authRole") + public AjaxResult insertAuthRole(Long userId, Long[] roleIds) + { + userService.checkUserDataScope(userId); + roleService.checkRoleDataScope(roleIds); + userService.insertUserAuth(userId, roleIds); + return success(); + } + + /** + * 获取部门树列表 + */ + @RequiresPermissions("Utem:user:list") + @GetMapping("/deptTree") + public AjaxResult deptTree(UDept dept) + { + return success(deptService.selectDeptTreeList(dept)); } } diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserOnlineController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserOnlineController.java new file mode 100644 index 0000000..87cb12b --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UUserOnlineController.java @@ -0,0 +1,80 @@ +package org.wfc.user.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.wfc.common.core.constant.CacheConstants; +import org.wfc.common.core.domain.LoginUser; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.common.log.annotation.Log; +import org.wfc.common.log.enums.BusinessType; +import org.wfc.common.redis.service.RedisService; +import org.wfc.common.security.annotation.RequiresPermissions; +import org.wfc.user.domain.UUserOnline; +import org.wfc.user.service.IUUserOnlineService; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * 在线用户监控 + * + * @author wfc + */ +@RestController +@RequestMapping("/online") +public class UUserOnlineController extends BaseController +{ + @Autowired + private IUUserOnlineService userOnlineService; + + @Autowired + private RedisService redisService; + + @RequiresPermissions("monitor:online:list") + @GetMapping("/list") + public TableDataInfo list(String ipaddr, String userName) + { + Collection keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); + List userOnlineList = new ArrayList(); + for (String key : keys) + { + LoginUser user = redisService.getCacheObject(key); + if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) + { + userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); + } + else if (StringUtils.isNotEmpty(ipaddr)) + { + userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); + } + else if (StringUtils.isNotEmpty(userName)) + { + userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); + } + else + { + userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); + } + } + Collections.reverse(userOnlineList); + userOnlineList.removeAll(Collections.singleton(null)); + return getDataTable(userOnlineList); + } + + /** + * 强退用户 + */ + @RequiresPermissions("monitor:online:forceLogout") + @Log(title = "在线用户", businessType = BusinessType.FORCE) + @DeleteMapping("/{tokenId}") + public AjaxResult forceLogout(@PathVariable String tokenId) + { + redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); + return success(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UConfig.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UConfig.java new file mode 100644 index 0000000..5f0b86b --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UConfig.java @@ -0,0 +1,112 @@ +package org.wfc.user.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.wfc.common.core.annotation.Excel; +import org.wfc.common.core.annotation.Excel.ColumnType; +import org.wfc.common.core.web.domain.BaseEntity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 参数配置表 u_config + * + * @author wfc + */ +public class UConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 参数主键 */ + @Excel(name = "参数主键", cellType = ColumnType.NUMERIC) + private Long configId; + + /** 参数名称 */ + @Excel(name = "参数名称") + private String configName; + + /** 参数键名 */ + @Excel(name = "参数键名") + private String configKey; + + /** 参数键值 */ + @Excel(name = "参数键值") + private String configValue; + + /** 系统内置(Y是 N否) */ + @Excel(name = "系统内置", readConverterExp = "Y=是,N=否") + private String configType; + + public Long getConfigId() + { + return configId; + } + + public void setConfigId(Long configId) + { + this.configId = configId; + } + + @NotBlank(message = "参数名称不能为空") + @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") + public String getConfigName() + { + return configName; + } + + public void setConfigName(String configName) + { + this.configName = configName; + } + + @NotBlank(message = "参数键名长度不能为空") + @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") + public String getConfigKey() + { + return configKey; + } + + public void setConfigKey(String configKey) + { + this.configKey = configKey; + } + + @NotBlank(message = "参数键值不能为空") + @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") + public String getConfigValue() + { + return configValue; + } + + public void setConfigValue(String configValue) + { + this.configValue = configValue; + } + + public String getConfigType() + { + return configType; + } + + public void setConfigType(String configType) + { + this.configType = configType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("configId", getConfigId()) + .append("configName", getConfigName()) + .append("configKey", getConfigKey()) + .append("configValue", getConfigValue()) + .append("configType", getConfigType()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UMenu.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UMenu.java new file mode 100644 index 0000000..8a59de1 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UMenu.java @@ -0,0 +1,287 @@ +package org.wfc.user.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.wfc.common.core.web.domain.BaseEntity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.List; + +/** + * 菜单权限表 u_menu + * + * @author wfc + */ +public class UMenu extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 菜单ID */ + private Long menuId; + + /** 菜单名称 */ + private String menuName; + + /** 父菜单名称 */ + private String parentName; + + /** 父菜单ID */ + private Long parentId; + + /** 显示顺序 */ + private Integer orderNum; + + /** 路由地址 */ + private String path; + + /** 组件路径 */ + private String component; + + /** 路由参数 */ + private String query; + + /** 路由名称,默认和路由地址相同的驼峰格式(注意:因为vue3版本的router会删除名称相同路由,为避免名字的冲突,特殊情况可以自定义) */ + private String routeName; + + /** 是否为外链(0是 1否) */ + private String isFrame; + + /** 是否缓存(0缓存 1不缓存) */ + private String isCache; + + /** 类型(M目录 C菜单 F按钮) */ + private String menuType; + + /** 显示状态(0显示 1隐藏) */ + private String visible; + + /** 菜单状态(0正常 1停用) */ + private String status; + + /** 权限字符串 */ + private String perms; + + /** 菜单图标 */ + private String icon; + + /** 菜单key */ + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** 子菜单 */ + private List children = new ArrayList(); + + public Long getMenuId() + { + return menuId; + } + + public void setMenuId(Long menuId) + { + this.menuId = menuId; + } + + @NotBlank(message = "菜单名称不能为空") + @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符") + public String getMenuName() + { + return menuName; + } + + public void setMenuName(String menuName) + { + this.menuName = menuName; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + @NotNull(message = "显示顺序不能为空") + public Integer getOrderNum() + { + return orderNum; + } + + public void setOrderNum(Integer orderNum) + { + this.orderNum = orderNum; + } + + @Size(min = 0, max = 200, message = "路由地址不能超过200个字符") + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + @Size(min = 0, max = 200, message = "组件路径不能超过255个字符") + public String getComponent() + { + return component; + } + + public void setComponent(String component) + { + this.component = component; + } + + public String getQuery() + { + return query; + } + + public void setQuery(String query) + { + this.query = query; + } + + public String getRouteName() + { + return routeName; + } + + public void setRouteName(String routeName) + { + this.routeName = routeName; + } + + public String getIsFrame() + { + return isFrame; + } + + public void setIsFrame(String isFrame) + { + this.isFrame = isFrame; + } + + public String getIsCache() + { + return isCache; + } + + public void setIsCache(String isCache) + { + this.isCache = isCache; + } + + @NotBlank(message = "菜单类型不能为空") + public String getMenuType() + { + return menuType; + } + + public void setMenuType(String menuType) + { + this.menuType = menuType; + } + + public String getVisible() + { + return visible; + } + + public void setVisible(String visible) + { + this.visible = visible; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") + public String getPerms() + { + return perms; + } + + public void setPerms(String perms) + { + this.perms = perms; + } + + public String getIcon() + { + return icon; + } + + public void setIcon(String icon) + { + this.icon = icon; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("menuId", getMenuId()) + .append("menuName", getMenuName()) + .append("parentId", getParentId()) + .append("orderNum", getOrderNum()) + .append("path", getPath()) + .append("component", getComponent()) + .append("query", getQuery()) + .append("routeName", getRouteName()) + .append("isFrame", getIsFrame()) + .append("IsCache", getIsCache()) + .append("menuType", getMenuType()) + .append("visible", getVisible()) + .append("status ", getStatus()) + .append("perms", getPerms()) + .append("icon", getIcon()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("name", getName()) + .toString(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UPost.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UPost.java new file mode 100644 index 0000000..894eb08 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UPost.java @@ -0,0 +1,125 @@ +package org.wfc.user.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.wfc.common.core.annotation.Excel; +import org.wfc.common.core.annotation.Excel.ColumnType; +import org.wfc.common.core.web.domain.BaseEntity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * 岗位表 u_post + * + * @author wfc + */ +public class UPost extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 岗位序号 */ + @Excel(name = "岗位序号", cellType = ColumnType.NUMERIC) + private Long postId; + + /** 岗位编码 */ + @Excel(name = "岗位编码") + private String postCode; + + /** 岗位名称 */ + @Excel(name = "岗位名称") + private String postName; + + /** 岗位排序 */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** 用户是否存在此岗位标识 默认不存在 */ + private boolean flag = false; + + public Long getPostId() + { + return postId; + } + + public void setPostId(Long postId) + { + this.postId = postId; + } + + @NotBlank(message = "岗位编码不能为空") + @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符") + public String getPostCode() + { + return postCode; + } + + public void setPostCode(String postCode) + { + this.postCode = postCode; + } + + @NotBlank(message = "岗位名称不能为空") + @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符") + public String getPostName() + { + return postName; + } + + public void setPostName(String postName) + { + this.postName = postName; + } + + @NotNull(message = "显示顺序不能为空") + public Integer getPostSort() + { + return postSort; + } + + public void setPostSort(Integer postSort) + { + this.postSort = postSort; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public boolean isFlag() + { + return flag; + } + + public void setFlag(boolean flag) + { + this.flag = flag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("postId", getPostId()) + .append("postCode", getPostCode()) + .append("postName", getPostName()) + .append("postSort", getPostSort()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleDept.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleDept.java new file mode 100644 index 0000000..261e6a0 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleDept.java @@ -0,0 +1,46 @@ +package org.wfc.user.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 角色和部门关联 u_role_dept + * + * @author wfc + */ +public class URoleDept +{ + /** 角色ID */ + private Long roleId; + + /** 部门ID */ + private Long deptId; + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("deptId", getDeptId()) + .toString(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleMenu.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleMenu.java new file mode 100644 index 0000000..9f26a7d --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/URoleMenu.java @@ -0,0 +1,46 @@ +package org.wfc.user.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 角色和菜单关联 u_role_menu + * + * @author wfc + */ +public class URoleMenu +{ + /** 角色ID */ + private Long roleId; + + /** 菜单ID */ + private Long menuId; + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public Long getMenuId() + { + return menuId; + } + + public void setMenuId(Long menuId) + { + this.menuId = menuId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("menuId", getMenuId()) + .toString(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUser.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUser.java deleted file mode 100644 index f230142..0000000 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUser.java +++ /dev/null @@ -1,212 +0,0 @@ -package org.wfc.user.domain; - -import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.wfc.common.core.annotation.Excel; -import org.wfc.common.core.web.domain.BaseEntity; - -/** - * 用户平台_用户信息对象 u_user - * - * @author wfc - * @date 2024-11-25 - */ -public class UUser extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 用户ID */ - private Long userId; - - /** 用户账号 */ - @Excel(name = "用户账号") - private String userName; - - /** 用户昵称 */ - @Excel(name = "用户昵称") - private String nickName; - - /** 年龄 */ - @Excel(name = "年龄") - private String age; - - /** 用户性别(0男 1女 2未知) */ - @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") - private String sex; - - /** 用户邮箱 */ - @Excel(name = "用户邮箱") - private String email; - - /** 手机号码 */ - @Excel(name = "手机号码") - private String phone; - - /** 地址 */ - @Excel(name = "地址") - private String address; - - /** 密码 */ - @Excel(name = "密码") - private String password; - - /** 帐号状态(0正常 1停用) */ - @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") - private String status; - - /** 删除标志(0代表存在 2代表删除) */ - private String delFlag; - - /** 最后登录IP */ - @Excel(name = "最后登录IP") - private String loginIp; - - /** 最后登录时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date loginDate; - - public void setUserId(Long userId) - { - this.userId = userId; - } - - public Long getUserId() - { - return userId; - } - public void setUserName(String userName) - { - this.userName = userName; - } - - public String getUserName() - { - return userName; - } - public void setNickName(String nickName) - { - this.nickName = nickName; - } - - public String getNickName() - { - return nickName; - } - public void setAge(String age) - { - this.age = age; - } - - public String getAge() - { - return age; - } - public void setSex(String sex) - { - this.sex = sex; - } - - public String getSex() - { - return sex; - } - public void setEmail(String email) - { - this.email = email; - } - - public String getEmail() - { - return email; - } - public void setPhone(String phone) - { - this.phone = phone; - } - - public String getPhone() - { - return phone; - } - public void setAddress(String address) - { - this.address = address; - } - - public String getAddress() - { - return address; - } - public void setPassword(String password) - { - this.password = password; - } - - public String getPassword() - { - return password; - } - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getDelFlag() - { - return delFlag; - } - public void setLoginIp(String loginIp) - { - this.loginIp = loginIp; - } - - public String getLoginIp() - { - return loginIp; - } - public void setLoginDate(Date loginDate) - { - this.loginDate = loginDate; - } - - public Date getLoginDate() - { - return loginDate; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("userName", getUserName()) - .append("nickName", getNickName()) - .append("age", getAge()) - .append("sex", getSex()) - .append("email", getEmail()) - .append("phone", getPhone()) - .append("address", getAddress()) - .append("password", getPassword()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("loginIp", getLoginIp()) - .append("loginDate", getLoginDate()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserOnline.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserOnline.java new file mode 100644 index 0000000..9f56fce --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserOnline.java @@ -0,0 +1,100 @@ +package org.wfc.user.domain; + +/** + * 当前在线会话 + * + * @author wfc + */ +public class UUserOnline +{ + /** 会话编号 */ + private String tokenId; + + /** 用户名称 */ + private String userName; + + /** 登录IP地址 */ + private String ipaddr; + + /** 登录地址 */ + private String loginLocation; + + /** 浏览器类型 */ + private String browser; + + /** 操作系统 */ + private String os; + + /** 登录时间 */ + private Long loginTime; + + public String getTokenId() + { + return tokenId; + } + + public void setTokenId(String tokenId) + { + this.tokenId = tokenId; + } + + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getIpaddr() + { + return ipaddr; + } + + public void setIpaddr(String ipaddr) + { + this.ipaddr = ipaddr; + } + + public String getLoginLocation() + { + return loginLocation; + } + + public void setLoginLocation(String loginLocation) + { + this.loginLocation = loginLocation; + } + + public String getBrowser() + { + return browser; + } + + public void setBrowser(String browser) + { + this.browser = browser; + } + + public String getOs() + { + return os; + } + + public void setOs(String os) + { + this.os = os; + } + + public Long getLoginTime() + { + return loginTime; + } + + public void setLoginTime(Long loginTime) + { + this.loginTime = loginTime; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserPost.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserPost.java new file mode 100644 index 0000000..65e58c6 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserPost.java @@ -0,0 +1,46 @@ +package org.wfc.user.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 用户和岗位关联 u_user_post + * + * @author wfc + */ +public class UUserPost +{ + /** 用户ID */ + private Long userId; + + /** 岗位ID */ + private Long postId; + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getPostId() + { + return postId; + } + + public void setPostId(Long postId) + { + this.postId = postId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("postId", getPostId()) + .toString(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserRole.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserRole.java new file mode 100644 index 0000000..e810ebf --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/UUserRole.java @@ -0,0 +1,46 @@ +package org.wfc.user.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 用户和角色关联 u_user_role + * + * @author wfc + */ +public class UUserRole +{ + /** 用户ID */ + private Long userId; + + /** 角色ID */ + private Long roleId; + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("roleId", getRoleId()) + .toString(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/MetaVo.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/MetaVo.java new file mode 100644 index 0000000..8391ae1 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/MetaVo.java @@ -0,0 +1,106 @@ +package org.wfc.user.domain.vo; + +import org.wfc.common.core.utils.StringUtils; + +/** + * 路由显示信息 + * + * @author wfc + */ +public class MetaVo +{ + /** + * 设置该路由在侧边栏和面包屑中展示的名字 + */ + private String title; + + /** + * 设置该路由的图标,对应路径src/assets/icons/svg + */ + private String icon; + + /** + * 设置为true,则不会被 缓存 + */ + private boolean noCache; + + /** + * 内链地址(http(s)://开头) + */ + private String link; + + public MetaVo() + { + } + + public MetaVo(String title, String icon) + { + this.title = title; + this.icon = icon; + } + + public MetaVo(String title, String icon, boolean noCache) + { + this.title = title; + this.icon = icon; + this.noCache = noCache; + } + + public MetaVo(String title, String icon, String link) + { + this.title = title; + this.icon = icon; + this.link = link; + } + + public MetaVo(String title, String icon, boolean noCache, String link) + { + this.title = title; + this.icon = icon; + this.noCache = noCache; + if (StringUtils.ishttp(link)) + { + this.link = link; + } + } + + public boolean isNoCache() + { + return noCache; + } + + public void setNoCache(boolean noCache) + { + this.noCache = noCache; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getIcon() + { + return icon; + } + + public void setIcon(String icon) + { + this.icon = icon; + } + + public String getLink() + { + return link; + } + + public void setLink(String link) + { + this.link = link; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/RouterVo.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/RouterVo.java new file mode 100644 index 0000000..8e7b468 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/RouterVo.java @@ -0,0 +1,150 @@ +package org.wfc.user.domain.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.wfc.user.domain.vo.MetaVo; + +import java.util.List; + +/** + * 路由配置信息 + * + * @author wfc + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public class RouterVo +{ + /** + * 路由名字 + */ + private String name; + + /** + * 路由地址 + */ + private String path; + + /** + * 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现 + */ + private boolean hideInMenu; + + /** + * 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击 + */ + private String redirect; + + /** + * 组件地址 + */ + private String component; + + /** + * 路由参数:如 {"id": 1, "name": "ry"} + */ + private String query; + + /** + * 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面 + */ + private Boolean alwaysShow; + + /** + * 其他元素 + */ + private MetaVo meta; + + /** + * 子路由 + */ + private List children; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + public boolean getHideInMenu() + { + return hideInMenu; + } + + public void setHideInMenu(boolean hideInMenu) + { + this.hideInMenu = hideInMenu; + } + + public String getRedirect() + { + return redirect; + } + + public void setRedirect(String redirect) + { + this.redirect = redirect; + } + + public String getComponent() + { + return component; + } + + public void setComponent(String component) + { + this.component = component; + } + + public String getQuery() + { + return query; + } + + public void setQuery(String query) + { + this.query = query; + } + + public Boolean getAlwaysShow() + { + return alwaysShow; + } + + public void setAlwaysShow(Boolean alwaysShow) + { + this.alwaysShow = alwaysShow; + } + + public MetaVo getMeta() + { + return meta; + } + + public void setMeta(MetaVo meta) + { + this.meta = meta; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/TreeSelect.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/TreeSelect.java new file mode 100644 index 0000000..724fcd6 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/domain/vo/TreeSelect.java @@ -0,0 +1,78 @@ +package org.wfc.user.domain.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.wfc.user.api.domain.UDept; +import org.wfc.user.domain.UMenu; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Treeselect树结构实体类 + * + * @author wfc + */ +public class TreeSelect implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private Long id; + + /** 节点名称 */ + private String label; + + /** 子节点 */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public TreeSelect() + { + + } + + public TreeSelect(UDept dept) + { + this.id = dept.getDeptId(); + this.label = dept.getDeptName(); + this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public TreeSelect(UMenu menu) + { + this.id = menu.getMenuId(); + this.label = menu.getMenuName(); + this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public Long getId() + { + return id; + } + + public void setId(Long id) + { + this.id = id; + } + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UConfigMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UConfigMapper.java new file mode 100644 index 0000000..a8d5715 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UConfigMapper.java @@ -0,0 +1,77 @@ +package org.wfc.user.mapper; + +import org.wfc.user.domain.UConfig; + +import java.util.List; + +/** + * 参数配置 数据层 + * + * @author wfc + */ +public interface UConfigMapper +{ + /** + * 查询参数配置信息 + * + * @param config 参数配置信息 + * @return 参数配置信息 + */ + public UConfig selectConfig(UConfig config); + + /** + * 通过ID查询配置 + * + * @param configId 参数ID + * @return 参数配置信息 + */ + public UConfig selectConfigById(Long configId); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(UConfig config); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数配置信息 + */ + public UConfig checkConfigKeyUnique(String configKey); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(UConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(UConfig config); + + /** + * 删除参数配置 + * + * @param configId 参数ID + * @return 结果 + */ + public int deleteConfigById(Long configId); + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + * @return 结果 + */ + public int deleteConfigByIds(Long[] configIds); +} \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDeptMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDeptMapper.java new file mode 100644 index 0000000..8b3a316 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDeptMapper.java @@ -0,0 +1,119 @@ +package org.wfc.user.mapper; + +import org.apache.ibatis.annotations.Param; +import org.wfc.user.api.domain.UDept; + +import java.util.List; + +/** + * 部门管理 数据层 + * + * @author wfc + */ +public interface UDeptMapper +{ + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectDeptList(UDept dept); + + /** + * 根据角色ID查询部门树信息 + * + * @param roleId 角色ID + * @param deptCheckStrictly 部门树选择项是否关联显示 + * @return 选中部门列表 + */ + public List selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + public UDept selectDeptById(Long deptId); + + /** + * 根据ID查询所有子部门 + * + * @param deptId 部门ID + * @return 部门列表 + */ + public List selectChildrenDeptById(Long deptId); + + /** + * 根据ID查询所有子部门(正常状态) + * + * @param deptId 部门ID + * @return 子部门数 + */ + public int selectNormalChildrenDeptById(Long deptId); + + /** + * 是否存在子节点 + * + * @param deptId 部门ID + * @return 结果 + */ + public int hasChildByDeptId(Long deptId); + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 + */ + public int checkDeptExistUser(Long deptId); + + /** + * 校验部门名称是否唯一 + * + * @param deptName 部门名称 + * @param parentId 父部门ID + * @return 结果 + */ + public UDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); + + /** + * 新增部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int insertDept(UDept dept); + + /** + * 修改部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int updateDept(UDept dept); + + /** + * 修改所在部门正常状态 + * + * @param deptIds 部门ID组 + */ + public void updateDeptStatusNormal(Long[] deptIds); + + /** + * 修改子元素关系 + * + * @param depts 子元素 + * @return 结果 + */ + public int updateDeptChildren(@Param("depts") List depts); + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictDataMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictDataMapper.java new file mode 100644 index 0000000..9414015 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictDataMapper.java @@ -0,0 +1,96 @@ +package org.wfc.user.mapper; + +import org.apache.ibatis.annotations.Param; +import org.wfc.user.api.domain.UDictData; + +import java.util.List; + +/** + * 字典表 数据层 + * + * @author wfc + */ +public interface UDictDataMapper +{ + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(UDictData dictData); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public UDictData selectDictDataById(Long dictCode); + + /** + * 查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据 + */ + public int countDictDataByType(String dictType); + + /** + * 通过字典ID删除字典数据信息 + * + * @param dictCode 字典数据ID + * @return 结果 + */ + public int deleteDictDataById(Long dictCode); + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + * @return 结果 + */ + public int deleteDictDataByIds(Long[] dictCodes); + + /** + * 新增字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(UDictData dictData); + + /** + * 修改字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(UDictData dictData); + + /** + * 同步修改字典类型 + * + * @param oldDictType 旧字典类型 + * @param newDictType 新旧字典类型 + * @return 结果 + */ + public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictTypeMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictTypeMapper.java new file mode 100644 index 0000000..982dba6 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UDictTypeMapper.java @@ -0,0 +1,84 @@ +package org.wfc.user.mapper; + +import org.wfc.user.api.domain.UDictType; + +import java.util.List; + +/** + * 字典表 数据层 + * + * @author wfc + */ +public interface UDictTypeMapper +{ + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(UDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public UDictType selectDictTypeById(Long dictId); + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + public UDictType selectDictTypeByType(String dictType); + + /** + * 通过字典ID删除字典信息 + * + * @param dictId 字典ID + * @return 结果 + */ + public int deleteDictTypeById(Long dictId); + + /** + * 批量删除字典类型信息 + * + * @param dictIds 需要删除的字典ID + * @return 结果 + */ + public int deleteDictTypeByIds(Long[] dictIds); + + /** + * 新增字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(UDictType dictType); + + /** + * 修改字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(UDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public UDictType checkDictTypeUnique(String dictType); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/ULogininforMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/ULogininforMapper.java new file mode 100644 index 0000000..87a1d9d --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/ULogininforMapper.java @@ -0,0 +1,43 @@ +package org.wfc.user.mapper; + +import org.wfc.user.api.domain.ULogininfor; + +import java.util.List; + +/** + * 系统访问日志情况信息 数据层 + * + * @author wfc + */ +public interface ULogininforMapper +{ + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + public int insertLogininfor(ULogininfor logininfor); + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + public List selectLogininforList(ULogininfor logininfor); + + /** + * 批量删除系统登录日志 + * + * @param infoIds 需要删除的登录日志ID + * @return 结果 + */ + public int deleteLogininforByIds(Long[] infoIds); + + /** + * 清空系统登录日志 + * + * @return 结果 + */ + public int cleanLogininfor(); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UMenuMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UMenuMapper.java new file mode 100644 index 0000000..fe9b1de --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UMenuMapper.java @@ -0,0 +1,126 @@ +package org.wfc.user.mapper; + +import org.apache.ibatis.annotations.Param; +import org.wfc.user.domain.UMenu; + +import java.util.List; + +/** + * 菜单表 数据层 + * + * @author wfc + */ +public interface UMenuMapper +{ + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + public List selectMenuList(UMenu menu); + + /** + * 根据用户所有权限 + * + * @return 权限列表 + */ + public List selectMenuPerms(); + + /** + * 根据用户查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + public List selectMenuListByUserId(UMenu menu); + + /** + * 根据角色ID查询权限 + * + * @param roleId 角色ID + * @return 权限列表 + */ + public List selectMenuPermsByRoleId(Long roleId); + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public List selectMenuPermsByUserId(Long userId); + + /** + * 根据用户ID查询菜单 + * + * @return 菜单列表 + */ + public List selectMenuTreeAll(); + + /** + * 根据用户ID查询菜单 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuTreeByUserId(Long userId); + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @param menuCheckStrictly 菜单树选择项是否关联显示 + * @return 选中菜单列表 + */ + public List selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + public UMenu selectMenuById(Long menuId); + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int hasChildByMenuId(Long menuId); + + /** + * 新增菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int insertMenu(UMenu menu); + + /** + * 修改菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int updateMenu(UMenu menu); + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int deleteMenuById(Long menuId); + + /** + * 校验菜单名称是否唯一 + * + * @param menuName 菜单名称 + * @param parentId 父菜单ID + * @return 结果 + */ + public UMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UOperLogMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UOperLogMapper.java new file mode 100644 index 0000000..48624cd --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UOperLogMapper.java @@ -0,0 +1,49 @@ +package org.wfc.user.mapper; + +import org.wfc.user.api.domain.UOperLog; + +import java.util.List; + +/** + * 操作日志 数据层 + * + * @author wfc + */ +public interface UOperLogMapper +{ + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + */ + public int insertOperlog(UOperLog operLog); + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + public List selectOperLogList(UOperLog operLog); + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + public int deleteOperLogByIds(Long[] operIds); + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + public UOperLog selectOperLogById(Long operId); + + /** + * 清空操作日志 + */ + public void cleanOperLog(); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UPostMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UPostMapper.java new file mode 100644 index 0000000..283ed11 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UPostMapper.java @@ -0,0 +1,100 @@ +package org.wfc.user.mapper; + +import org.wfc.user.domain.UPost; + +import java.util.List; + +/** + * 岗位信息 数据层 + * + * @author wfc + */ +public interface UPostMapper +{ + /** + * 查询岗位数据集合 + * + * @param post 岗位信息 + * @return 岗位数据集合 + */ + public List selectPostList(UPost post); + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + public List selectPostAll(); + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + public UPost selectPostById(Long postId); + + /** + * 根据用户ID获取岗位选择框列表 + * + * @param userId 用户ID + * @return 选中岗位ID列表 + */ + public List selectPostListByUserId(Long userId); + + /** + * 查询用户所属岗位组 + * + * @param userName 用户名 + * @return 结果 + */ + public List selectPostsByUserName(String userName); + + /** + * 删除岗位信息 + * + * @param postId 岗位ID + * @return 结果 + */ + public int deletePostById(Long postId); + + /** + * 批量删除岗位信息 + * + * @param postIds 需要删除的岗位ID + * @return 结果 + */ + public int deletePostByIds(Long[] postIds); + + /** + * 修改岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int updatePost(UPost post); + + /** + * 新增岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int insertPost(UPost post); + + /** + * 校验岗位名称 + * + * @param postName 岗位名称 + * @return 结果 + */ + public UPost checkPostNameUnique(String postName); + + /** + * 校验岗位编码 + * + * @param postCode 岗位编码 + * @return 结果 + */ + public UPost checkPostCodeUnique(String postCode); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleDeptMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleDeptMapper.java new file mode 100644 index 0000000..35280b3 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleDeptMapper.java @@ -0,0 +1,45 @@ +package org.wfc.user.mapper; + +import org.wfc.user.domain.URoleDept; + +import java.util.List; + +/** + * 角色与部门关联表 数据层 + * + * @author wfc + */ +public interface URoleDeptMapper +{ + /** + * 通过角色ID删除角色和部门关联 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleDeptByRoleId(Long roleId); + + /** + * 批量删除角色部门关联信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleDept(Long[] ids); + + /** + * 查询部门使用数量 + * + * @param deptId 部门ID + * @return 结果 + */ + public int selectCountRoleDeptByDeptId(Long deptId); + + /** + * 批量新增角色部门信息 + * + * @param roleDeptList 角色部门列表 + * @return 结果 + */ + public int batchRoleDept(List roleDeptList); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMapper.java new file mode 100644 index 0000000..e86c48f --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMapper.java @@ -0,0 +1,108 @@ +package org.wfc.user.mapper; + +import org.wfc.user.api.domain.URole; + +import java.util.List; + +/** + * 角色表 数据层 + * + * @author wfc + */ +public interface URoleMapper +{ + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + public List selectRoleList(URole role); + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolePermissionByUserId(Long userId); + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectRoleAll(); + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + public List selectRoleListByUserId(Long userId); + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + public URole selectRoleById(Long roleId); + + /** + * 根据用户ID查询角色 + * + * @param userName 用户名 + * @return 角色列表 + */ + public List selectRolesByUserName(String userName); + + /** + * 校验角色名称是否唯一 + * + * @param roleName 角色名称 + * @return 角色信息 + */ + public URole checkRoleNameUnique(String roleName); + + /** + * 校验角色权限是否唯一 + * + * @param roleKey 角色权限 + * @return 角色信息 + */ + public URole checkRoleKeyUnique(String roleKey); + + /** + * 修改角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRole(URole role); + + /** + * 新增角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int insertRole(URole role); + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleById(Long roleId); + + /** + * 批量删除角色信息 + * + * @param roleIds 需要删除的角色ID + * @return 结果 + */ + public int deleteRoleByIds(Long[] roleIds); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMenuMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMenuMapper.java new file mode 100644 index 0000000..e1fee92 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/URoleMenuMapper.java @@ -0,0 +1,45 @@ +package org.wfc.user.mapper; + +import org.wfc.user.domain.URoleMenu; + +import java.util.List; + +/** + * 角色与菜单关联表 数据层 + * + * @author wfc + */ +public interface URoleMenuMapper +{ + /** + * 查询菜单使用数量 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int checkMenuExistRole(Long menuId); + + /** + * 通过角色ID删除角色和菜单关联 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleMenuByRoleId(Long roleId); + + /** + * 批量删除角色菜单关联信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleMenu(Long[] ids); + + /** + * 批量新增角色菜单信息 + * + * @param roleMenuList 角色菜单列表 + * @return 结果 + */ + public int batchRoleMenu(List roleMenuList); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserMapper.java index 0b7141c..1d3da57 100644 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserMapper.java +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserMapper.java @@ -1,61 +1,128 @@ package org.wfc.user.mapper; +import org.apache.ibatis.annotations.Param; +import org.wfc.user.api.domain.UUser; + import java.util.List; -import org.wfc.user.domain.UUser; /** - * 用户平台_用户信息Mapper接口 - * + * 用户表 数据层 + * * @author wfc - * @date 2024-11-25 */ public interface UUserMapper { /** - * 查询用户平台_用户信息 - * - * @param userId 用户平台_用户信息主键 - * @return 用户平台_用户信息 + * 根据条件分页查询用户列表 + * + * @param UUser 用户信息 + * @return 用户信息集合信息 */ - public UUser selectUUserByUserId(Long userId); + public List selectUserList(UUser UUser); /** - * 查询用户平台_用户信息列表 - * - * @param uUser 用户平台_用户信息 - * @return 用户平台_用户信息集合 + * 根据条件分页查询已配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 */ - public List selectUUserList(UUser uUser); + public List selectAllocatedList(UUser user); /** - * 新增用户平台_用户信息 - * - * @param uUser 用户平台_用户信息 + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUnallocatedList(UUser user); + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + public UUser selectUserByUserName(String userName); + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + public UUser selectUserById(Long userId); + + /** + * 新增用户信息 + * + * @param user 用户信息 * @return 结果 */ - public int insertUUser(UUser uUser); + public int insertUser(UUser user); /** - * 修改用户平台_用户信息 - * - * @param uUser 用户平台_用户信息 + * 修改用户信息 + * + * @param user 用户信息 * @return 结果 */ - public int updateUUser(UUser uUser); + public int updateUser(UUser user); /** - * 删除用户平台_用户信息 - * - * @param userId 用户平台_用户信息主键 + * 修改用户头像 + * + * @param userName 用户名 + * @param avatar 头像地址 * @return 结果 */ - public int deleteUUserByUserId(Long userId); + public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar); /** - * 批量删除用户平台_用户信息 - * - * @param userIds 需要删除的数据主键集合 + * 重置用户密码 + * + * @param userName 用户名 + * @param password 密码 * @return 结果 */ - public int deleteUUserByUserIds(Long[] userIds); + public int resetUserPwd(@Param("userName") String userName, @Param("password") String password); + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserById(Long userId); + + /** + * 批量删除用户信息 + * + * @param userIds 需要删除的用户ID + * @return 结果 + */ + public int deleteUserByIds(Long[] userIds); + + /** + * 校验用户名称是否唯一 + * + * @param userName 用户名称 + * @return 结果 + */ + public UUser checkUserNameUnique(String userName); + + /** + * 校验手机号码是否唯一 + * + * @param phonenumber 手机号码 + * @return 结果 + */ + public UUser checkPhoneUnique(String phonenumber); + + /** + * 校验email是否唯一 + * + * @param email 用户邮箱 + * @return 结果 + */ + public UUser checkEmailUnique(String email); } diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserPostMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserPostMapper.java new file mode 100644 index 0000000..16f10b3 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserPostMapper.java @@ -0,0 +1,45 @@ +package org.wfc.user.mapper; + +import org.wfc.user.domain.UUserPost; + +import java.util.List; + +/** + * 用户与岗位关联表 数据层 + * + * @author wfc + */ +public interface UUserPostMapper +{ + /** + * 通过用户ID删除用户和岗位关联 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserPostByUserId(Long userId); + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + public int countUserPostById(Long postId); + + /** + * 批量删除用户和岗位关联 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUserPost(Long[] ids); + + /** + * 批量新增用户岗位信息 + * + * @param userPostList 用户岗位列表 + * @return 结果 + */ + public int batchUserPost(List userPostList); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserRoleMapper.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserRoleMapper.java new file mode 100644 index 0000000..b1e3c75 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/mapper/UUserRoleMapper.java @@ -0,0 +1,63 @@ +package org.wfc.user.mapper; + +import org.apache.ibatis.annotations.Param; +import org.wfc.user.domain.UUserRole; + +import java.util.List; + +/** + * 用户与角色关联表 数据层 + * + * @author wfc + */ +public interface UUserRoleMapper +{ + /** + * 通过用户ID删除用户和角色关联 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserRoleByUserId(Long userId); + + /** + * 批量删除用户和角色关联 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUserRole(Long[] ids); + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + public int countUserRoleByRoleId(Long roleId); + + /** + * 批量新增用户角色信息 + * + * @param userRoleList 用户角色列表 + * @return 结果 + */ + public int batchUserRole(List userRoleList); + + /** + * 删除用户和角色关联信息 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + public int deleteUserRoleInfo(UUserRole userRole); + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUConfigService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUConfigService.java new file mode 100644 index 0000000..f04ccbc --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUConfigService.java @@ -0,0 +1,83 @@ +package org.wfc.user.service; + +import org.wfc.user.domain.UConfig; + +import java.util.List; + +/** + * 参数配置 服务层 + * + * @author wfc + */ +public interface IUConfigService +{ + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + public UConfig selectConfigById(Long configId); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数键值 + */ + public String selectConfigByKey(String configKey); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(UConfig config); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(UConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(UConfig config); + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + */ + public void deleteConfigByIds(Long[] configIds); + + /** + * 加载参数缓存数据 + */ + public void loadingConfigCache(); + + /** + * 清空参数缓存数据 + */ + public void clearConfigCache(); + + /** + * 重置参数缓存数据 + */ + public void resetConfigCache(); + + /** + * 校验参数键名是否唯一 + * + * @param config 参数信息 + * @return 结果 + */ + public boolean checkConfigKeyUnique(UConfig config); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDeptService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDeptService.java new file mode 100644 index 0000000..f639e41 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDeptService.java @@ -0,0 +1,125 @@ +package org.wfc.user.service; + +import org.wfc.user.api.domain.UDept; +import org.wfc.user.domain.vo.TreeSelect; + +import java.util.List; + +/** + * 部门管理 服务层 + * + * @author wfc + */ +public interface IUDeptService +{ + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectDeptList(UDept dept); + + /** + * 查询部门树结构信息 + * + * @param dept 部门信息 + * @return 部门树信息集合 + */ + public List selectDeptTreeList(UDept dept); + + /** + * 构建前端所需要树结构 + * + * @param depts 部门列表 + * @return 树结构列表 + */ + public List buildDeptTree(List depts); + + /** + * 构建前端所需要下拉树结构 + * + * @param depts 部门列表 + * @return 下拉树结构列表 + */ + public List buildDeptTreeSelect(List depts); + + /** + * 根据角色ID查询部门树信息 + * + * @param roleId 角色ID + * @return 选中部门列表 + */ + public List selectDeptListByRoleId(Long roleId); + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + public UDept selectDeptById(Long deptId); + + /** + * 根据ID查询所有子部门(正常状态) + * + * @param deptId 部门ID + * @return 子部门数 + */ + public int selectNormalChildrenDeptById(Long deptId); + + /** + * 是否存在部门子节点 + * + * @param deptId 部门ID + * @return 结果 + */ + public boolean hasChildByDeptId(Long deptId); + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 true 存在 false 不存在 + */ + public boolean checkDeptExistUser(Long deptId); + + /** + * 校验部门名称是否唯一 + * + * @param dept 部门信息 + * @return 结果 + */ + public boolean checkDeptNameUnique(UDept dept); + + /** + * 校验部门是否有数据权限 + * + * @param deptId 部门id + */ + public void checkDeptDataScope(Long deptId); + + /** + * 新增保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int insertDept(UDept dept); + + /** + * 修改保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int updateDept(UDept dept); + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictDataService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictDataService.java new file mode 100644 index 0000000..2495a84 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictDataService.java @@ -0,0 +1,61 @@ +package org.wfc.user.service; + +import org.wfc.user.api.domain.UDictData; + +import java.util.List; + +/** + * 字典 业务层 + * + * @author wfc + */ +public interface IUDictDataService +{ + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(UDictData dictData); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(String dictType, String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public UDictData selectDictDataById(Long dictCode); + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + */ + public void deleteDictDataByIds(Long[] dictCodes); + + /** + * 新增保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(UDictData dictData); + + /** + * 修改保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(UDictData dictData); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictTypeService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictTypeService.java new file mode 100644 index 0000000..02c1146 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUDictTypeService.java @@ -0,0 +1,99 @@ +package org.wfc.user.service; + +import org.wfc.user.api.domain.UDictData; +import org.wfc.user.api.domain.UDictType; + +import java.util.List; + +/** + * 字典 业务层 + * + * @author wfc + */ +public interface IUDictTypeService +{ + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(UDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public UDictType selectDictTypeById(Long dictId); + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + public UDictType selectDictTypeByType(String dictType); + + /** + * 批量删除字典信息 + * + * @param dictIds 需要删除的字典ID + */ + public void deleteDictTypeByIds(Long[] dictIds); + + /** + * 加载字典缓存数据 + */ + public void loadingDictCache(); + + /** + * 清空字典缓存数据 + */ + public void clearDictCache(); + + /** + * 重置字典缓存数据 + */ + public void resetDictCache(); + + /** + * 新增保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(UDictType dictType); + + /** + * 修改保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(UDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public boolean checkDictTypeUnique(UDictType dictType); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IULogininforService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IULogininforService.java new file mode 100644 index 0000000..9c48180 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IULogininforService.java @@ -0,0 +1,41 @@ +package org.wfc.user.service; + +import org.wfc.user.api.domain.ULogininfor; + +import java.util.List; + +/** + * 系统访问日志情况信息 服务层 + * + * @author wfc + */ +public interface IULogininforService +{ + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + public int insertLogininfor(ULogininfor logininfor); + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + public List selectLogininforList(ULogininfor logininfor); + + /** + * 批量删除系统登录日志 + * + * @param infoIds 需要删除的登录日志ID + * @return 结果 + */ + public int deleteLogininforByIds(Long[] infoIds); + + /** + * 清空系统登录日志 + */ + public void cleanLogininfor(); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUMenuService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUMenuService.java new file mode 100644 index 0000000..9c04b74 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUMenuService.java @@ -0,0 +1,145 @@ +package org.wfc.user.service; + +import org.wfc.user.domain.UMenu; +import org.wfc.user.domain.vo.RouterVo; +import org.wfc.user.domain.vo.TreeSelect; + +import java.util.List; +import java.util.Set; + +/** + * 菜单 业务层 + * + * @author wfc + */ +public interface IUMenuService +{ + /** + * 根据用户查询系统菜单列表 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuList(Long userId); + + /** + * 根据用户查询系统菜单列表 + * + * @param menu 菜单信息 + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuList(UMenu menu, Long userId); + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Set selectMenuPermsByUserId(Long userId); + + /** + * 根据角色ID查询权限 + * + * @param roleId 角色ID + * @return 权限列表 + */ + public Set selectMenuPermsByRoleId(Long roleId); + + /** + * 根据用户ID查询菜单树信息 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuTreeByUserId(Long userId); + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @return 选中菜单列表 + */ + public List selectMenuListByRoleId(Long roleId); + + /** + * 构建前端路由所需要的菜单 + * + * @param menus 菜单列表 + * @return 路由列表 + */ + public List buildMenus(List menus); + + /** + * 构建前端所需要树结构 + * + * @param menus 菜单列表 + * @return 树结构列表 + */ + public List buildMenuTree(List menus); + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + public List buildMenuTreeSelect(List menus); + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + public UMenu selectMenuById(Long menuId); + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + public boolean hasChildByMenuId(Long menuId); + + /** + * 查询菜单是否存在角色 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + public boolean checkMenuExistRole(Long menuId); + + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int insertMenu(UMenu menu); + + /** + * 修改保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int updateMenu(UMenu menu); + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int deleteMenuById(Long menuId); + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + public boolean checkMenuNameUnique(UMenu menu); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUOperLogService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUOperLogService.java new file mode 100644 index 0000000..8b36884 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUOperLogService.java @@ -0,0 +1,50 @@ +package org.wfc.user.service; + +import org.wfc.user.api.domain.UOperLog; + +import java.util.List; + +/** + * 操作日志 服务层 + * + * @author wfc + */ +public interface IUOperLogService +{ + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + * @return 结果 + */ + public int insertOperlog(UOperLog operLog); + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + public List selectOperLogList(UOperLog operLog); + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + public int deleteOperLogByIds(Long[] operIds); + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + public UOperLog selectOperLogById(Long operId); + + /** + * 清空操作日志 + */ + public void cleanOperLog(); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPermissionService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPermissionService.java new file mode 100644 index 0000000..b7234f4 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPermissionService.java @@ -0,0 +1,29 @@ +package org.wfc.user.service; + +import org.wfc.user.api.domain.UUser; + +import java.util.Set; + +/** + * 权限信息 服务层 + * + * @author wfc + */ +public interface IUPermissionService +{ + /** + * 获取角色数据权限 + * + * @param user 用户 + * @return 角色权限信息 + */ + public Set getRolePermission(UUser user); + + /** + * 获取菜单数据权限 + * + * @param user 用户Id + * @return 菜单权限信息 + */ + public Set getMenuPermission(UUser user); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPostService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPostService.java new file mode 100644 index 0000000..33ae3ea --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUPostService.java @@ -0,0 +1,100 @@ +package org.wfc.user.service; + +import org.wfc.user.domain.UPost; + +import java.util.List; + +/** + * 岗位信息 服务层 + * + * @author wfc + */ +public interface IUPostService +{ + /** + * 查询岗位信息集合 + * + * @param post 岗位信息 + * @return 岗位列表 + */ + public List selectPostList(UPost post); + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + public List selectPostAll(); + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + public UPost selectPostById(Long postId); + + /** + * 根据用户ID获取岗位选择框列表 + * + * @param userId 用户ID + * @return 选中岗位ID列表 + */ + public List selectPostListByUserId(Long userId); + + /** + * 校验岗位名称 + * + * @param post 岗位信息 + * @return 结果 + */ + public boolean checkPostNameUnique(UPost post); + + /** + * 校验岗位编码 + * + * @param post 岗位信息 + * @return 结果 + */ + public boolean checkPostCodeUnique(UPost post); + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + public int countUserPostById(Long postId); + + /** + * 删除岗位信息 + * + * @param postId 岗位ID + * @return 结果 + */ + public int deletePostById(Long postId); + + /** + * 批量删除岗位信息 + * + * @param postIds 需要删除的岗位ID + * @return 结果 + */ + public int deletePostByIds(Long[] postIds); + + /** + * 新增保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int insertPost(UPost post); + + /** + * 修改保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int updatePost(UPost post); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IURoleService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IURoleService.java new file mode 100644 index 0000000..271fab1 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IURoleService.java @@ -0,0 +1,176 @@ +package org.wfc.user.service; + + + +import org.wfc.user.api.domain.URole; +import org.wfc.user.domain.UUserRole; + +import java.util.List; +import java.util.Set; + +/** + * 角色业务层 + * + * @author wfc + */ +public interface IURoleService +{ + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + public List selectRoleList(URole role); + + /** + * 根据用户ID查询角色列表 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolesByUserId(Long userId); + + /** + * 根据用户ID查询角色权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Set selectRolePermissionByUserId(Long userId); + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectRoleAll(); + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + public List selectRoleListByUserId(Long userId); + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + public URole selectRoleById(Long roleId); + + /** + * 校验角色名称是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + public boolean checkRoleNameUnique(URole role); + + /** + * 校验角色权限是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + public boolean checkRoleKeyUnique(URole role); + + /** + * 校验角色是否允许操作 + * + * @param role 角色信息 + */ + public void checkRoleAllowed(URole role); + + /** + * 校验角色是否有数据权限 + * + * @param roleIds 角色id + */ + public void checkRoleDataScope(Long... roleIds); + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + public int countUserRoleByRoleId(Long roleId); + + /** + * 新增保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int insertRole(URole role); + + /** + * 修改保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRole(URole role); + + /** + * 修改角色状态 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRoleStatus(URole role); + + /** + * 修改数据权限信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int authDataScope(URole role); + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleById(Long roleId); + + /** + * 批量删除角色信息 + * + * @param roleIds 需要删除的角色ID + * @return 结果 + */ + public int deleteRoleByIds(Long[] roleIds); + + /** + * 取消授权用户角色 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + public int deleteAuthUser(UUserRole userRole); + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要取消授权的用户数据ID + * @return 结果 + */ + public int deleteAuthUsers(Long roleId, Long[] userIds); + + /** + * 批量选择授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int insertAuthUsers(Long roleId, Long[] userIds); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserOnlineService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserOnlineService.java new file mode 100644 index 0000000..b98c9b1 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserOnlineService.java @@ -0,0 +1,48 @@ +package org.wfc.user.service; + +import org.wfc.common.core.domain.LoginUser; +import org.wfc.user.domain.UUserOnline; + +/** + * 在线用户 服务层 + * + * @author wfc + */ +public interface IUUserOnlineService +{ + /** + * 通过登录地址查询信息 + * + * @param ipaddr 登录地址 + * @param user 用户信息 + * @return 在线用户信息 + */ + public UUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user); + + /** + * 通过用户名称查询信息 + * + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + public UUserOnline selectOnlineByUserName(String userName, LoginUser user); + + /** + * 通过登录地址/用户名称查询信息 + * + * @param ipaddr 登录地址 + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + public UUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user); + + /** + * 设置在线用户信息 + * + * @param user 用户信息 + * @return 在线用户 + */ + public UUserOnline loginUserToUserOnline(LoginUser user); +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserService.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserService.java index b9a7a51..73f9648 100644 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserService.java +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/IUUserService.java @@ -1,61 +1,207 @@ package org.wfc.user.service; +import org.wfc.user.api.domain.UUser; + import java.util.List; -import org.wfc.user.domain.UUser; /** - * 用户平台_用户信息Service接口 - * + * 用户 业务层 + * * @author wfc - * @date 2024-11-25 */ public interface IUUserService { /** - * 查询用户平台_用户信息 - * - * @param userId 用户平台_用户信息主键 - * @return 用户平台_用户信息 + * 根据条件分页查询用户列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 */ - public UUser selectUUserByUserId(Long userId); + public List selectUserList(UUser user); /** - * 查询用户平台_用户信息列表 - * - * @param uUser 用户平台_用户信息 - * @return 用户平台_用户信息集合 + * 根据条件分页查询已分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 */ - public List selectUUserList(UUser uUser); + public List selectAllocatedList(UUser user); /** - * 新增用户平台_用户信息 - * - * @param uUser 用户平台_用户信息 + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUnallocatedList(UUser user); + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + public UUser selectUserByUserName(String userName); + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + public UUser selectUserById(Long userId); + + /** + * 根据用户ID查询用户所属角色组 + * + * @param userName 用户名 * @return 结果 */ - public int insertUUser(UUser uUser); + public String selectUserRoleGroup(String userName); /** - * 修改用户平台_用户信息 - * - * @param uUser 用户平台_用户信息 + * 根据用户ID查询用户所属岗位组 + * + * @param userName 用户名 * @return 结果 */ - public int updateUUser(UUser uUser); + public String selectUserPostGroup(String userName); /** - * 批量删除用户平台_用户信息 - * - * @param userIds 需要删除的用户平台_用户信息主键集合 + * 校验用户名称是否唯一 + * + * @param user 用户信息 * @return 结果 */ - public int deleteUUserByUserIds(Long[] userIds); + public boolean checkUserNameUnique(UUser user); /** - * 删除用户平台_用户信息信息 + * 校验手机号码是否唯一 * - * @param userId 用户平台_用户信息主键 + * @param user 用户信息 * @return 结果 */ - public int deleteUUserByUserId(Long userId); + public boolean checkPhoneUnique(UUser user); + + /** + * 校验email是否唯一 + * + * @param user 用户信息 + * @return 结果 + */ + public boolean checkEmailUnique(UUser user); + + /** + * 校验用户是否允许操作 + * + * @param user 用户信息 + */ + public void checkUserAllowed(UUser user); + + /** + * 校验用户是否有数据权限 + * + * @param userId 用户id + */ + public void checkUserDataScope(Long userId); + + /** + * 新增用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int insertUser(UUser user); + + /** + * 注册用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public boolean registerUser(UUser user); + + /** + * 修改用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUser(UUser user); + + /** + * 用户授权角色 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + public void insertUserAuth(Long userId, Long[] roleIds); + + /** + * 修改用户状态 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUserStatus(UUser user); + + /** + * 修改用户基本信息 + * + * @param user 用户信息 + * @return 结果 + */ + public boolean updateUserProfile(UUser user); + + /** + * 修改用户头像 + * + * @param userName 用户名 + * @param avatar 头像地址 + * @return 结果 + */ + public boolean updateUserAvatar(String userName, String avatar); + + /** + * 重置用户密码 + * + * @param user 用户信息 + * @return 结果 + */ + public int resetPwd(UUser user); + + /** + * 重置用户密码 + * + * @param userName 用户名 + * @param password 密码 + * @return 结果 + */ + public int resetUserPwd(String userName, String password); + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserById(Long userId); + + /** + * 批量删除用户信息 + * + * @param userIds 需要删除的用户ID + * @return 结果 + */ + public int deleteUserByIds(Long[] userIds); + + /** + * 导入用户数据 + * + * @param userList 用户数据列表 + * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @return 结果 + */ + public String importUser(List userList, Boolean isUpdateSupport, String operName); } diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/UUserServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/UUserServiceImpl.java deleted file mode 100644 index 2bef70d..0000000 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/UUserServiceImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.wfc.user.service.impl; - -import java.util.List; -import org.wfc.common.core.utils.DateUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.wfc.user.mapper.UUserMapper; -import org.wfc.user.domain.UUser; -import org.wfc.user.service.IUUserService; - -/** - * 用户平台_用户信息Service业务层处理 - * - * @author wfc - * @date 2024-11-25 - */ -@Service -public class UUserServiceImpl implements IUUserService -{ - @Autowired - private UUserMapper uUserMapper; - - /** - * 查询用户平台_用户信息 - * - * @param userId 用户平台_用户信息主键 - * @return 用户平台_用户信息 - */ - @Override - public UUser selectUUserByUserId(Long userId) - { - return uUserMapper.selectUUserByUserId(userId); - } - - /** - * 查询用户平台_用户信息列表 - * - * @param uUser 用户平台_用户信息 - * @return 用户平台_用户信息 - */ - @Override - public List selectUUserList(UUser uUser) - { - return uUserMapper.selectUUserList(uUser); - } - - /** - * 新增用户平台_用户信息 - * - * @param uUser 用户平台_用户信息 - * @return 结果 - */ - @Override - public int insertUUser(UUser uUser) - { - uUser.setCreateTime(DateUtils.getNowDate()); - return uUserMapper.insertUUser(uUser); - } - - /** - * 修改用户平台_用户信息 - * - * @param uUser 用户平台_用户信息 - * @return 结果 - */ - @Override - public int updateUUser(UUser uUser) - { - uUser.setUpdateTime(DateUtils.getNowDate()); - return uUserMapper.updateUUser(uUser); - } - - /** - * 批量删除用户平台_用户信息 - * - * @param userIds 需要删除的用户平台_用户信息主键 - * @return 结果 - */ - @Override - public int deleteUUserByUserIds(Long[] userIds) - { - return uUserMapper.deleteUUserByUserIds(userIds); - } - - /** - * 删除用户平台_用户信息信息 - * - * @param userId 用户平台_用户信息主键 - * @return 结果 - */ - @Override - public int deleteUUserByUserId(Long userId) - { - return uUserMapper.deleteUUserByUserId(userId); - } -} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UConfigServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UConfigServiceImpl.java new file mode 100644 index 0000000..39be59f --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UConfigServiceImpl.java @@ -0,0 +1,214 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.wfc.common.core.constant.CacheConstants; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.exception.ServiceException; +import org.wfc.common.core.text.Convert; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.redis.service.RedisService; +import org.wfc.user.domain.UConfig; +import org.wfc.user.mapper.UConfigMapper; +import org.wfc.user.service.IUConfigService; + +import javax.annotation.PostConstruct; +import java.util.Collection; +import java.util.List; + +/** + * 参数配置 服务层实现 + * + * @author wfc + */ +@Service +public class UConfigServiceImpl implements IUConfigService +{ + @Autowired + private UConfigMapper configMapper; + + @Autowired + private RedisService redisService; + + /** + * 项目启动时,初始化参数到缓存 + */ + @PostConstruct + public void init() + { + loadingConfigCache(); + } + + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + @Override + public UConfig selectConfigById(Long configId) + { + UConfig config = new UConfig(); + config.setConfigId(configId); + return configMapper.selectConfig(config); + } + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数key + * @return 参数键值 + */ + @Override + public String selectConfigByKey(String configKey) + { + String configValue = Convert.toStr(redisService.getCacheObject(getCacheKey(configKey))); + if (StringUtils.isNotEmpty(configValue)) + { + return configValue; + } + UConfig config = new UConfig(); + config.setConfigKey(configKey); + UConfig retConfig = configMapper.selectConfig(config); + if (StringUtils.isNotNull(retConfig)) + { + redisService.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); + return retConfig.getConfigValue(); + } + return StringUtils.EMPTY; + } + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + @Override + public List selectConfigList(UConfig config) + { + return configMapper.selectConfigList(config); + } + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int insertConfig(UConfig config) + { + int row = configMapper.insertConfig(config); + if (row > 0) + { + redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int updateConfig(UConfig config) + { + UConfig temp = configMapper.selectConfigById(config.getConfigId()); + if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) + { + redisService.deleteObject(getCacheKey(temp.getConfigKey())); + } + + int row = configMapper.updateConfig(config); + if (row > 0) + { + redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + */ + @Override + public void deleteConfigByIds(Long[] configIds) + { + for (Long configId : configIds) + { + UConfig config = selectConfigById(configId); + if (StringUtils.equals(UserConstants.YES, config.getConfigType())) + { + throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); + } + configMapper.deleteConfigById(configId); + redisService.deleteObject(getCacheKey(config.getConfigKey())); + } + } + + /** + * 加载参数缓存数据 + */ + @Override + public void loadingConfigCache() + { + List configsList = configMapper.selectConfigList(new UConfig()); + for (UConfig config : configsList) + { + redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + } + + /** + * 清空参数缓存数据 + */ + @Override + public void clearConfigCache() + { + Collection keys = redisService.keys(CacheConstants.SYS_CONFIG_KEY + "*"); + redisService.deleteObject(keys); + } + + /** + * 重置参数缓存数据 + */ + @Override + public void resetConfigCache() + { + clearConfigCache(); + loadingConfigCache(); + } + + /** + * 校验参数键名是否唯一 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public boolean checkConfigKeyUnique(UConfig config) + { + Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); + UConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey()); + if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + private String getCacheKey(String configKey) + { + return CacheConstants.SYS_CONFIG_KEY + configKey; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDeptServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDeptServiceImpl.java new file mode 100644 index 0000000..2f587cd --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDeptServiceImpl.java @@ -0,0 +1,337 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.exception.ServiceException; +import org.wfc.common.core.text.Convert; +import org.wfc.common.core.utils.SpringUtils; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.UDept; +import org.wfc.user.api.domain.URole; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.domain.vo.TreeSelect; +import org.wfc.user.mapper.UDeptMapper; +import org.wfc.user.mapper.URoleMapper; +import org.wfc.user.service.IUDeptService; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 部门管理 服务实现 + * + * @author wfc + */ +@Service +public class UDeptServiceImpl implements IUDeptService +{ + @Autowired + private UDeptMapper deptMapper; + + @Autowired + private URoleMapper roleMapper; + + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + @Override + public List selectDeptList(UDept dept) + { + return deptMapper.selectDeptList(dept); + } + + /** + * 查询部门树结构信息 + * + * @param dept 部门信息 + * @return 部门树信息集合 + */ + @Override + public List selectDeptTreeList(UDept dept) + { + List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + return buildDeptTreeSelect(depts); + } + + /** + * 构建前端所需要树结构 + * + * @param depts 部门列表 + * @return 树结构列表 + */ + @Override + public List buildDeptTree(List depts) + { + List returnList = new ArrayList(); + List tempList = depts.stream().map(UDept::getDeptId).collect(Collectors.toList()); + for (UDept dept : depts) + { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(dept.getParentId())) + { + recursionFn(depts, dept); + returnList.add(dept); + } + } + if (returnList.isEmpty()) + { + returnList = depts; + } + return returnList; + } + + /** + * 构建前端所需要下拉树结构 + * + * @param depts 部门列表 + * @return 下拉树结构列表 + */ + @Override + public List buildDeptTreeSelect(List depts) + { + List deptTrees = buildDeptTree(depts); + return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + /** + * 根据角色ID查询部门树信息 + * + * @param roleId 角色ID + * @return 选中部门列表 + */ + @Override + public List selectDeptListByRoleId(Long roleId) + { + URole role = roleMapper.selectRoleById(roleId); + return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); + } + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + @Override + public UDept selectDeptById(Long deptId) + { + return deptMapper.selectDeptById(deptId); + } + + /** + * 根据ID查询所有子部门(正常状态) + * + * @param deptId 部门ID + * @return 子部门数 + */ + @Override + public int selectNormalChildrenDeptById(Long deptId) + { + return deptMapper.selectNormalChildrenDeptById(deptId); + } + + /** + * 是否存在子节点 + * + * @param deptId 部门ID + * @return 结果 + */ + @Override + public boolean hasChildByDeptId(Long deptId) + { + int result = deptMapper.hasChildByDeptId(deptId); + return result > 0; + } + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 true 存在 false 不存在 + */ + @Override + public boolean checkDeptExistUser(Long deptId) + { + int result = deptMapper.checkDeptExistUser(deptId); + return result > 0; + } + + /** + * 校验部门名称是否唯一 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public boolean checkDeptNameUnique(UDept dept) + { + Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); + UDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); + if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验部门是否有数据权限 + * + * @param deptId 部门id + */ + @Override + public void checkDeptDataScope(Long deptId) + { + if (!UUser.isAdmin(SecurityUtils.getUserId()) && StringUtils.isNotNull(deptId)) + { + UDept dept = new UDept(); + dept.setDeptId(deptId); + List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + if (StringUtils.isEmpty(depts)) + { + throw new ServiceException("没有权限访问部门数据!"); + } + } + } + + /** + * 新增保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public int insertDept(UDept dept) + { + UDept info = deptMapper.selectDeptById(dept.getParentId()); + // 如果父节点不为正常状态,则不允许新增子节点 + if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) + { + throw new ServiceException("部门停用,不允许新增"); + } + dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + return deptMapper.insertDept(dept); + } + + /** + * 修改保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public int updateDept(UDept dept) + { + UDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); + UDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); + if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) + { + String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); + String oldAncestors = oldDept.getAncestors(); + dept.setAncestors(newAncestors); + updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); + } + int result = deptMapper.updateDept(dept); + if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) + && !StringUtils.equals("0", dept.getAncestors())) + { + // 如果该部门是启用状态,则启用该部门的所有上级部门 + updateParentDeptStatusNormal(dept); + } + return result; + } + + /** + * 修改该部门的父级部门状态 + * + * @param dept 当前部门 + */ + private void updateParentDeptStatusNormal(UDept dept) + { + String ancestors = dept.getAncestors(); + Long[] deptIds = Convert.toLongArray(ancestors); + deptMapper.updateDeptStatusNormal(deptIds); + } + + /** + * 修改子元素关系 + * + * @param deptId 被修改的部门ID + * @param newAncestors 新的父ID集合 + * @param oldAncestors 旧的父ID集合 + */ + public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) + { + List children = deptMapper.selectChildrenDeptById(deptId); + for (UDept child : children) + { + child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); + } + if (children.size() > 0) + { + deptMapper.updateDeptChildren(children); + } + } + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + @Override + public int deleteDeptById(Long deptId) + { + return deptMapper.deleteDeptById(deptId); + } + + /** + * 递归列表 + */ + private void recursionFn(List list, UDept t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (UDept tChild : childList) + { + if (hasChild(list, tChild)) + { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, UDept t) + { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) + { + UDept n = (UDept) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) + { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, UDept t) + { + return getChildList(list, t).size() > 0 ? true : false; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictDataServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictDataServiceImpl.java new file mode 100644 index 0000000..ef18547 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictDataServiceImpl.java @@ -0,0 +1,112 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.wfc.common.security.utils.DictUtils; +import org.wfc.user.api.domain.UDictData; +import org.wfc.user.mapper.UDictDataMapper; +import org.wfc.user.service.IUDictDataService; + +import java.util.List; + +/** + * 字典 业务层处理 + * + * @author wfc + */ +@Service +public class UDictDataServiceImpl implements IUDictDataService +{ + @Autowired + private UDictDataMapper dictDataMapper; + + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataList(UDictData dictData) + { + return dictDataMapper.selectDictDataList(dictData); + } + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + @Override + public String selectDictLabel(String dictType, String dictValue) + { + return dictDataMapper.selectDictLabel(dictType, dictValue); + } + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + @Override + public UDictData selectDictDataById(Long dictCode) + { + return dictDataMapper.selectDictDataById(dictCode); + } + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + */ + @Override + public void deleteDictDataByIds(Long[] dictCodes) + { + for (Long dictCode : dictCodes) + { + UDictData data = selectDictDataById(dictCode); + dictDataMapper.deleteDictDataById(dictCode); + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + } + + /** + * 新增保存字典数据信息 + * + * @param data 字典数据信息 + * @return 结果 + */ + @Override + public int insertDictData(UDictData data) + { + int row = dictDataMapper.insertDictData(data); + if (row > 0) + { + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + return row; + } + + /** + * 修改保存字典数据信息 + * + * @param data 字典数据信息 + * @return 结果 + */ + @Override + public int updateDictData(UDictData data) + { + int row = dictDataMapper.updateDictData(data); + if (row > 0) + { + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + return row; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictTypeServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictTypeServiceImpl.java new file mode 100644 index 0000000..31ae974 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UDictTypeServiceImpl.java @@ -0,0 +1,224 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.exception.ServiceException; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.security.utils.DictUtils; +import org.wfc.user.api.domain.UDictData; +import org.wfc.user.api.domain.UDictType; +import org.wfc.user.mapper.UDictDataMapper; +import org.wfc.user.mapper.UDictTypeMapper; +import org.wfc.user.service.IUDictTypeService; + +import javax.annotation.PostConstruct; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 字典 业务层处理 + * + * @author wfc + */ +@Service +public class UDictTypeServiceImpl implements IUDictTypeService +{ + @Autowired + private UDictTypeMapper dictTypeMapper; + + @Autowired + private UDictDataMapper dictDataMapper; + + /** + * 项目启动时,初始化字典到缓存 + */ + @PostConstruct + public void init() + { + loadingDictCache(); + } + + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeList(UDictType dictType) + { + return dictTypeMapper.selectDictTypeList(dictType); + } + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeAll() + { + return dictTypeMapper.selectDictTypeAll(); + } + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataByType(String dictType) + { + List dictDatas = DictUtils.getDictCache(dictType, UDictData.class); + if (StringUtils.isNotEmpty(dictDatas)) + { + return dictDatas; + } + dictDatas = dictDataMapper.selectDictDataByType(dictType); + if (StringUtils.isNotEmpty(dictDatas)) + { + DictUtils.setDictCache(dictType, dictDatas); + return dictDatas; + } + return null; + } + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + @Override + public UDictType selectDictTypeById(Long dictId) + { + return dictTypeMapper.selectDictTypeById(dictId); + } + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + @Override + public UDictType selectDictTypeByType(String dictType) + { + return dictTypeMapper.selectDictTypeByType(dictType); + } + + /** + * 批量删除字典类型信息 + * + * @param dictIds 需要删除的字典ID + */ + @Override + public void deleteDictTypeByIds(Long[] dictIds) + { + for (Long dictId : dictIds) + { + UDictType dictType = selectDictTypeById(dictId); + if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) + { + throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName())); + } + dictTypeMapper.deleteDictTypeById(dictId); + DictUtils.removeDictCache(dictType.getDictType()); + } + } + + /** + * 加载字典缓存数据 + */ + @Override + public void loadingDictCache() + { + UDictData dictData = new UDictData(); + dictData.setStatus("0"); + Map> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream().collect(Collectors.groupingBy(UDictData::getDictType)); + for (Map.Entry> entry : dictDataMap.entrySet()) + { + DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(UDictData::getDictSort)).collect(Collectors.toList())); + } + } + + /** + * 清空字典缓存数据 + */ + @Override + public void clearDictCache() + { + DictUtils.clearDictCache(); + } + + /** + * 重置字典缓存数据 + */ + @Override + public void resetDictCache() + { + clearDictCache(); + loadingDictCache(); + } + + /** + * 新增保存字典类型信息 + * + * @param dict 字典类型信息 + * @return 结果 + */ + @Override + public int insertDictType(UDictType dict) + { + int row = dictTypeMapper.insertDictType(dict); + if (row > 0) + { + DictUtils.setDictCache(dict.getDictType(), null); + } + return row; + } + + /** + * 修改保存字典类型信息 + * + * @param dict 字典类型信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateDictType(UDictType dict) + { + UDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId()); + dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType()); + int row = dictTypeMapper.updateDictType(dict); + if (row > 0) + { + List dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); + DictUtils.setDictCache(dict.getDictType(), dictDatas); + } + return row; + } + + /** + * 校验字典类型称是否唯一 + * + * @param dict 字典类型 + * @return 结果 + */ + @Override + public boolean checkDictTypeUnique(UDictType dict) + { + Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); + UDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); + if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/ULogininforServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/ULogininforServiceImpl.java new file mode 100644 index 0000000..186c198 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/ULogininforServiceImpl.java @@ -0,0 +1,66 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.wfc.user.api.domain.ULogininfor; +import org.wfc.user.mapper.ULogininforMapper; +import org.wfc.user.service.IULogininforService; + +import java.util.List; + +/** + * 系统访问日志情况信息 服务层处理 + * + * @author wfc + */ +@Service +public class ULogininforServiceImpl implements IULogininforService +{ + + @Autowired + private ULogininforMapper logininforMapper; + + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + @Override + public int insertLogininfor(ULogininfor logininfor) + { + return logininforMapper.insertLogininfor(logininfor); + } + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + @Override + public List selectLogininforList(ULogininfor logininfor) + { + return logininforMapper.selectLogininforList(logininfor); + } + + /** + * 批量删除系统登录日志 + * + * @param infoIds 需要删除的登录日志ID + * @return 结果 + */ + @Override + public int deleteLogininforByIds(Long[] infoIds) + { + return logininforMapper.deleteLogininforByIds(infoIds); + } + + /** + * 清空系统登录日志 + */ + @Override + public void cleanLogininfor() + { + logininforMapper.cleanLogininfor(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UMenuServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UMenuServiceImpl.java new file mode 100644 index 0000000..6f633c0 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UMenuServiceImpl.java @@ -0,0 +1,516 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.wfc.common.core.constant.Constants; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.URole; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.domain.UMenu; +import org.wfc.user.domain.vo.MetaVo; +import org.wfc.user.domain.vo.RouterVo; +import org.wfc.user.domain.vo.TreeSelect; +import org.wfc.user.mapper.UMenuMapper; +import org.wfc.user.mapper.URoleMapper; +import org.wfc.user.mapper.URoleMenuMapper; +import org.wfc.user.service.IUMenuService; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 菜单 业务层处理 + * + * @author wfc + */ +@Service +public class UMenuServiceImpl implements IUMenuService +{ + public static final String PREMISSION_STRING = "perms[\"{0}\"]"; + + @Autowired + private UMenuMapper menuMapper; + + @Autowired + private URoleMapper roleMapper; + + @Autowired + private URoleMenuMapper roleMenuMapper; + + /** + * 根据用户查询系统菜单列表 + * + * @param userId 用户ID + * @return 菜单列表 + */ + @Override + public List selectMenuList(Long userId) + { + return selectMenuList(new UMenu(), userId); + } + + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + @Override + public List selectMenuList(UMenu menu, Long userId) + { + List menuList; + // 管理员显示所有菜单信息 + if (UUser.isAdmin(userId)) + { + menuList = menuMapper.selectMenuList(menu); + } + else + { + menu.getParams().put("userId", userId); + menuList = menuMapper.selectMenuListByUserId(menu); + } + return menuList; + } + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + @Override + public Set selectMenuPermsByUserId(Long userId) + { + List perms = menuMapper.selectMenuPermsByUserId(userId); + Set permsSet = new HashSet<>(); + for (String perm : perms) + { + if (StringUtils.isNotEmpty(perm)) + { + permsSet.addAll(Arrays.asList(perm.trim().split(","))); + } + } + return permsSet; + } + + /** + * 根据角色ID查询权限 + * + * @param roleId 角色ID + * @return 权限列表 + */ + @Override + public Set selectMenuPermsByRoleId(Long roleId) + { + List perms = menuMapper.selectMenuPermsByRoleId(roleId); + Set permsSet = new HashSet<>(); + for (String perm : perms) + { + if (StringUtils.isNotEmpty(perm)) + { + permsSet.addAll(Arrays.asList(perm.trim().split(","))); + } + } + return permsSet; + } + + /** + * 根据用户ID查询菜单 + * + * @param userId 用户名称 + * @return 菜单列表 + */ + @Override + public List selectMenuTreeByUserId(Long userId) + { + List menus = null; + if (SecurityUtils.isAdmin(userId)) + { + menus = menuMapper.selectMenuTreeAll(); + } + else + { + menus = menuMapper.selectMenuTreeByUserId(userId); + } + return getChildPerms(menus, 0); + } + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @return 选中菜单列表 + */ + @Override + public List selectMenuListByRoleId(Long roleId) + { + URole role = roleMapper.selectRoleById(roleId); + return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); + } + + /** + * 构建前端路由所需要的菜单 + * + * @param menus 菜单列表 + * @return 路由列表 + */ + @Override + public List buildMenus(List menus) + { + List routers = new LinkedList<>(); + for (UMenu menu : menus) + { + RouterVo router = new RouterVo(); + router.setHideInMenu("1".equals(menu.getVisible())); + router.setName(menu.getName()); + router.setPath(getRouterPath(menu)); + router.setComponent(getComponent(menu)); + router.setQuery(menu.getQuery()); + router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); + List cMenus = menu.getChildren(); + if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) + { + router.setAlwaysShow(true); + router.setRedirect("noRedirect"); + router.setChildren(buildMenus(cMenus)); + } + else if (isMenuFrame(menu)) + { + router.setMeta(null); + List childrenList = new ArrayList(); + RouterVo children = new RouterVo(); + children.setPath(menu.getPath()); + children.setComponent(menu.getComponent()); + children.setName(menu.getName()); + children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); + children.setQuery(menu.getQuery()); + childrenList.add(children); + router.setChildren(childrenList); + } + else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) + { + router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon())); + router.setPath("/"); + List childrenList = new ArrayList(); + RouterVo children = new RouterVo(); + String routerPath = innerLinkReplaceEach(menu.getPath()); + children.setPath(routerPath); + children.setComponent(UserConstants.INNER_LINK); + children.setName(menu.getName()); + children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath())); + childrenList.add(children); + router.setChildren(childrenList); + } + routers.add(router); + } + return routers; + } + + /** + * 构建前端所需要树结构 + * + * @param menus 菜单列表 + * @return 树结构列表 + */ + @Override + public List buildMenuTree(List menus) + { + List returnList = new ArrayList<>(); + List tempList = menus.stream().map(UMenu::getMenuId).collect(Collectors.toList()); + for (UMenu menu : menus) { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(menu.getParentId())) { + recursionFn(menus, menu); + returnList.add(menu); + } + } + if (returnList.isEmpty()) + { + returnList = menus; + } + return returnList; + } + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + @Override + public List buildMenuTreeSelect(List menus) + { + List menuTrees = buildMenuTree(menus); + return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + @Override + public UMenu selectMenuById(Long menuId) + { + return menuMapper.selectMenuById(menuId); + } + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public boolean hasChildByMenuId(Long menuId) + { + int result = menuMapper.hasChildByMenuId(menuId); + return result > 0; + } + + /** + * 查询菜单使用数量 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public boolean checkMenuExistRole(Long menuId) + { + int result = roleMenuMapper.checkMenuExistRole(menuId); + return result > 0; + } + + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int insertMenu(UMenu menu) + { + return menuMapper.insertMenu(menu); + } + + /** + * 修改保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int updateMenu(UMenu menu) + { + return menuMapper.updateMenu(menu); + } + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public int deleteMenuById(Long menuId) + { + return menuMapper.deleteMenuById(menuId); + } + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public boolean checkMenuNameUnique(UMenu menu) + { + Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); + UMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); + if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 获取路由名称 + * + * @param menu 菜单信息 + * @return 路由名称 + */ + public String getRouteName(UMenu menu) + { + String routerName = StringUtils.capitalize(menu.getName()); + // 非外链并且是一级目录(类型为目录) + if (isMenuFrame(menu)) + { + routerName = StringUtils.EMPTY; + } + return routerName; + } + + /** + * 获取路由地址 + * + * @param menu 菜单信息 + * @return 路由地址 + */ + public String getRouterPath(UMenu menu) + { + String routerPath = menu.getPath(); + // 内链打开外网方式 + if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) + { + routerPath = innerLinkReplaceEach(routerPath); + } + // 非外链并且是一级目录(类型为目录) + if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) + && UserConstants.NO_FRAME.equals(menu.getIsFrame())) + { + routerPath = menu.getPath(); + } + // 非外链并且是一级目录(类型为菜单) + else if (isMenuFrame(menu)) + { + routerPath = "/"; + } + return routerPath; + } + + /** + * 获取组件信息 + * + * @param menu 菜单信息 + * @return 组件信息 + */ + public String getComponent(UMenu menu) + { + String component = UserConstants.LAYOUT; + if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) + { + component = menu.getComponent(); + } + else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) + { + component = UserConstants.INNER_LINK; + } + else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) + { + component = UserConstants.PARENT_VIEW; + } + return component; + } + + /** + * 是否为菜单内部跳转 + * + * @param menu 菜单信息 + * @return 结果 + */ + public boolean isMenuFrame(UMenu menu) + { + return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType()) + && menu.getIsFrame().equals(UserConstants.NO_FRAME); + } + + /** + * 是否为内链组件 + * + * @param menu 菜单信息 + * @return 结果 + */ + public boolean isInnerLink(UMenu menu) + { + return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath()); + } + + /** + * 是否为parent_view组件 + * + * @param menu 菜单信息 + * @return 结果 + */ + public boolean isParentView(UMenu menu) + { + return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()); + } + + /** + * 根据父节点的ID获取所有子节点 + * + * @param list 分类表 + * @param parentId 传入的父节点ID + * @return String + */ + public List getChildPerms(List list, int parentId) + { + List returnList = new ArrayList<>(); + for (UMenu t : list) { + // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 + if (t.getParentId() == parentId) { + recursionFn(list, t); + returnList.add(t); + } + } + return returnList; + } + + /** + * 递归列表 + * + * @param list 分类表 + * @param t 子节点 + */ + private void recursionFn(List list, UMenu t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (UMenu tChild : childList) + { + if (hasChild(list, tChild)) + { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, UMenu t) + { + List tlist = new ArrayList(); + for (UMenu n : list) { + if (n.getParentId().longValue() == t.getMenuId().longValue()) { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, UMenu t) + { + return !getChildList(list, t).isEmpty(); + } + + /** + * 内链域名特殊字符替换 + * + * @return 替换后的内链域名 + */ + public String innerLinkReplaceEach(String path) + { + return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":" }, + new String[] { "", "", "", "/", "/" }); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOperLogServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOperLogServiceImpl.java new file mode 100644 index 0000000..166eeaf --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOperLogServiceImpl.java @@ -0,0 +1,78 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.wfc.user.api.domain.UOperLog; +import org.wfc.user.mapper.UOperLogMapper; +import org.wfc.user.service.IUOperLogService; + +import java.util.List; + +/** + * 操作日志 服务层处理 + * + * @author wfc + */ +@Service +public class UOperLogServiceImpl implements IUOperLogService +{ + @Autowired + private UOperLogMapper operLogMapper; + + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + * @return 结果 + */ + @Override + public int insertOperlog(UOperLog operLog) + { + return operLogMapper.insertOperlog(operLog); + } + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + @Override + public List selectOperLogList(UOperLog operLog) + { + return operLogMapper.selectOperLogList(operLog); + } + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + @Override + public int deleteOperLogByIds(Long[] operIds) + { + return operLogMapper.deleteOperLogByIds(operIds); + } + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + @Override + public UOperLog selectOperLogById(Long operId) + { + return operLogMapper.selectOperLogById(operId); + } + + /** + * 清空操作日志 + */ + @Override + public void cleanOperLog() + { + operLogMapper.cleanOperLog(); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPermissionServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPermissionServiceImpl.java new file mode 100644 index 0000000..806ef45 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPermissionServiceImpl.java @@ -0,0 +1,92 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.user.api.domain.URole; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.service.IUMenuService; +import org.wfc.user.service.IUPermissionService; +import org.wfc.user.service.IURoleService; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * 用户权限处理 + * + * @author wfc + */ +@Service +public class UPermissionServiceImpl implements IUPermissionService +{ + @Autowired + private IURoleService roleService; + + @Autowired + private IUMenuService menuService; + + /** + * 获取角色数据权限 + * + * @param user 用户 + * @return 角色权限信息 + */ + @Override + public Set getRolePermission(UUser user) + { + Set roles = new HashSet(); + // 管理员拥有所有权限 + if (user.isAdmin()) + { + roles.add("admin"); + } + else + { + roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId())); + } + return roles; + } + + /** + * 获取菜单数据权限 + * + * @param user 用户 + * @return 菜单权限信息 + */ + @Override + public Set getMenuPermission(UUser user) + { + Set perms = new HashSet(); + // 管理员拥有所有权限 + if (user.isAdmin()) + { + perms.add("*:*:*"); + } + else + { + List roles = user.getRoles(); + if (!CollectionUtils.isEmpty(roles)) + { + // 多角色设置permissions属性,以便数据权限匹配权限 + for (URole role : roles) + { + if (StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL)) + { + Set rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId()); + role.setPermissions(rolePerms); + perms.addAll(rolePerms); + } + } + } + else + { + perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId())); + } + } + return perms; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPostServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPostServiceImpl.java new file mode 100644 index 0000000..d972ceb --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UPostServiceImpl.java @@ -0,0 +1,179 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.exception.ServiceException; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.user.domain.UPost; +import org.wfc.user.mapper.UPostMapper; +import org.wfc.user.mapper.UUserPostMapper; +import org.wfc.user.service.IUPostService; + +import java.util.List; + +/** + * 岗位信息 服务层处理 + * + * @author wfc + */ +@Service +public class UPostServiceImpl implements IUPostService +{ + @Autowired + private UPostMapper postMapper; + + @Autowired + private UUserPostMapper userPostMapper; + + /** + * 查询岗位信息集合 + * + * @param post 岗位信息 + * @return 岗位信息集合 + */ + @Override + public List selectPostList(UPost post) + { + return postMapper.selectPostList(post); + } + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + @Override + public List selectPostAll() + { + return postMapper.selectPostAll(); + } + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + @Override + public UPost selectPostById(Long postId) + { + return postMapper.selectPostById(postId); + } + + /** + * 根据用户ID获取岗位选择框列表 + * + * @param userId 用户ID + * @return 选中岗位ID列表 + */ + @Override + public List selectPostListByUserId(Long userId) + { + return postMapper.selectPostListByUserId(userId); + } + + /** + * 校验岗位名称是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public boolean checkPostNameUnique(UPost post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + UPost info = postMapper.checkPostNameUnique(post.getPostName()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验岗位编码是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public boolean checkPostCodeUnique(UPost post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + UPost info = postMapper.checkPostCodeUnique(post.getPostCode()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + @Override + public int countUserPostById(Long postId) + { + return userPostMapper.countUserPostById(postId); + } + + /** + * 删除岗位信息 + * + * @param postId 岗位ID + * @return 结果 + */ + @Override + public int deletePostById(Long postId) + { + return postMapper.deletePostById(postId); + } + + /** + * 批量删除岗位信息 + * + * @param postIds 需要删除的岗位ID + * @return 结果 + */ + @Override + public int deletePostByIds(Long[] postIds) + { + for (Long postId : postIds) + { + UPost post = selectPostById(postId); + if (countUserPostById(postId) > 0) + { + throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName())); + } + } + return postMapper.deletePostByIds(postIds); + } + + /** + * 新增保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public int insertPost(UPost post) + { + return postMapper.insertPost(post); + } + + /** + * 修改保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public int updatePost(UPost post) + { + return postMapper.updatePost(post); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/URoleServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/URoleServiceImpl.java new file mode 100644 index 0000000..45ff9b9 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/URoleServiceImpl.java @@ -0,0 +1,422 @@ +package org.wfc.user.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.exception.ServiceException; +import org.wfc.common.core.utils.SpringUtils; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.URole; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.domain.URoleDept; +import org.wfc.user.domain.URoleMenu; +import org.wfc.user.domain.UUserRole; +import org.wfc.user.mapper.URoleDeptMapper; +import org.wfc.user.mapper.URoleMapper; +import org.wfc.user.mapper.URoleMenuMapper; +import org.wfc.user.mapper.UUserRoleMapper; +import org.wfc.user.service.IURoleService; + +import java.util.*; + +/** + * 角色 业务层处理 + * + * @author wfc + */ +@Service +public class URoleServiceImpl implements IURoleService +{ + @Autowired + private URoleMapper roleMapper; + + @Autowired + private URoleMenuMapper roleMenuMapper; + + @Autowired + private UUserRoleMapper userRoleMapper; + + @Autowired + private URoleDeptMapper roleDeptMapper; + + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + @Override + public List selectRoleList(URole role) + { + return roleMapper.selectRoleList(role); + } + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + @Override + public List selectRolesByUserId(Long userId) + { + List userRoles = roleMapper.selectRolePermissionByUserId(userId); + List roles = selectRoleAll(); + for (URole role : roles) + { + for (URole userRole : userRoles) + { + if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) + { + role.setFlag(true); + break; + } + } + } + return roles; + } + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + @Override + public Set selectRolePermissionByUserId(Long userId) + { + List perms = roleMapper.selectRolePermissionByUserId(userId); + Set permsSet = new HashSet<>(); + for (URole perm : perms) + { + if (StringUtils.isNotNull(perm)) + { + permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); + } + } + return permsSet; + } + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + @Override + public List selectRoleAll() + { + return SpringUtils.getAopProxy(this).selectRoleList(new URole()); + } + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + @Override + public List selectRoleListByUserId(Long userId) + { + return roleMapper.selectRoleListByUserId(userId); + } + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + @Override + public URole selectRoleById(Long roleId) + { + return roleMapper.selectRoleById(roleId); + } + + /** + * 校验角色名称是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public boolean checkRoleNameUnique(URole role) + { + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + URole info = roleMapper.checkRoleNameUnique(role.getRoleName()); + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验角色权限是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public boolean checkRoleKeyUnique(URole role) + { + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + URole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验角色是否允许操作 + * + * @param role 角色信息 + */ + @Override + public void checkRoleAllowed(URole role) + { + if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) + { + throw new ServiceException("不允许操作超级管理员角色"); + } + } + + /** + * 校验角色是否有数据权限 + * + * @param roleIds 角色id + */ + @Override + public void checkRoleDataScope(Long... roleIds) + { + if (!UUser.isAdmin(SecurityUtils.getUserId())) + { + for (Long roleId : roleIds) + { + URole role = new URole(); + role.setRoleId(roleId); + List roles = SpringUtils.getAopProxy(this).selectRoleList(role); + if (StringUtils.isEmpty(roles)) + { + throw new ServiceException("没有权限访问角色数据!"); + } + } + } + } + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + @Override + public int countUserRoleByRoleId(Long roleId) + { + return userRoleMapper.countUserRoleByRoleId(roleId); + } + + /** + * 新增保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int insertRole(URole role) + { + // 新增角色信息 + roleMapper.insertRole(role); + return insertRoleMenu(role); + } + + /** + * 修改保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateRole(URole role) + { + // 修改角色信息 + roleMapper.updateRole(role); + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); + return insertRoleMenu(role); + } + + /** + * 修改角色状态 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public int updateRoleStatus(URole role) + { + return roleMapper.updateRole(role); + } + + /** + * 修改数据权限信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int authDataScope(URole role) + { + // 修改角色信息 + roleMapper.updateRole(role); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId()); + // 新增角色和部门信息(数据权限) + return insertRoleDept(role); + } + + /** + * 新增角色菜单信息 + * + * @param role 角色对象 + */ + public int insertRoleMenu(URole role) + { + int rows = 1; + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long menuId : role.getMenuIds()) + { + URoleMenu rm = new URoleMenu(); + rm.setRoleId(role.getRoleId()); + rm.setMenuId(menuId); + list.add(rm); + } + if (list.size() > 0) + { + rows = roleMenuMapper.batchRoleMenu(list); + } + return rows; + } + + /** + * 新增角色部门信息(数据权限) + * + * @param role 角色对象 + */ + public int insertRoleDept(URole role) + { + int rows = 1; + // 新增角色与部门(数据权限)管理 + List list = new ArrayList(); + for (Long deptId : role.getDeptIds()) + { + URoleDept rd = new URoleDept(); + rd.setRoleId(role.getRoleId()); + rd.setDeptId(deptId); + list.add(rd); + } + if (list.size() > 0) + { + rows = roleDeptMapper.batchRoleDept(list); + } + return rows; + } + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteRoleById(Long roleId) + { + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenuByRoleId(roleId); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDeptByRoleId(roleId); + return roleMapper.deleteRoleById(roleId); + } + + /** + * 批量删除角色信息 + * + * @param roleIds 需要删除的角色ID + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteRoleByIds(Long[] roleIds) + { + for (Long roleId : roleIds) + { + checkRoleAllowed(new URole(roleId)); + checkRoleDataScope(roleId); + URole role = selectRoleById(roleId); + if (countUserRoleByRoleId(roleId) > 0) + { + throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); + } + } + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenu(roleIds); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDept(roleIds); + return roleMapper.deleteRoleByIds(roleIds); + } + + /** + * 取消授权用户角色 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + @Override + public int deleteAuthUser(UUserRole userRole) + { + return userRoleMapper.deleteUserRoleInfo(userRole); + } + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要取消授权的用户数据ID + * @return 结果 + */ + @Override + public int deleteAuthUsers(Long roleId, Long[] userIds) + { + return userRoleMapper.deleteUserRoleInfos(roleId, userIds); + } + + /** + * 批量选择授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要授权的用户数据ID + * @return 结果 + */ + @Override + public int insertAuthUsers(Long roleId, Long[] userIds) + { + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long userId : userIds) + { + UUserRole ur = new UUserRole(); + ur.setUserId(userId); + ur.setRoleId(roleId); + list.add(ur); + } + return userRoleMapper.batchUserRole(list); + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserOnlineServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserOnlineServiceImpl.java new file mode 100644 index 0000000..11d420c --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserOnlineServiceImpl.java @@ -0,0 +1,89 @@ +package org.wfc.user.service.impl; + +import org.springframework.stereotype.Service; +import org.wfc.common.core.domain.LoginUser; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.user.domain.UUserOnline; +import org.wfc.user.service.IUUserOnlineService; + +/** + * 在线用户 服务层处理 + * + * @author wfc + */ +@Service +public class UUserOnlineServiceImpl implements IUUserOnlineService +{ + /** + * 通过登录地址查询信息 + * + * @param ipaddr 登录地址 + * @param user 用户信息 + * @return 在线用户信息 + */ + @Override + public UUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) + { + if (StringUtils.equals(ipaddr, user.getIpaddr())) + { + return loginUserToUserOnline(user); + } + return null; + } + + /** + * 通过用户名称查询信息 + * + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + @Override + public UUserOnline selectOnlineByUserName(String userName, LoginUser user) + { + if (StringUtils.equals(userName, user.getUsername())) + { + return loginUserToUserOnline(user); + } + return null; + } + + /** + * 通过登录地址/用户名称查询信息 + * + * @param ipaddr 登录地址 + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + @Override + public UUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) + { + if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) + { + return loginUserToUserOnline(user); + } + return null; + } + + /** + * 设置在线用户信息 + * + * @param user 用户信息 + * @return 在线用户 + */ + @Override + public UUserOnline loginUserToUserOnline(LoginUser user) + { + if (StringUtils.isNull(user)) + { + return null; + } + UUserOnline UUserOnline = new UUserOnline(); + UUserOnline.setTokenId(user.getToken()); + UUserOnline.setUserName(user.getUsername()); + UUserOnline.setIpaddr(user.getIpaddr()); + UUserOnline.setLoginTime(user.getLoginTime()); + return UUserOnline; + } +} diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserServiceImpl.java new file mode 100644 index 0000000..41645be --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UUserServiceImpl.java @@ -0,0 +1,544 @@ +package org.wfc.user.service.impl; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.wfc.common.core.constant.UserConstants; +import org.wfc.common.core.exception.ServiceException; +import org.wfc.common.core.utils.SpringUtils; +import org.wfc.common.core.utils.StringUtils; +import org.wfc.common.core.utils.bean.BeanValidators; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.api.domain.URole; +import org.wfc.user.api.domain.UUser; +import org.wfc.user.domain.UPost; +import org.wfc.user.domain.UUserPost; +import org.wfc.user.domain.UUserRole; +import org.wfc.user.mapper.*; +import org.wfc.user.service.IUConfigService; +import org.wfc.user.service.IUDeptService; +import org.wfc.user.service.IUUserService; + +import javax.validation.Validator; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 用户 业务层处理 + * + * @author wfc + */ +@Service +public class UUserServiceImpl implements IUUserService +{ + private static final Logger log = LoggerFactory.getLogger(UUserServiceImpl.class); + + @Autowired + private UUserMapper userMapper; + + @Autowired + private URoleMapper roleMapper; + + @Autowired + private UPostMapper postMapper; + + @Autowired + private UUserRoleMapper userRoleMapper; + + @Autowired + private UUserPostMapper userPostMapper; + + @Autowired + private IUConfigService configService; + + @Autowired + private IUDeptService deptService; + + @Autowired + protected Validator validator; + + /** + * 根据条件分页查询用户列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @Override + public List selectUserList(UUser user) + { + return userMapper.selectUserList(user); + } + + /** + * 根据条件分页查询已分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @Override + public List selectAllocatedList(UUser user) + { + return userMapper.selectAllocatedList(user); + } + + /** + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @Override + public List selectUnallocatedList(UUser user) + { + return userMapper.selectUnallocatedList(user); + } + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + @Override + public UUser selectUserByUserName(String userName) + { + return userMapper.selectUserByUserName(userName); + } + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + @Override + public UUser selectUserById(Long userId) + { + return userMapper.selectUserById(userId); + } + + /** + * 查询用户所属角色组 + * + * @param userName 用户名 + * @return 结果 + */ + @Override + public String selectUserRoleGroup(String userName) + { + List list = roleMapper.selectRolesByUserName(userName); + if (CollectionUtils.isEmpty(list)) + { + return StringUtils.EMPTY; + } + return list.stream().map(URole::getRoleName).collect(Collectors.joining(",")); + } + + /** + * 查询用户所属岗位组 + * + * @param userName 用户名 + * @return 结果 + */ + @Override + public String selectUserPostGroup(String userName) + { + List list = postMapper.selectPostsByUserName(userName); + if (CollectionUtils.isEmpty(list)) + { + return StringUtils.EMPTY; + } + return list.stream().map(UPost::getPostName).collect(Collectors.joining(",")); + } + + /** + * 校验用户名称是否唯一 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public boolean checkUserNameUnique(UUser user) + { + Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); + UUser info = userMapper.checkUserNameUnique(user.getUserName()); + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验手机号码是否唯一 + * + * @param user 用户信息 + * @return + */ + @Override + public boolean checkPhoneUnique(UUser user) + { + Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); + UUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验email是否唯一 + * + * @param user 用户信息 + * @return + */ + @Override + public boolean checkEmailUnique(UUser user) + { + Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); + UUser info = userMapper.checkEmailUnique(user.getEmail()); + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验用户是否允许操作 + * + * @param user 用户信息 + */ + @Override + public void checkUserAllowed(UUser user) + { + if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) + { + throw new ServiceException("不允许操作超级管理员用户"); + } + } + + /** + * 校验用户是否有数据权限 + * + * @param userId 用户id + */ + @Override + public void checkUserDataScope(Long userId) + { + if (!UUser.isAdmin(SecurityUtils.getUserId())) + { + UUser user = new UUser(); + user.setUserId(userId); + List users = SpringUtils.getAopProxy(this).selectUserList(user); + if (StringUtils.isEmpty(users)) + { + throw new ServiceException("没有权限访问用户数据!"); + } + } + } + + /** + * 新增保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int insertUser(UUser user) + { + // 新增用户信息 + int rows = userMapper.insertUser(user); + // 新增用户岗位关联 + insertUserPost(user); + // 新增用户与角色管理 + insertUserRole(user); + return rows; + } + + /** + * 注册用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public boolean registerUser(UUser user) + { + return userMapper.insertUser(user) > 0; + } + + /** + * 修改保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateUser(UUser user) + { + Long userId = user.getUserId(); + // 删除用户与角色关联 + userRoleMapper.deleteUserRoleByUserId(userId); + // 新增用户与角色管理 + insertUserRole(user); + // 删除用户与岗位关联 + userPostMapper.deleteUserPostByUserId(userId); + // 新增用户与岗位管理 + insertUserPost(user); + return userMapper.updateUser(user); + } + + /** + * 用户授权角色 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void insertUserAuth(Long userId, Long[] roleIds) + { + userRoleMapper.deleteUserRoleByUserId(userId); + insertUserRole(userId, roleIds); + } + + /** + * 修改用户状态 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int updateUserStatus(UUser user) + { + return userMapper.updateUser(user); + } + + /** + * 修改用户基本信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public boolean updateUserProfile(UUser user) + { + return userMapper.updateUser(user) > 0; + } + + /** + * 修改用户头像 + * + * @param userName 用户名 + * @param avatar 头像地址 + * @return 结果 + */ + @Override + public boolean updateUserAvatar(String userName, String avatar) + { + return userMapper.updateUserAvatar(userName, avatar) > 0; + } + + /** + * 重置用户密码 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int resetPwd(UUser user) + { + return userMapper.updateUser(user); + } + + /** + * 重置用户密码 + * + * @param userName 用户名 + * @param password 密码 + * @return 结果 + */ + @Override + public int resetUserPwd(String userName, String password) + { + return userMapper.resetUserPwd(userName, password); + } + + /** + * 新增用户角色信息 + * + * @param user 用户对象 + */ + public void insertUserRole(UUser user) + { + this.insertUserRole(user.getUserId(), user.getRoleIds()); + } + + /** + * 新增用户岗位信息 + * + * @param user 用户对象 + */ + public void insertUserPost(UUser user) + { + Long[] posts = user.getPostIds(); + if (StringUtils.isNotEmpty(posts)) + { + // 新增用户与岗位管理 + List list = new ArrayList(); + for (Long postId : posts) + { + UUserPost up = new UUserPost(); + up.setUserId(user.getUserId()); + up.setPostId(postId); + list.add(up); + } + userPostMapper.batchUserPost(list); + } + } + + /** + * 新增用户角色信息 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + public void insertUserRole(Long userId, Long[] roleIds) + { + if (StringUtils.isNotEmpty(roleIds)) + { + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long roleId : roleIds) + { + UUserRole ur = new UUserRole(); + ur.setUserId(userId); + ur.setRoleId(roleId); + list.add(ur); + } + userRoleMapper.batchUserRole(list); + } + } + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteUserById(Long userId) + { + // 删除用户与角色关联 + userRoleMapper.deleteUserRoleByUserId(userId); + // 删除用户与岗位表 + userPostMapper.deleteUserPostByUserId(userId); + return userMapper.deleteUserById(userId); + } + + /** + * 批量删除用户信息 + * + * @param userIds 需要删除的用户ID + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteUserByIds(Long[] userIds) + { + for (Long userId : userIds) + { + checkUserAllowed(new UUser(userId)); + checkUserDataScope(userId); + } + // 删除用户与角色关联 + userRoleMapper.deleteUserRole(userIds); + // 删除用户与岗位关联 + userPostMapper.deleteUserPost(userIds); + return userMapper.deleteUserByIds(userIds); + } + + /** + * 导入用户数据 + * + * @param userList 用户数据列表 + * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @return 结果 + */ + @Override + public String importUser(List userList, Boolean isUpdateSupport, String operName) + { + if (StringUtils.isNull(userList) || userList.size() == 0) + { + throw new ServiceException("导入用户数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (UUser user : userList) + { + try + { + // 验证是否存在这个用户 + UUser u = userMapper.selectUserByUserName(user.getUserName()); + if (StringUtils.isNull(u)) + { + BeanValidators.validateWithException(validator, user); + deptService.checkDeptDataScope(user.getDeptId()); + String password = configService.selectConfigByKey("U.user.initPassword"); + user.setPassword(SecurityUtils.encryptPassword(password)); + user.setCreateBy(operName); + userMapper.insertUser(user); + successNum++; + successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); + } + else if (isUpdateSupport) + { + BeanValidators.validateWithException(validator, user); + checkUserAllowed(u); + checkUserDataScope(u.getUserId()); + deptService.checkDeptDataScope(user.getDeptId()); + user.setUserId(u.getUserId()); + user.setUpdateBy(operName); + userMapper.updateUser(user); + successNum++; + successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 更新成功"); + } + else + { + failureNum++; + failureMsg.append("
" + failureNum + "、账号 " + user.getUserName() + " 已存在"); + } + } + catch (Exception e) + { + failureNum++; + String msg = "
" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + log.error(msg, e); + } + } + if (failureNum > 0) + { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } + else + { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } + +} diff --git a/wfc-modules/wfc-modules-user/src/main/resources/application.yml b/wfc-modules/wfc-modules-user/src/main/resources/application.yml index 6c2314d..c6a8726 100644 --- a/wfc-modules/wfc-modules-user/src/main/resources/application.yml +++ b/wfc-modules/wfc-modules-user/src/main/resources/application.yml @@ -1,24 +1,56 @@ # spring配置 spring: redis: - host: 192.168.2.248 - port: 6379 - password: + host: 192.168.9.58 + port: 16379 + password: helloearth datasource: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.2.248:3306/wfc-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: 123456 + druid: + stat-view-servlet: + enabled: true + loginUsername: admin + loginPassword: 123456 + dynamic: + druid: + initial-size: 5 + min-idle: 5 + maxActive: 20 + maxWait: 60000 + connectTimeout: 30000 + socketTimeout: 60000 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxPoolPreparedStatementPerConnectionSize: 20 + filters: stat,slf4j + connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 + datasource: + # 主库数据源 + master: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.9.58:13306/wfc-user-platform?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: 1000omc@kp! + # 从库数据源 + # slave: + # username: + # password: + # url: + # driver-class-name: # mybatis配置 mybatis: # 搜索指定包别名 - typeAliasesPackage: org.wfc.user.domain + typeAliasesPackage: org.wfc.user # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath:mapper/**/*.xml # swagger配置 swagger: - title: 用户平台接口文档 + title: 系统模块接口文档 license: Powered By wfc - licenseUrl: https://wfc.vip + licenseUrl: https://wfc.vip \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UConfigMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UConfigMapper.xml new file mode 100644 index 0000000..0b224dd --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UConfigMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark + from u_config + + + + + + + and config_id = #{configId} + + + and config_key = #{configKey} + + + + + + + + + + + + + + insert into u_config ( + config_name, + config_key, + config_value, + config_type, + create_by, + remark, + create_time + )values( + #{configName}, + #{configKey}, + #{configValue}, + #{configType}, + #{createBy}, + #{remark}, + sysdate() + ) + + + + update u_config + + config_name = #{configName}, + config_key = #{configKey}, + config_value = #{configValue}, + config_type = #{configType}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where config_id = #{configId} + + + + delete from u_config where config_id = #{configId} + + + + delete from u_config where config_id in + + #{configId} + + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDeptMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDeptMapper.xml new file mode 100644 index 0000000..edff7f5 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDeptMapper.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select d.dept_id, d.parent_id, d.ancestors, d.remark, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time + from u_dept d + + + + + + + + + + + + + + + + + + + + insert into u_dept( + dept_id, + parent_id, + dept_name, + ancestors, + order_num, + leader, + phone, + email, + status, + create_by, + remark, + create_time + )values( + #{deptId}, + #{parentId}, + #{deptName}, + #{ancestors}, + #{orderNum}, + #{leader}, + #{phone}, + #{email}, + #{status}, + #{createBy}, + #{remark}, + sysdate() + ) + + + + update u_dept + + parent_id = #{parentId}, + dept_name = #{deptName}, + ancestors = #{ancestors}, + order_num = #{orderNum}, + leader = #{leader}, + phone = #{phone}, + email = #{email}, + status = #{status}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where dept_id = #{deptId} + + + + update u_dept set ancestors = + + when #{item.deptId} then #{item.ancestors} + + where dept_id in + + #{item.deptId} + + + + + update u_dept set status = '0' where dept_id in + + #{deptId} + + + + + update u_dept set del_flag = '2' where dept_id = #{deptId} + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictDataMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictDataMapper.xml new file mode 100644 index 0000000..a48bb3a --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictDataMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark + from u_dict_data + + + + + + + + + + + + + + delete from u_dict_data where dict_code = #{dictCode} + + + + delete from u_dict_data where dict_code in + + #{dictCode} + + + + + update u_dict_data + + dict_sort = #{dictSort}, + dict_label = #{dictLabel}, + dict_value = #{dictValue}, + dict_type = #{dictType}, + css_class = #{cssClass}, + list_class = #{listClass}, + is_default = #{isDefault}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where dict_code = #{dictCode} + + + + update u_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType} + + + + insert into u_dict_data( + dict_sort, + dict_label, + dict_value, + dict_type, + css_class, + list_class, + is_default, + status, + remark, + create_by, + create_time + )values( + #{dictSort}, + #{dictLabel}, + #{dictValue}, + #{dictType}, + #{cssClass}, + #{listClass}, + #{isDefault}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictTypeMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictTypeMapper.xml new file mode 100644 index 0000000..89b8a78 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UDictTypeMapper.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + select dict_id, dict_name, dict_type, status, create_by, create_time, remark + from u_dict_type + + + + + + + + + + + + + + delete from u_dict_type where dict_id = #{dictId} + + + + delete from u_dict_type where dict_id in + + #{dictId} + + + + + update u_dict_type + + dict_name = #{dictName}, + dict_type = #{dictType}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where dict_id = #{dictId} + + + + insert into u_dict_type( + dict_name, + dict_type, + status, + remark, + create_by, + create_time + )values( + #{dictName}, + #{dictType}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/ULogininforMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/ULogininforMapper.xml new file mode 100644 index 0000000..8cc74e4 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/ULogininforMapper.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + insert into u_logininfor (user_name, status, ipaddr, msg, access_time) + values (#{userName}, #{status}, #{ipaddr}, #{msg}, sysdate()) + + + + + + delete from u_logininfor where info_id in + + #{infoId} + + + + + truncate table u_logininfor + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UMenuMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UMenuMapper.xml new file mode 100644 index 0000000..b90b40b --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UMenuMapper.xml @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select menu_id, menu_name, parent_id, order_num, path, name, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time + from u_menu + + + + + + + + + + + + + + + + + + + + + + + + + + update u_menu + + menu_name = #{menuName}, + parent_id = #{parentId}, + order_num = #{orderNum}, + path = #{path}, + component = #{component}, + `query` = #{query}, + is_frame = #{isFrame}, + is_cache = #{isCache}, + menu_type = #{menuType}, + visible = #{visible}, + status = #{status}, + perms = #{perms}, + icon = #{icon}, + remark = #{remark}, + name = #{name}, + update_time = sysdate() + + where menu_id = #{menuId} + + + + insert into u_menu( + menu_id, + parent_id, + menu_name, + order_num, + path, + component, + `query`, + is_frame, + is_cache, + menu_type, + visible, + status, + perms, + icon, + remark, + create_by, + name, + create_time + )values( + #{menuId}, + #{parentId}, + #{menuName}, + #{orderNum}, + #{path}, + #{component}, + #{query}, + #{isFrame}, + #{isCache}, + #{menuType}, + #{visible}, + #{status}, + #{perms}, + #{icon}, + #{remark}, + #{createBy}, + #{name}, + sysdate() + ) + + + + delete from u_menu where menu_id = #{menuId} + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UOperLogMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UOperLogMapper.xml new file mode 100644 index 0000000..4da5d41 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UOperLogMapper.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time, cost_time + from u_oper_log + + + + insert into u_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, cost_time, oper_time) + values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, sysdate()) + + + + + + delete from u_oper_log where oper_id in + + #{operId} + + + + + + + truncate table u_oper_log + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UPostMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UPostMapper.xml new file mode 100644 index 0000000..2876944 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UPostMapper.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark + from u_post + + + + + + + + + + + + + + + + + + update u_post + + post_code = #{postCode}, + post_name = #{postName}, + post_sort = #{postSort}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where post_id = #{postId} + + + + insert into u_post( + post_id, + post_code, + post_name, + post_sort, + status, + remark, + create_by, + create_time + )values( + #{postId}, + #{postCode}, + #{postName}, + #{postSort}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + delete from u_post where post_id = #{postId} + + + + delete from u_post where post_id in + + #{postId} + + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleDeptMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleDeptMapper.xml new file mode 100644 index 0000000..36f0890 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleDeptMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + delete from u_role_dept where role_id=#{roleId} + + + + + + delete from u_role_dept where role_id in + + #{roleId} + + + + + insert into u_role_dept(role_id, dept_id) values + + (#{item.roleId},#{item.deptId}) + + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMapper.xml new file mode 100644 index 0000000..f01d3a5 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMapper.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, + r.status, r.del_flag, r.create_time, r.remark + from u_role r + left join u_user_role ur on ur.role_id = r.role_id + left join u_user u on u.user_id = ur.user_id + left join u_dept d on u.dept_id = d.dept_id + + + + + + + + + + + + + + + + + + + + insert into u_role( + role_id, + role_name, + role_key, + role_sort, + data_scope, + menu_check_strictly, + dept_check_strictly, + status, + remark, + create_by, + create_time + )values( + #{roleId}, + #{roleName}, + #{roleKey}, + #{roleSort}, + #{dataScope}, + #{menuCheckStrictly}, + #{deptCheckStrictly}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + update u_role + + role_name = #{roleName}, + role_key = #{roleKey}, + role_sort = #{roleSort}, + data_scope = #{dataScope}, + menu_check_strictly = #{menuCheckStrictly}, + dept_check_strictly = #{deptCheckStrictly}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where role_id = #{roleId} + + + + update u_role set del_flag = '2' where role_id = #{roleId} + + + + update u_role set del_flag = '2' where role_id in + + #{roleId} + + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMenuMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMenuMapper.xml new file mode 100644 index 0000000..5a83b37 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/URoleMenuMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + delete from u_role_menu where role_id=#{roleId} + + + + delete from u_role_menu where role_id in + + #{roleId} + + + + + insert into u_role_menu(role_id, menu_id) values + + (#{item.roleId},#{item.menuId}) + + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserMapper.xml index 8172bfb..dbb61ef 100644 --- a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserMapper.xml +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserMapper.xml @@ -1,130 +1,221 @@ +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - - select user_id, user_name, nick_name, age, sex, email, phone, address, password, status, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, remark from u_user - - - + 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 u_user u + left join u_dept d on u.dept_id = d.dept_id + where u.del_flag = '0' + + AND u.user_id = #{userId} + + + AND u.user_name like concat('%', #{userName}, '%') + + + AND u.status = #{status} + + + AND u.phonenumber like concat('%', #{phonenumber}, '%') + + + AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d') + + + AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d') + + + AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM u_dept t WHERE find_in_set(#{deptId}, ancestors) )) + + +-- ${params.dataScope} - - + select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time + from u_user u + left join u_dept d on u.dept_id = d.dept_id + left join u_user_role ur on u.user_id = ur.user_id + left join u_role r on r.role_id = ur.role_id + where u.del_flag = '0' and r.role_id = #{roleId} + + AND u.user_name like concat('%', #{userName}, '%') + + + AND u.phonenumber like concat('%', #{phonenumber}, '%') + + + ${params.dataScope} - - - insert into u_user - - user_name, - nick_name, - age, - sex, - email, - phone, - address, - password, - status, - del_flag, - login_ip, - login_date, - create_by, - create_time, - update_by, - update_time, - remark, - - - #{userName}, - #{nickName}, - #{age}, - #{sex}, - #{email}, - #{phone}, - #{address}, - #{password}, - #{status}, - #{delFlag}, - #{loginIp}, - #{loginDate}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - #{remark}, - + + + + + + + + + + + + + + + insert into u_user( + user_id, + dept_id, + user_name, + nick_name, + email, + avatar, + phonenumber, + sex, + password, + status, + create_by, + remark, + create_time + )values( + #{userId}, + #{deptId}, + #{userName}, + #{nickName}, + #{email}, + #{avatar}, + #{phonenumber}, + #{sex}, + #{password}, + #{status}, + #{createBy}, + #{remark}, + sysdate() + ) - - - update u_user - - user_name = #{userName}, - nick_name = #{nickName}, - age = #{age}, - sex = #{sex}, - email = #{email}, - phone = #{phone}, - address = #{address}, - password = #{password}, - status = #{status}, - del_flag = #{delFlag}, - login_ip = #{loginIp}, - login_date = #{loginDate}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - remark = #{remark}, - - where user_id = #{userId} + + + update u_user + + dept_id = #{deptId}, + user_name = #{userName}, + nick_name = #{nickName}, + email = #{email}, + phonenumber = #{phonenumber}, + sex = #{sex}, + avatar = #{avatar}, + password = #{password}, + status = #{status}, + login_ip = #{loginIp}, + login_date = #{loginDate}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where user_id = #{userId} - - - delete from u_user where user_id = #{userId} - - - - delete from u_user where user_id in - - #{userId} - - - \ No newline at end of file + + + update u_user set status = #{status} where user_id = #{userId} + + + + update u_user set avatar = #{avatar} where user_name = #{userName} + + + + update u_user set password = #{password} where user_name = #{userName} + + + + update u_user set del_flag = '2' where user_id = #{userId} + + + + update u_user set del_flag = '2' where user_id in + + #{userId} + + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserPostMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserPostMapper.xml new file mode 100644 index 0000000..1eb9243 --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserPostMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + delete from u_user_post where user_id=#{userId} + + + + + + delete from u_user_post where user_id in + + #{userId} + + + + + insert into u_user_post(user_id, post_id) values + + (#{item.userId},#{item.postId}) + + + + \ No newline at end of file diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserRoleMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserRoleMapper.xml new file mode 100644 index 0000000..75f0a8f --- /dev/null +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UUserRoleMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + delete from u_user_role where user_id=#{userId} + + + + + + delete from u_user_role where user_id in + + #{userId} + + + + + insert into u_user_role(user_id, role_id) values + + (#{item.userId},#{item.roleId}) + + + + + delete from u_user_role where user_id=#{userId} and role_id=#{roleId} + + + + delete from u_user_role where role_id=#{roleId} and user_id in + + #{userId} + + + \ No newline at end of file