9 Commits

59 changed files with 852 additions and 867 deletions

View File

@@ -56,7 +56,7 @@
|作用|示例|
|---|---|
|分页查询|listUserPages|
|分页查询|getUserPage|
|列表查询|listUsers|
|单个查询|getUser/getUserDetail/getUserInfo ...|
|新增|saveUser|

View File

@@ -9,7 +9,7 @@ CREATE DATABASE IF NOT EXISTS youlai_boot DEFAULT CHARACTER SET utf8mb4 DEFAULT
-- ----------------------------
-- 2. 创建表
-- 2. 创建表 && 数据初始化
-- ----------------------------
use youlai_boot;
@@ -21,17 +21,17 @@ SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `sys_dept` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部门名称',
`parent_id` bigint NULL DEFAULT 0 COMMENT '父节点id',
`parent_id` bigint(0) NULL DEFAULT 0 COMMENT '父节点id',
`tree_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '父节点id路径',
`sort` int NULL DEFAULT 0 COMMENT '显示顺序',
`status` tinyint NULL DEFAULT 1 COMMENT '状态(1:正常;0:禁用)',
`deleted` tinyint NULL DEFAULT 0 COMMENT '逻辑删除标识(1:已删除;0:未删除)',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`sort` int(0) NULL DEFAULT 0 COMMENT '显示顺序',
`status` tinyint(0) NULL DEFAULT 1 COMMENT '状态(1:正常;0:禁用)',
`deleted` tinyint(0) NULL DEFAULT 0 COMMENT '逻辑删除标识(1:已删除;0:未删除)',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 150 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '部门表' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 171 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '部门表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_dept
@@ -41,45 +41,45 @@ INSERT INTO `sys_dept` VALUES (2, '研发部门', 1, '0,1', 1, 1, 0, NULL, '2022
INSERT INTO `sys_dept` VALUES (3, '测试部门', 1, '0,1', 1, 1, 0, NULL, '2022-04-19 12:46:37');
-- ----------------------------
-- Table structure for sys_dict_item
-- Table structure for sys_dict
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict_item`;
CREATE TABLE `sys_dict_item` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`type_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典类型编码',
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典项名称',
`value` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典项值',
`sort` int NULL DEFAULT 0 COMMENT '排序',
`status` tinyint NULL DEFAULT 0 COMMENT '状态(1:正常;0:禁用)',
`defaulted` tinyint NULL DEFAULT 0 COMMENT '是否默认(1:是;0:否)',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 65 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典数据表' ROW_FORMAT = DYNAMIC;
DROP TABLE IF EXISTS `sys_dict`;
CREATE TABLE `sys_dict` (
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
`type_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典类型编码',
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典项名称',
`value` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典项值',
`sort` int(0) NULL DEFAULT 0 COMMENT '排序',
`status` tinyint(0) NULL DEFAULT 0 COMMENT '状态(1:正常;0:禁用)',
`defaulted` tinyint(0) NULL DEFAULT 0 COMMENT '是否默认(1:是;0:否)',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 69 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典数据表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_dict_item
-- Records of sys_dict
-- ----------------------------
INSERT INTO `sys_dict_item` VALUES (1, 'gender', '', '1', 1, 1, 0, NULL, '2019-05-05 13:07:52', '2022-06-12 23:20:39');
INSERT INTO `sys_dict_item` VALUES (2, 'gender', '', '2', 2, 1, 0, NULL, '2019-04-19 11:33:00', '2019-07-02 14:23:05');
INSERT INTO `sys_dict_item` VALUES (3, 'gender', '未知', '0', 1, 1, 0, NULL, '2020-10-17 08:09:31', '2020-10-17 08:09:31');
INSERT INTO `sys_dict` VALUES (1, 'gender', '', '1', 1, 1, 0, NULL, '2019-05-05 13:07:52', '2022-06-12 23:20:39');
INSERT INTO `sys_dict` VALUES (2, 'gender', '', '2', 2, 1, 0, NULL, '2019-04-19 11:33:00', '2019-07-02 14:23:05');
INSERT INTO `sys_dict` VALUES (3, 'gender', '未知', '0', 1, 1, 0, NULL, '2020-10-17 08:09:31', '2020-10-17 08:09:31');
-- ----------------------------
-- Table structure for sys_dict_type
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict_type`;
CREATE TABLE `sys_dict_type` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键 ',
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键 ',
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '类型名称',
`code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '类型编码',
`status` tinyint(1) NULL DEFAULT 0 COMMENT '状态(0:正常;1:禁用)',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `type_code`(`code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 79 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典类型表' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 89 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典类型表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_dict_type
@@ -91,78 +91,91 @@ INSERT INTO `sys_dict_type` VALUES (1, '性别', 'gender', 1, NULL, '2019-12-06
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu` (
`id` bigint NOT NULL AUTO_INCREMENT,
`parent_id` bigint NOT NULL COMMENT '父菜单ID',
`id` bigint(0) NOT NULL AUTO_INCREMENT,
`parent_id` bigint(0) NOT NULL COMMENT '父菜单ID',
`name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '菜单名称',
`type` tinyint NULL DEFAULT NULL COMMENT '菜单类型(1:菜单2:目录3:外链4:按钮)',
`type` tinyint(0) NULL DEFAULT NULL COMMENT '菜单类型(1:菜单2:目录3:外链4:按钮)',
`path` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '路由路径(浏览器地址栏路径)',
`component` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件路径(vue页面完整路径省略.vue后缀)',
`perm` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限标识',
`visible` tinyint(1) NOT NULL DEFAULT 1 COMMENT '显示状态(1-显示;0-隐藏)',
`sort` int NULL DEFAULT 0 COMMENT '排序',
`sort` int(0) NULL DEFAULT 0 COMMENT '排序',
`icon` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '菜单图标',
`redirect_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '外链路径',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`redirect` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '跳转路径',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单管理' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 69 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单管理' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_menu
-- ----------------------------
INSERT INTO `sys_menu` VALUES (1, 0, '系统管理', 2, '/system', 'Layout', NULL, 1, 1, 'system', '/system/user', '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (2, 1, '用户管理', 1, 'user', 'system/user/index', NULL, 1, 1, 'user', NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (3, 1, '角色管理', 1, 'role', 'system/role/index', NULL, 1, 2, 'role', NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (4, 1, '菜单管理', 1, 'cmenu', 'system/menu/index', NULL, 1, 3, 'menu', NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (5, 1, '部门管理', 1, 'dept', 'system/dept/index', NULL, 1, 4, 'tree', NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (6, 1, '字典管理', 1, 'dict', 'system/dict/index', NULL, 1, 5, 'dict', NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (20, 0, '多级菜单', 2, '/multi-level-menu', 'Layout', NULL, 1, 7, 'nested', '/nested/level1/level2', '2022-02-16 23:11:00', '2022-02-16 23:11:00');
INSERT INTO `sys_menu` VALUES (21, 20, '菜单一级', 2, 'nested_level1_index', 'nested/level1/index', NULL, 1, 1, '', '/nested/level1/level2', '2022-02-16 23:13:38', '2022-02-16 23:13:38');
INSERT INTO `sys_menu` VALUES (22, 21, '菜单二级', 2, 'nested_level1_level2_index', 'nested/level1/level2/index', NULL, 1, 1, '', '/nested/level1/level2/level3', '2022-02-16 23:14:23', '2022-02-16 23:14:23');
INSERT INTO `sys_menu` VALUES (23, 22, '菜单三级-1', 1, 'nested_level1_level2_level3_index1', 'nested/level1/level2/level3/index1', NULL, 1, 1, '', '', '2022-02-16 23:14:51', '2022-02-16 23:14:51');
INSERT INTO `sys_menu` VALUES (24, 22, '菜单三级-2', 1, 'nested_level1_level2_level3_index2', 'nested/level1/level2/level3/index2', NULL, 1, 2, '', '', '2022-02-16 23:15:08', '2022-02-16 23:15:08');
INSERT INTO `sys_menu` VALUES (26, 0, '外部链接', 2, '/external-link', 'Layout', NULL, 1, 9, 'link', 'noredirect', '2022-02-17 22:51:20', '2022-02-17 22:51:20');
INSERT INTO `sys_menu` VALUES (30, 26, 'document', 3, 'https://www.cnblogs.com/haoxianrui/', '', NULL, 1, 1, 'link', '', '2022-02-18 00:01:40', '2022-02-18 00:01:40');
INSERT INTO `sys_menu` VALUES (31, 2, '用户新增', 4, '', NULL, 'sys:user:add', 1, 1, '', '', '2022-10-23 11:04:08', '2022-10-23 11:04:11');
INSERT INTO `sys_menu` VALUES (32, 2, '用户编辑', 4, '', NULL, 'sys:user:edit', 1, 2, '', '', '2022-10-23 11:04:08', '2022-10-23 11:04:11');
INSERT INTO `sys_menu` VALUES (33, 2, '用户删除', 4, '', NULL, 'sys:user:delete', 1, 3, '', '', '2022-10-23 11:04:08', '2022-10-23 11:04:11');
INSERT INTO `sys_menu` VALUES (36, 0, '组件封装', 2, '/component', 'Layout', NULL, 1, 10, 'menu', '', '2022-10-31 09:18:44', '2022-10-31 09:18:47');
INSERT INTO `sys_menu` VALUES (37, 36, '富文本编辑器', 1, 'editor', 'component/editor', NULL, 1, 1, '', '', NULL, NULL);
INSERT INTO `sys_menu` VALUES (38, 36, '上传组件', 1, 'uploader', 'component/uploader', NULL, 1, 2, '', '', '2022-11-20 23:16:30', '2022-11-20 23:16:32');
INSERT INTO `sys_menu` VALUES (1, 0, '系统管理', 2, '/system', 'Layout', NULL, 1, 1, 'system', '/system/user', '/system/user', '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (2, 1, '用户管理', 1, 'user', 'system/user/index', NULL, 1, 1, 'user', NULL, NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (3, 1, '角色管理', 1, 'role', 'system/role/index', NULL, 1, 2, 'role', NULL, NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (4, 1, '菜单管理', 1, 'cmenu', 'system/menu/index', NULL, 1, 3, 'menu', NULL, NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (5, 1, '部门管理', 1, 'dept', 'system/dept/index', NULL, 1, 4, 'tree', NULL, NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (6, 1, '字典管理', 1, 'dict', 'system/dict/index', NULL, 1, 5, 'dict', NULL, NULL, '2021-08-28 09:12:21', '2021-08-28 09:12:21');
INSERT INTO `sys_menu` VALUES (20, 0, '多级菜单', 2, '/multi-level-menu', 'Layout', NULL, 1, 9, 'multi_level', '/nested/level1/level2', '/nested/level1/level2', '2022-02-16 23:11:00', '2022-02-16 23:11:00');
INSERT INTO `sys_menu` VALUES (21, 20, '菜单一级', 2, 'nested_level1_index', 'nested/level1/index', NULL, 1, 1, '', '/nested/level1/level2', '/nested/level1/level2', '2022-02-16 23:13:38', '2022-02-16 23:13:38');
INSERT INTO `sys_menu` VALUES (22, 21, '菜单二级', 2, 'nested_level1_level2_index', 'nested/level1/level2/index', NULL, 1, 1, '', '/nested/level1/level2/level3', '/nested/level1/level2/level3', '2022-02-16 23:14:23', '2022-02-16 23:14:23');
INSERT INTO `sys_menu` VALUES (23, 22, '菜单三级-1', 1, 'nested_level1_level2_level3_index1', 'nested/level1/level2/level3/index1', NULL, 1, 1, '', '', '', '2022-02-16 23:14:51', '2022-02-16 23:14:51');
INSERT INTO `sys_menu` VALUES (24, 22, '菜单三级-2', 1, 'nested_level1_level2_level3_index2', 'nested/level1/level2/level3/index2', NULL, 1, 2, '', '', '', '2022-02-16 23:15:08', '2022-02-16 23:15:08');
INSERT INTO `sys_menu` VALUES (26, 0, '外部链接', 2, '/external-link', 'Layout', NULL, 1, 8, 'link', 'noredirect', 'noredirect', '2022-02-17 22:51:20', '2022-02-17 22:51:20');
INSERT INTO `sys_menu` VALUES (30, 26, 'document', 3, 'https://www.cnblogs.com/haoxianrui/p/16090029.html', '', NULL, 1, 1, 'document', '', '', '2022-02-18 00:01:40', '2022-02-18 00:01:40');
INSERT INTO `sys_menu` VALUES (31, 2, '用户新增', 4, '', NULL, 'sys:user:add', 1, 1, '', '', '', '2022-10-23 11:04:08', '2022-10-23 11:04:11');
INSERT INTO `sys_menu` VALUES (32, 2, '用户编辑', 4, '', NULL, 'sys:user:edit', 1, 2, '', '', '', '2022-10-23 11:04:08', '2022-10-23 11:04:11');
INSERT INTO `sys_menu` VALUES (33, 2, '用户删除', 4, '', NULL, 'sys:user:delete', 1, 3, '', '', '', '2022-10-23 11:04:08', '2022-10-23 11:04:11');
INSERT INTO `sys_menu` VALUES (36, 0, '组件封装', 2, '/demo', 'Layout', NULL, 1, 10, 'menu', '', '', '2022-10-31 09:18:44', '2022-10-31 09:18:47');
INSERT INTO `sys_menu` VALUES (37, 36, '富文本编辑器', 1, 'editor', 'demo/editor', NULL, 1, 1, '', '', '', NULL, NULL);
INSERT INTO `sys_menu` VALUES (38, 36, '上传组件', 1, 'uploader', 'demo/uploader', NULL, 1, 2, '', '', '', '2022-11-20 23:16:30', '2022-11-20 23:16:32');
INSERT INTO `sys_menu` VALUES (39, 36, '图标选择器', 1, 'icon-selector', 'demo/icon-selector', NULL, 1, 3, '', '', '', '2022-11-20 23:16:30', '2022-11-20 23:16:32');
INSERT INTO `sys_menu` VALUES (40, 0, '接口', 2, '/api', 'Layout', NULL, 1, 7, 'api', '', '', '2022-02-17 22:51:20', '2022-02-17 22:51:20');
INSERT INTO `sys_menu` VALUES (41, 40, '接口文档', 1, 'apidoc', 'demo/apidoc', NULL, 1, 1, 'api', '', '', '2022-02-17 22:51:20', '2022-02-17 22:51:20');
-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
`id` bigint NOT NULL AUTO_INCREMENT,
`id` bigint(0) NOT NULL AUTO_INCREMENT,
`name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '角色名称',
`code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色编码',
`sort` int NULL DEFAULT NULL COMMENT '显示顺序',
`sort` int(0) NULL DEFAULT NULL COMMENT '显示顺序',
`status` tinyint(1) NULL DEFAULT 1 COMMENT '角色状态(1-正常0-停用)',
`data_scope` tinyint DEFAULT NULL COMMENT '数据权限(0-所有数据1-部门及子部门数据2-本部门数据3-本人数据)',
`data_scope` tinyint(0) NULL DEFAULT NULL COMMENT '数据权限(0-所有数据1-部门及子部门数据2-本部门数据3-本人数据)',
`deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除1-已删除)',
`create_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 110 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 128 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_role
-- ----------------------------
INSERT INTO `sys_role` VALUES (1, '超级管理员', 'ROOT', 1, 1,0, 0, '2021-05-21 14:56:51', '2018-12-23 16:00:00');
INSERT INTO `sys_role` VALUES (2, '系统管理员', 'ADMIN', 2, 1,1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (3, '访问游客', 'GUEST', 3, 1, 2,0, '2021-05-26 15:49:05', '2019-05-05 16:00:00');
INSERT INTO `sys_role` VALUES (1, '超级管理员', 'ROOT', 1, 1, 0, 0, '2021-05-21 14:56:51', '2018-12-23 16:00:00');
INSERT INTO `sys_role` VALUES (2, '系统管理员', 'ADMIN', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (3, '访问游客', 'GUEST', 3, 1, 2, 0, '2021-05-26 15:49:05', '2019-05-05 16:00:00');
INSERT INTO `sys_role` VALUES (4, '系统管理员1', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (5, '系统管理员2', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (6, '系统管理员3', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (7, '系统管理员4', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (8, '系统管理员5', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (9, '系统管理员6', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (10, '系统管理员7', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (11, '系统管理员8', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
INSERT INTO `sys_role` VALUES (12, '系统管理员9', 'ADMIN1', 2, 1, 1, 0, '2021-03-25 12:39:54', NULL);
-- ----------------------------
-- Table structure for sys_role_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_menu`;
CREATE TABLE `sys_role_menu` (
`role_id` bigint NOT NULL COMMENT '角色ID',
`menu_id` bigint NOT NULL COMMENT '菜单ID'
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色和菜单关联表' ROW_FORMAT = DYNAMIC;
`role_id` bigint(0) NOT NULL COMMENT '角色ID',
`menu_id` bigint(0) NOT NULL COMMENT '菜单ID'
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色和菜单关联表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_role_menu
@@ -197,47 +210,50 @@ INSERT INTO `sys_role_menu` VALUES (2, 34);
INSERT INTO `sys_role_menu` VALUES (2, 26);
INSERT INTO `sys_role_menu` VALUES (2, 30);
INSERT INTO `sys_role_menu` VALUES (2, 31);
INSERT INTO `sys_role_menu` VALUES (2, 36);
INSERT INTO `sys_role_menu` VALUES (2, 38);
INSERT INTO `sys_role_menu` VALUES (2, 39);
INSERT INTO `sys_role_menu` VALUES (2, 40);
INSERT INTO `sys_role_menu` VALUES (2, 41);
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
`id` int NOT NULL AUTO_INCREMENT,
`id` int(0) NOT NULL AUTO_INCREMENT,
`username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名',
`nickname` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '昵称',
`gender` tinyint(1) NULL DEFAULT 1 COMMENT '性别((1:男;2:女))',
`password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码',
`dept_id` int NULL DEFAULT NULL COMMENT '部门ID',
`dept_id` int(0) NULL DEFAULT NULL COMMENT '部门ID',
`avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户头像',
`mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系方式',
`status` tinyint(1) NULL DEFAULT 1 COMMENT '用户状态((1:正常;0:禁用))',
`email` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户邮箱',
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除标识(0:未删除;1:已删除)',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `login_name`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 260 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 287 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户信息表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES (1, 'root', '有来技术', 0, '$2a$10$xVWsNOhHrCxh5UbpCE7/HuJ.PAOKcYAqRxD2CO2nVnJS.IAXkr5aq', NULL, 'https://s2.loli.net/2022/04/07/gw1L2Z5sPtS8GIl.gif', '17621590365', 1, 'youlaitech@163.com', 0, NULL, NULL);
INSERT INTO `sys_user` VALUES (2, 'admin', '系统管理员', 1, '$2a$10$xVWsNOhHrCxh5UbpCE7/HuJ.PAOKcYAqRxD2CO2nVnJS.IAXkr5aq', 2, 'https://s2.loli.net/2022/04/07/gw1L2Z5sPtS8GIl.gif', '17621210366', 1, '', 0, '2019-10-10 13:41:22', '2022-07-31 12:39:30');
INSERT INTO `sys_user` VALUES (3, 'test', '测试小用户', 1, '$2a$10$MPJkNw.hKT/fZOgwYP8q9eu/rFJJDsNov697AmdkHNJkpjIpVSw2q', 3, 'https://s2.loli.net/2022/04/07/gw1L2Z5sPtS8GIl.gif', '17621210366', 1, 'youlaitech@163.com', 1, '2021-06-05 01:31:29', '2021-06-05 01:31:29');
INSERT INTO `sys_user` VALUES (3, 'test', '测试小用户', 1, '$2a$10$xVWsNOhHrCxh5UbpCE7/HuJ.PAOKcYAqRxD2CO2nVnJS.IAXkr5aq', 3, 'https://s2.loli.net/2022/04/07/gw1L2Z5sPtS8GIl.gif', '17621210366', 1, 'youlaitech@163.com', 0, '2021-06-05 01:31:29', '2021-06-05 01:31:29');
-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role` (
`user_id` bigint NOT NULL COMMENT '用户ID',
`role_id` bigint NOT NULL COMMENT '角色ID',
`user_id` bigint(0) NOT NULL COMMENT '用户ID',
`role_id` bigint(0) 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;
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户和角色关联表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_user_role

View File

@@ -1,6 +1,7 @@
package com.youlai.system.common.enums;
import com.youlai.system.common.base.IBaseEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
/**
@@ -9,6 +10,7 @@ import lombok.Getter;
* @author haoxr
* @date 2022/10/14
*/
@Schema(enumAsRef = true)
public enum GenderEnum implements IBaseEnum<Integer> {
MALE(1, ""),

View File

@@ -17,7 +17,7 @@ public class PageResult<T> implements Serializable {
private String code;
private Data data;
private Data<T> data;
private String msg;

View File

@@ -1,18 +1,23 @@
package com.youlai.system.config;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.customizers.OperationCustomizer;
import org.springdoc.core.customizers.OpenApiCustomizer;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
/**
* 接口文档配置
* Swagger 配置
* <p>
* Spring Doc FAQ: https://springdoc.org/#faq
*
* @author haoxr
* @date 2023/2/17
@@ -20,55 +25,47 @@ import org.springframework.http.HttpHeaders;
@Configuration
public class SwaggerConfig {
/**
* 接口信息
*/
@Bean
public OpenAPI apiInfo() {
return new OpenAPI()
.components(new Components()
.addSecuritySchemes("Authorization",
new SecurityScheme().type(SecurityScheme.Type.HTTP)
.scheme("bearer").bearerFormat("JWT")
)
)
.info(new Info()
.title("youlai-boot 接口文档")
.version("2.0.0")
.description("接口文档")
.license(new License().name("Apache 2.0")
.url("https://www.youlai.tech"))
);
}
/**
* 接口分组-系统接口
*
* @param operationCustomizer
* @return
*/
@Bean
public GroupedOpenApi systemApi(OperationCustomizer operationCustomizer) {
return GroupedOpenApi.builder()
.group("系统接口")
.packagesToScan("com.youlai.system.controller")
.pathsToMatch( "/api/**")
.addOperationCustomizer(operationCustomizer)
public GroupedOpenApi groupedOpenApi() {
String paths[] = {"/api/**"};
String packagesToScan[] = {"com.youlai.system.controller"};
return GroupedOpenApi.builder().group("系统接口")
.packagesToScan(packagesToScan)
.pathsToMatch(paths)
.build();
}
/**
* 鉴权
*
* @return
*/
@Bean
public OperationCustomizer operationCustomizer() {
return (operation, handlerMethod) -> operation.addParametersItem(
new Parameter()
.in(SecurityScheme.In.HEADER.toString())
.name(HttpHeaders.AUTHORIZATION)
.required(true)
.description("token 校验"));
}
/**
* 接口信息
*
* @return
*/
@Bean
public OpenAPI apiInfo() {
return new OpenAPI().info(
new Info()
.title("youlai-boot接口文档")
.version("0.0.1")
.description("youlai-boot接口文档")
.license(new License().name("Apache 2.0")
.url("https://www.youlai.tech")
)
);
}
}

View File

@@ -4,6 +4,7 @@ import com.youlai.system.common.result.Result;
import com.youlai.system.pojo.vo.FileInfoVO;
import com.youlai.system.service.FileService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
@@ -11,7 +12,7 @@ import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@Tag(name = "文件接口")
@Tag(name = "08.文件接口")
@RestController
@RequestMapping("/api/v1/files")
@RequiredArgsConstructor
@@ -20,19 +21,19 @@ public class FileController {
private final FileService fileService;
@PostMapping
@Operation(summary = "文件上传")
@Operation(summary = "文件上传", security = {@SecurityRequirement(name = "Authorization")})
public Result<FileInfoVO> uploadFile(
@Parameter(name ="表单文件对象") @RequestParam(value = "file") MultipartFile file
@Parameter(description ="表单文件对象") @RequestParam(value = "file") MultipartFile file
) {
FileInfoVO fileInfoVO = fileService.uploadFile(file);
return Result.success(fileInfoVO);
}
@DeleteMapping
@Operation(summary = "文件删除")
@Operation(summary = "文件删除", security = {@SecurityRequirement(name = "Authorization")})
@SneakyThrows
public Result deleteFile(
@Parameter(name ="文件路径") @RequestParam String filePath
@Parameter(description ="文件路径") @RequestParam String filePath
) {
boolean result = fileService.deleteFile(filePath);
return Result.judge(result);

View File

@@ -7,6 +7,7 @@ import com.youlai.system.pojo.query.DeptQuery;
import com.youlai.system.pojo.vo.DeptVO;
import com.youlai.system.service.SysDeptService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
@@ -22,15 +23,13 @@ import java.util.List;
* @author haoxr
* @date 2020/11/6
*/
@Tag(name = "部门接口")
@Tag(name = "05.部门接口")
@RestController
@RequestMapping("/api/v1/dept")
@RequiredArgsConstructor
public class SysDeptController {
private final SysDeptService deptService;
@Operation(summary = "获取部门列表")
@Operation(summary = "获取部门列表", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping
public Result<List<DeptVO>> listDepartments(
@ParameterObject DeptQuery queryParams
@@ -39,23 +38,23 @@ public class SysDeptController {
return Result.success(list);
}
@Operation(summary = "获取部门下拉选项")
@Operation(summary = "获取部门下拉选项", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/options")
public Result<List<Option>> listDeptOptions() {
List<Option> list = deptService.listDeptOptions();
return Result.success(list);
}
@Operation(summary = "获取部门详情")
@Operation(summary = "获取部门详情", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{deptId}/form")
public Result<DeptForm> getDeptForm(
@Parameter(name ="部门ID") @PathVariable Long deptId
@Parameter(description ="部门ID") @PathVariable Long deptId
) {
DeptForm deptForm = deptService.getDeptForm(deptId);
return Result.success(deptForm);
}
@Operation(summary = "新增部门")
@Operation(summary = "新增部门", security = {@SecurityRequirement(name = "Authorization")})
@PostMapping
public Result saveDept(
@Valid @RequestBody DeptForm formData
@@ -64,7 +63,7 @@ public class SysDeptController {
return Result.success(id);
}
@Operation(summary = "修改部门")
@Operation(summary = "修改部门", security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{deptId}")
public Result updateDept(
@PathVariable Long deptId,
@@ -74,10 +73,10 @@ public class SysDeptController {
return Result.success(deptId);
}
@Operation(summary = "删除部门")
@Operation(summary = "删除部门", security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}")
public Result deleteDepartments(
@Parameter(name ="部门ID多个以英文逗号(,)分割") @PathVariable("ids") String ids
@Parameter(description ="部门ID多个以英文逗号(,)分割") @PathVariable("ids") String ids
) {
boolean result = deptService.deleteByIds(ids);
return Result.judge(result);

View File

@@ -0,0 +1,134 @@
package com.youlai.system.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.common.result.PageResult;
import com.youlai.system.common.result.Result;
import com.youlai.system.pojo.form.DictForm;
import com.youlai.system.pojo.form.DictTypeForm;
import com.youlai.system.pojo.query.DictPageQuery;
import com.youlai.system.pojo.query.DictTypePageQuery;
import com.youlai.system.pojo.vo.DictPageVO;
import com.youlai.system.pojo.vo.DictTypePageVO;
import com.youlai.system.pojo.vo.Option;
import com.youlai.system.service.SysDictService;
import com.youlai.system.service.SysDictTypeService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "07.字典接口")
@RestController
@RequestMapping("/api/v1/dict")
@RequiredArgsConstructor
public class SysDictController {
private final SysDictService dictService;
private final SysDictTypeService dictTypeService;
@Operation(summary = "字典分页列表", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/page")
public PageResult<DictPageVO> getDictPage(
@ParameterObject DictPageQuery queryParams
) {
Page<DictPageVO> result = dictService.getDictPage(queryParams);
return PageResult.success(result);
}
@Operation(summary = "字典数据表单数据", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{id}/form")
public Result<DictForm> getDictForm(
@Parameter(description ="字典ID") @PathVariable Long id
) {
DictForm formData = dictService.getDictForm(id);
return Result.success(formData);
}
@Operation(summary = "新增字典", security = {@SecurityRequirement(name = "Authorization")})
@PostMapping
public Result saveDict(
@RequestBody DictForm DictForm
) {
boolean result = dictService.saveDict(DictForm);
return Result.judge(result);
}
@Operation(summary = "修改字典", security = {@SecurityRequirement(name = "Authorization")})
@PutMapping("/{id}")
public Result updateDict(
@PathVariable Long id,
@RequestBody DictForm DictForm
) {
boolean status = dictService.updateDict(id, DictForm);
return Result.judge(status);
}
@Operation(summary = "删除字典", security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}")
public Result deleteDict(
@Parameter(description ="字典ID多个以英文逗号(,)拼接") @PathVariable String ids
) {
boolean result = dictService.deleteDict(ids);
return Result.judge(result);
}
@Operation(summary = "字典下拉列表", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/options")
public Result<List<Option>> listDictOptions(
@Parameter(description ="字典类型编码") @RequestParam String typeCode
) {
List<Option> list = dictService.listDictOptions(typeCode);
return Result.success(list);
}
/*----------------------------------------------------*/
@Operation(summary = "字典类型分页列表", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/types/page")
public PageResult<DictTypePageVO> getDictTypePage(
@ParameterObject DictTypePageQuery queryParams
) {
Page<DictTypePageVO> result = dictTypeService.getDictTypePage(queryParams);
return PageResult.success(result);
}
@Operation(summary = "字典类型表单数据", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/types/{id}/form")
public Result<DictTypeForm> getDictTypeForm(
@Parameter(description ="字典ID") @PathVariable Long id
) {
DictTypeForm dictTypeForm = dictTypeService.getDictTypeForm(id);
return Result.success(dictTypeForm);
}
@Operation(summary = "新增字典类型", security = {@SecurityRequirement(name = "Authorization")})
@PostMapping("/types")
public Result saveDictType(@RequestBody DictTypeForm dictTypeForm) {
boolean result = dictTypeService.saveDictType(dictTypeForm);
return Result.judge(result);
}
@Operation(summary = "修改字典类型", security = {@SecurityRequirement(name = "Authorization")})
@PutMapping("/types/{id}")
public Result updateDictType(@PathVariable Long id, @RequestBody DictTypeForm dictTypeForm) {
boolean status = dictTypeService.updateDictType(id, dictTypeForm);
return Result.judge(status);
}
@Operation(summary = "删除字典类型", security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/types/{ids}")
public Result deleteDictTypes(
@Parameter(description ="字典类型ID多个以英文逗号(,)分割") @PathVariable String ids
) {
boolean result = dictTypeService.deleteDictTypes(ids);
return Result.judge(result);
}
}

View File

@@ -1,71 +0,0 @@
package com.youlai.system.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.common.result.PageResult;
import com.youlai.system.common.result.Result;
import com.youlai.system.pojo.form.DictItemForm;
import com.youlai.system.pojo.query.DictItemPageQuery;
import com.youlai.system.pojo.vo.DictItemPageVO;
import com.youlai.system.service.SysDictItemService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;
@Tag(name = "字典数据接口")
@RestController
@RequestMapping("/api/v1/dict/items")
@RequiredArgsConstructor
public class SysDictItemController {
private final SysDictItemService dictItemService;
@Operation(summary = "字典数据分页列表")
@GetMapping("/pages")
public PageResult<DictItemPageVO> listDictItemPages(
@ParameterObject DictItemPageQuery queryParams
) {
Page<DictItemPageVO> result = dictItemService.listDictItemPages(queryParams);
return PageResult.success(result);
}
@Operation(summary = "字典数据表单数据")
@GetMapping("/{id}/form")
public Result<DictItemForm> getDictItemForm(
@Parameter(name ="字典ID") @PathVariable Long id
) {
DictItemForm formData = dictItemService.getDictItemForm(id);
return Result.success(formData);
}
@Operation(summary = "新增字典数据")
@PostMapping
public Result saveDictItem(
@RequestBody DictItemForm DictItemForm
) {
boolean result = dictItemService.saveDictItem(DictItemForm);
return Result.judge(result);
}
@Operation(summary = "修改字典数据")
@PutMapping("/{id}")
public Result updateDictItem(
@PathVariable Long id,
@RequestBody DictItemForm DictItemForm
) {
boolean status = dictItemService.updateDictItem(id, DictItemForm);
return Result.judge(status);
}
@Operation(summary = "删除字典")
@DeleteMapping("/{ids}")
public Result deleteDictItems(
@Parameter(name ="字典ID多个以英文逗号(,)拼接") @PathVariable String ids
) {
boolean result = dictItemService.deleteDictItems(ids);
return Result.judge(result);
}
}

View File

@@ -1,77 +0,0 @@
package com.youlai.system.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.pojo.vo.Option;
import com.youlai.system.common.result.PageResult;
import com.youlai.system.common.result.Result;
import com.youlai.system.pojo.form.DictTypeForm;
import com.youlai.system.pojo.query.DictTypePageQuery;
import com.youlai.system.pojo.vo.DictTypePageVO;
import com.youlai.system.service.SysDictTypeService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "字典类型接口")
@RestController
@RequestMapping("/api/v1/dict/types")
@RequiredArgsConstructor
public class SysDictTypeController {
private final SysDictTypeService dictTypeService;
@Operation(summary = "字典类型分页列表")
@GetMapping("/pages")
public PageResult<DictTypePageVO> listDictTypePages(
@ParameterObject DictTypePageQuery queryParams
) {
Page<DictTypePageVO> result = dictTypeService.listDictTypePages(queryParams);
return PageResult.success(result);
}
@Operation(summary = "字典类型表单详情")
@GetMapping("/{id}/form")
public Result<DictTypeForm> getDictTypeFormData(
@Parameter(name ="字典ID") @PathVariable Long id
) {
DictTypeForm dictTypeForm = dictTypeService.getDictTypeFormData(id);
return Result.success(dictTypeForm);
}
@Operation(summary = "新增字典类型")
@PostMapping
public Result saveDictType(@RequestBody DictTypeForm dictTypeForm) {
boolean result = dictTypeService.saveDictType(dictTypeForm);
return Result.judge(result);
}
@Operation(summary = "修改字典类型")
@PutMapping("/{id}")
public Result updateDict(@PathVariable Long id, @RequestBody DictTypeForm dictTypeForm) {
boolean status = dictTypeService.updateDictType(id, dictTypeForm);
return Result.judge(status);
}
@Operation(summary = "删除字典类型")
@DeleteMapping("/{ids}")
public Result deleteDictTypes(
@Parameter(name ="字典类型ID多个以英文逗号(,)分割") @PathVariable String ids
) {
boolean result = dictTypeService.deleteDictTypes(ids);
return Result.judge(result);
}
@Operation(summary = "获取字典类型的数据项")
@GetMapping("/{typeCode}/items")
public Result<List<Option>> listDictItemsByTypeCode(
@Parameter(name ="字典类型编码") @PathVariable String typeCode
) {
List<Option> list = dictTypeService.listDictItemsByTypeCode(typeCode);
return Result.success(list);
}
}

View File

@@ -1,14 +1,15 @@
package com.youlai.system.controller;
import com.youlai.system.pojo.form.MenuForm;
import com.youlai.system.pojo.vo.Option;
import com.youlai.system.common.result.Result;
import com.youlai.system.pojo.entity.SysMenu;
import com.youlai.system.pojo.query.MenuQuery;
import com.youlai.system.pojo.vo.MenuVO;
import com.youlai.system.pojo.vo.ResourceVO;
import com.youlai.system.pojo.vo.RouteVO;
import com.youlai.system.service.SysMenuService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
@@ -26,7 +27,7 @@ import java.util.List;
* @author haoxr
* @date 2020/11/06
*/
@Tag(name = "菜单接口")
@Tag(name = "04.菜单接口")
@RestController
@RequestMapping("/api/v1/menus")
@RequiredArgsConstructor
@@ -35,76 +36,69 @@ public class SysMenuController {
private final SysMenuService menuService;
@Operation(summary = "资源(菜单+权限)列表")
@GetMapping("/resources")
public Result<List<ResourceVO>> listResources() {
List<ResourceVO> resources = menuService.listResources();
return Result.success(resources);
}
@Operation(summary = "菜单列表")
@Operation(summary = "菜单列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping
public Result listMenus( @ParameterObject MenuQuery queryParams) {
public Result<List<MenuVO>> listMenus( @ParameterObject MenuQuery queryParams) {
List<MenuVO> menuList = menuService.listMenus(queryParams);
return Result.success(menuList);
}
@Operation(summary = "菜单下拉列表")
@Operation(summary = "菜单下拉列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/options")
public Result listMenuOptions() {
List<Option> menus = menuService.listMenuOptions();
return Result.success(menus);
}
@Operation(summary = "路由列表")
@Operation(summary = "路由列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/routes")
public Result listRoutes() {
public Result<List<RouteVO>> listRoutes() {
List<RouteVO> routeList = menuService.listRoutes();
return Result.success(routeList);
}
@Operation(summary = "菜单详情")
@GetMapping("/{id}")
public Result detail(
@Parameter(name = "菜单ID") @PathVariable Long id
@Operation(summary = "菜单表单数据",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{id}/form")
public Result<MenuForm> getMenuForm(
@Parameter(description = "菜单ID") @PathVariable Long id
) {
SysMenu menu = menuService.getById(id);
MenuForm menu = menuService.getMenuForm(id);
return Result.success(menu);
}
@Operation(summary = "新增菜单")
@Operation(summary = "新增菜单",security = {@SecurityRequirement(name = "Authorization")})
@PostMapping
@CacheEvict(cacheNames = "system", key = "'routes'")
public Result addMenu(@RequestBody SysMenu menu) {
boolean result = menuService.saveMenu(menu);
public Result addMenu(@RequestBody MenuForm menuForm) {
boolean result = menuService.saveMenu(menuForm);
return Result.judge(result);
}
@Operation(summary = "修改菜单")
@Operation(summary = "修改菜单",security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{id}")
@CacheEvict(cacheNames = "system", key = "'routes'")
public Result updateMenu(
@RequestBody SysMenu menu
@RequestBody MenuForm menuForm
) {
boolean result = menuService.saveMenu(menu);
boolean result = menuService.saveMenu(menuForm);
return Result.judge(result);
}
@Operation(summary = "删除菜单")
@DeleteMapping("/{ids}")
@Operation(summary = "删除菜单",security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{id}")
@CacheEvict(cacheNames = "system", key = "'routes'")
public Result deleteMenus(
@Parameter(name ="菜单ID多个以英文(,)分割") @PathVariable("ids") String ids
public Result deleteMenu(
@Parameter(description ="菜单ID多个以英文(,)分割") @PathVariable("id") Long id
) {
boolean result = menuService.removeByIds(Arrays.asList(ids.split(",")));
boolean result = menuService.deleteMenu(id);
return Result.judge(result);
}
@Operation(summary = "修改菜单显示状态")
@Operation(summary = "修改菜单显示状态",security = {@SecurityRequirement(name = "Authorization")})
@PatchMapping("/{menuId}")
public Result updateMenuVisible(
@Parameter(name = "菜单ID") @PathVariable Long menuId,
@Parameter(name = "显示状态(1:显示;0:隐藏)") Integer visible
@Parameter(description = "菜单ID") @PathVariable Long menuId,
@Parameter(description = "显示状态(1:显示;0:隐藏)") Integer visible
) {
boolean result =menuService.updateMenuVisible(menuId, visible);

View File

@@ -4,12 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.pojo.vo.Option;
import com.youlai.system.common.result.PageResult;
import com.youlai.system.common.result.Result;
import com.youlai.system.pojo.entity.SysRole;
import com.youlai.system.pojo.form.RoleForm;
import com.youlai.system.pojo.query.RolePageQuery;
import com.youlai.system.pojo.vo.RolePageVO;
import com.youlai.system.service.SysRoleService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.List;
@Tag(name = "角色接口")
@Tag(name = "03.角色接口")
@RestController
@RequestMapping("/api/v1/roles")
@RequiredArgsConstructor
@@ -27,74 +27,74 @@ public class SysRoleController {
private final SysRoleService roleService;
@Operation(summary = "角色分页列表")
@GetMapping("/pages")
public PageResult<RolePageVO> listRolePages(
@Operation(summary = "角色分页列表",security = {@SecurityRequirement(name = "Authorization")} )
@GetMapping("/page")
public PageResult<RolePageVO> getRolePage(
@ParameterObject RolePageQuery queryParams
) {
Page<RolePageVO> result = roleService.listRolePages(queryParams);
Page<RolePageVO> result = roleService.getRolePage(queryParams);
return PageResult.success(result);
}
@Operation(summary = "角色下拉列表")
@Operation(summary = "角色下拉列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/options")
public Result<List<Option>> listRoleOptions() {
List<Option> list = roleService.listRoleOptions();
return Result.success(list);
}
@Operation(summary = "角色详情")
@GetMapping("/{roleId}")
public Result getRoleDetail(
@Parameter(name ="角色ID") @PathVariable Long roleId
) {
SysRole role = roleService.getById(roleId);
return Result.success(role);
}
@Operation(summary = "新增角色")
@Operation(summary = "新增角色",security = {@SecurityRequirement(name = "Authorization")})
@PostMapping
public Result addRole(@Valid @RequestBody RoleForm roleForm) {
boolean result = roleService.saveRole(roleForm);
return Result.judge(result);
}
@Operation(summary = "修改角色")
@Operation(summary = "角色表单数据",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{roleId}/form")
public Result<RoleForm> getRoleForm(
@Parameter(description ="角色ID") @PathVariable Long roleId
) {
RoleForm roleForm = roleService.getRoleForm(roleId);
return Result.success(roleForm);
}
@Operation(summary = "修改角色",security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{id}")
public Result updateRole(@Valid @RequestBody RoleForm roleForm) {
boolean result = roleService.saveRole(roleForm);
return Result.judge(result);
}
@Operation(summary = "删除角色")
@Operation(summary = "删除角色",security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}")
public Result deleteRoles(
@Parameter(name ="删除角色,多个以英文逗号(,)分割") @PathVariable String ids
@Parameter(description ="删除角色,多个以英文逗号(,)分割") @PathVariable String ids
) {
boolean result = roleService.deleteRoles(ids);
return Result.judge(result);
}
@Operation(summary = "修改角色状态")
@Operation(summary = "修改角色状态",security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{roleId}/status")
public Result updateRoleStatus(
@Parameter(name ="角色ID") @PathVariable Long roleId,
@Parameter(name ="角色状态:1-启用0-禁用") @RequestParam Integer status
@Parameter(description ="角色ID") @PathVariable Long roleId,
@Parameter(description ="状态(1:启用;0:禁用)") @RequestParam Integer status
) {
boolean result = roleService.updateRoleStatus(roleId, status);
return Result.judge(result);
}
@Operation(summary = "获取角色的菜单ID集合")
@Operation(summary = "获取角色的菜单ID集合",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{roleId}/menuIds")
public Result<List<Long>> getRoleMenuIds(
@Parameter(name ="角色ID") @PathVariable Long roleId
@Parameter(description ="角色ID") @PathVariable Long roleId
) {
List<Long> resourceIds = roleService.getRoleMenuIds(roleId);
return Result.success(resourceIds);
List<Long> menuIds = roleService.getRoleMenuIds(roleId);
return Result.success(menuIds);
}
@Operation(summary = "分配角色的资源权限")
@Operation(summary = "分配菜单权限给角色",security = {@SecurityRequirement(name = "Authorization")})
@PutMapping("/{roleId}/menus")
public Result updateRoleMenus(
@PathVariable Long roleId,

View File

@@ -17,6 +17,7 @@ import com.youlai.system.pojo.vo.UserInfoVO;
import com.youlai.system.pojo.vo.UserPageVO;
import com.youlai.system.service.SysUserService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
@@ -42,7 +43,7 @@ import java.util.List;
* @author haoxr
* @date 2022/10/16
*/
@Tag(name = "用户接口")
@Tag(name = "02.用户接口")
@RestController
@RequestMapping("/api/v1/users")
@RequiredArgsConstructor
@@ -50,25 +51,16 @@ public class SysUserController {
private final SysUserService userService;
@Operation(summary = "用户分页列表")
@GetMapping("/pages")
public PageResult<UserPageVO> listUserPages(
@Operation(summary = "用户分页列表", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/page")
public PageResult<UserPageVO> getUserPage(
@ParameterObject UserPageQuery queryParams
) {
IPage<UserPageVO> result = userService.listUserPages(queryParams);
IPage<UserPageVO> result = userService.getUserPage(queryParams);
return PageResult.success(result);
}
@Operation(summary = "用户表单数据")
@GetMapping("/{userId}/form")
public Result<UserForm> getUserForm(
@Parameter(name = "用户ID") @PathVariable Long userId
) {
UserForm formData = userService.getUserFormData(userId);
return Result.success(formData);
}
@Operation(summary = "新增用户")
@Operation(summary = "新增用户", security = {@SecurityRequirement(name = "Authorization")})
@PostMapping
@PreAuthorize("@pms.hasPermission('sys:user:add')")
public Result saveUser(
@@ -78,41 +70,50 @@ public class SysUserController {
return Result.judge(result);
}
@Operation(summary = "修改用户")
@Operation(summary = "用户表单数据", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{userId}/form")
public Result<UserForm> getUserForm(
@Parameter(description = "用户ID") @PathVariable Long userId
) {
UserForm formData = userService.getUserFormData(userId);
return Result.success(formData);
}
@Operation(summary = "修改用户", security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{userId}")
@PreAuthorize("@pms.hasPermission('sys:user:edit')")
public Result updateUser(
@Parameter(name = "用户ID") @PathVariable Long userId,
@Parameter(description = "用户ID") @PathVariable Long userId,
@RequestBody @Validated UserForm userForm) {
boolean result = userService.updateUser(userId, userForm);
return Result.judge(result);
}
@Operation(summary = "删除用户")
@Operation(summary = "删除用户", security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}")
@PreAuthorize("@pms.hasPermission('sys:user:delete')")
public Result deleteUsers(
@Parameter(name = "用户ID多个以英文逗号(,)分割") @PathVariable String ids
@Parameter(description = "用户ID多个以英文逗号(,)分割") @PathVariable String ids
) {
boolean result = userService.deleteUsers(ids);
return Result.judge(result);
}
@Operation(summary = "修改用户密码")
@Operation(summary = "修改用户密码", security = {@SecurityRequirement(name = "Authorization")})
@PatchMapping(value = "/{userId}/password")
public Result updatePassword(
@Parameter(name = "用户ID") @PathVariable Long userId,
@Parameter(description = "用户ID") @PathVariable Long userId,
@RequestParam String password
) {
boolean result = userService.updatePassword(userId, password);
return Result.judge(result);
}
@Operation(summary = "修改用户状态")
@Operation(summary = "修改用户状态", security = {@SecurityRequirement(name = "Authorization")})
@PatchMapping(value = "/{userId}/status")
public Result updatePassword(
@Parameter(name = "用户ID") @PathVariable Long userId,
@Parameter(name = "用户状态(1:启用;0:禁用)") @RequestParam Integer status
@Parameter(description = "用户ID") @PathVariable Long userId,
@Parameter(description = "用户状态(1:启用;0:禁用)") @RequestParam Integer status
) {
boolean result = userService.update(new LambdaUpdateWrapper<SysUser>()
.eq(SysUser::getId, userId)
@@ -121,14 +122,14 @@ public class SysUserController {
return Result.judge(result);
}
@Operation(summary = "获取当前登录用户信息")
@Operation(summary = "获取当前登录用户信息", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/me")
public Result<UserInfoVO> getUserLoginInfo() {
UserInfoVO userInfoVO = userService.getUserLoginInfo();
return Result.success(userInfoVO);
}
@Operation(summary = "用户导入模板下载")
@Operation(summary = "用户导入模板下载", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/template")
public void downloadTemplate(HttpServletResponse response) throws IOException {
String fileName = "用户导入模板.xlsx";
@@ -144,15 +145,15 @@ public class SysUserController {
excelWriter.finish();
}
@Operation(summary = "导入用户")
@Operation(summary = "导入用户", security = {@SecurityRequirement(name = "Authorization")})
@PostMapping("/_import")
public Result importUsers(@Parameter(name = "部门ID") Long deptId, MultipartFile file) throws IOException {
public Result importUsers(@Parameter(description = "部门ID") Long deptId, MultipartFile file) throws IOException {
UserImportListener listener = new UserImportListener(deptId);
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportVO.class, listener);
return Result.success(msg);
}
@Operation(summary = "导出用户")
@Operation(summary = "导出用户", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/_export")
public void exportUsers(UserPageQuery queryParams, HttpServletResponse response) throws IOException {
String fileName = "用户列表.xlsx";

View File

@@ -1,9 +1,9 @@
package com.youlai.system.converter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.pojo.entity.SysDictItem;
import com.youlai.system.pojo.form.DictItemForm;
import com.youlai.system.pojo.vo.DictItemPageVO;
import com.youlai.system.pojo.entity.SysDict;
import com.youlai.system.pojo.form.DictForm;
import com.youlai.system.pojo.vo.DictPageVO;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
@@ -14,12 +14,12 @@ import org.mapstruct.Mapper;
* @date 2022/6/8
*/
@Mapper(componentModel = "spring")
public interface DictItemConverter {
public interface DictConverter {
Page<DictItemPageVO> entity2Page(Page<SysDictItem> page);
Page<DictPageVO> entity2Page(Page<SysDict> page);
DictItemForm entity2Form(SysDictItem entity);
DictForm entity2Form(SysDict entity);
@InheritInverseConfiguration(name="entity2Form")
SysDictItem form2Entity(DictItemForm entity);
SysDict form2Entity(DictForm entity);
}

View File

@@ -1,6 +1,7 @@
package com.youlai.system.converter;
import com.youlai.system.pojo.entity.SysMenu;
import com.youlai.system.pojo.form.MenuForm;
import com.youlai.system.pojo.vo.MenuVO;
import org.mapstruct.Mapper;
@@ -13,6 +14,11 @@ import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface MenuConverter {
MenuVO entity2VO(SysMenu entity);
MenuVO entity2Vo(SysMenu entity);
MenuForm entity2Form(SysMenu entity);
SysMenu form2Entity(MenuForm menuForm);
}

View File

@@ -26,10 +26,12 @@ public interface RoleConverter {
@Mapping(target = "value", source = "id"),
@Mapping(target = "label", source = "name")
})
Option role2Option(SysRole role);
Option entity2Option(SysRole role);
List<Option> roles2Options(List<SysRole> roles);
List<Option> entities2Options(List<SysRole> roles);
SysRole form2Entity(RoleForm roleForm);
RoleForm entity2Form(SysRole entity);
}

View File

@@ -24,7 +24,7 @@ public class RequestLogFilter extends CommonsRequestLoggingFilter {
@Override
protected void beforeRequest(HttpServletRequest request, String message) {
String requestURI = request.getRequestURI();
log.info("request uri{}", requestURI);
log.info("request uri: {}", requestURI);
super.beforeRequest(request, message);
}

View File

@@ -4,7 +4,6 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler;
import com.youlai.system.common.annotation.DataPermission;
import com.youlai.system.common.base.IBaseEnum;
import com.youlai.system.common.enums.DataScopeEnum;
import com.youlai.system.framework.security.util.SecurityUtils;

View File

@@ -26,7 +26,6 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import java.util.List;
import java.util.stream.Collectors;
/**
* 用户导入监听器
* <p>

View File

@@ -1,11 +1,11 @@
package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youlai.system.pojo.entity.SysDictItem;
import com.youlai.system.pojo.entity.SysDict;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
public interface SysDictMapper extends BaseMapper<SysDict> {
}

View File

@@ -2,7 +2,7 @@ package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.common.annotation.DataPermission;
import com.youlai.system.framework.mybatisplus.DataPermission;
import com.youlai.system.pojo.bo.UserBO;
import com.youlai.system.pojo.entity.SysUser;
import com.youlai.system.pojo.bo.UserAuthInfo;
@@ -30,7 +30,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return
*/
@DataPermission(deptAlias = "u")
Page<UserBO> listUserPages(Page<UserBO> page, UserPageQuery queryParams);
Page<UserBO> getUserPage(Page<UserBO> page, UserPageQuery queryParams);
/**
* 获取用户表单详情

View File

@@ -12,6 +12,9 @@ public class LoginResult {
@Schema(description = "访问token")
private String accessToken;
@Schema(description = "token 类型",example = "Bearer")
private String tokenType;
@Schema(description = "刷新token")
private String refreshToken;

View File

@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@@ -14,9 +14,8 @@ import lombok.Data;
* @author haoxr
* @date 2022/12/17
*/
@TableName(value ="sys_dict_item")
@Data
public class SysDictItem implements Serializable {
public class SysDict implements Serializable {
/**
* 主键
*/

View File

@@ -1,17 +1,12 @@
package com.youlai.system.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import com.youlai.system.common.base.BaseEntity;
import lombok.Data;
/**
* 字典类型
* 字典类型实体
*
* @author haoxr
* @date 2022/12/17

View File

@@ -9,13 +9,16 @@ import com.youlai.system.common.enums.MenuTypeEnum;
import lombok.Data;
/**
* 菜单实体
* 菜单实体对象
*
* @author haoxr
* @date 2023/3/6
*/
@TableName(value ="sys_menu")
@Data
public class SysMenu extends BaseEntity {
/**
*
* 菜单ID
*/
@TableId(type = IdType.AUTO)
private Long id;
@@ -66,8 +69,8 @@ public class SysMenu extends BaseEntity {
private String icon;
/**
* 外链路径
* 跳转路径
*/
private String redirectUrl;
private String redirect;
}

View File

@@ -1,16 +1,14 @@
package com.youlai.system.pojo.form;
import com.youlai.system.common.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Schema(description = "部门表单对象")
@Data
public class DeptForm extends BaseEntity {
public class DeptForm {
@Schema(description="部门ID(新增不填)")
@Schema(description="部门ID")
private Long id;
@Schema(description="部门名称")
@@ -20,10 +18,10 @@ public class DeptForm extends BaseEntity {
@NotNull(message = "父部门ID不能为空")
private Long parentId;
@Schema(description="状态")
@Schema(description="状态(1:启用;0:禁用)")
private Integer status;
@Schema(description="排序")
@Schema(description="排序(数字越小排名越靠前)")
private Integer sort;
}

View File

@@ -1,31 +1,32 @@
package com.youlai.system.pojo.form;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "字典数据项")
@Schema(description = "字典表单对象")
@Data
public class DictItemForm {
public class DictForm {
@Schema(description="数据项ID")
@Schema(description="字典ID")
private Long id;
@Schema(description="类型编码")
private String typeCode;
@Schema(description="数据项名称")
@Schema(description="字典名称")
private String name;
@Schema(description="")
@Schema(description="字典")
private String value;
@Schema(description="状态1->启用;0->禁用")
@Schema(description="状态(1:启用;0:禁用)")
private Integer status;
@Schema(description="排序")
private Integer sort;
@Schema(description = "字典备注")
private String remark;
}

View File

@@ -1,8 +1,6 @@
package com.youlai.system.pojo.form;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -19,7 +17,10 @@ public class DictTypeForm {
@Schema(description="类型编码")
private String code;
@Schema(description="类型状态1->启用;0->禁用")
@Schema(description="类型状态(1:启用;0:禁用)")
private Integer status;
@Schema(description = "备注")
private String remark;
}

View File

@@ -0,0 +1,44 @@
package com.youlai.system.pojo.form;
import com.youlai.system.common.enums.MenuTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "菜单表单对象")
@Data
public class MenuForm {
@Schema(description = "菜单ID")
private Long id;
@Schema(description = "父菜单ID")
private Long parentId;
@Schema(description = "菜单名称")
private String name;
@Schema(description = "菜单类型(1-菜单2-目录3-外链4-按钮权限)")
private MenuTypeEnum type;
@Schema(description = "路由路径")
private String path;
@Schema(description = "组件路径(vue页面完整路径省略.vue后缀)")
private String component;
@Schema(description = "权限标识")
private String perm;
@Schema(description = "显示状态(1:显示;0:隐藏)")
private Integer visible;
@Schema(description = "排序(数字越小排名越靠前)")
private Integer sort;
@Schema(description = "菜单图标")
private String icon;
@Schema(description = "跳转路径")
private String redirect;
}

View File

@@ -1,31 +0,0 @@
package com.youlai.system.pojo.form;
import lombok.Data;
import java.util.List;
/**
* 角色权限传输层对象
*
* @author haoxr
* @date 2021/12/19 11:46
*/
@Data
public class RolePermsForm {
/**
* 菜单ID
*/
private Long menuId;
/**
* 角色ID
*/
private Long roleId;
/**
* 权限ID集合
*/
private List<Long> permIds;
}

View File

@@ -1,20 +0,0 @@
package com.youlai.system.pojo.form;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description ="菜单资源表单")
@Data
public class RoleResourceForm {
@Schema(description="菜单ID集合")
private List<Long> menuIds;
@Schema(description="权限ID集合")
private List<Long> permIds;
}

View File

@@ -14,7 +14,7 @@ import java.util.List;
* @author haoxr
* @date 2022/4/12 11:04
*/
@Schema
@Schema(description = "用户表单对象")
@Data
public class UserForm {

View File

@@ -3,12 +3,11 @@ package com.youlai.system.pojo.query;
import com.youlai.system.common.base.BasePageQuery;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description ="字典数据项分页查询对象")
@Data
public class DictItemPageQuery extends BasePageQuery {
public class DictPageQuery extends BasePageQuery {
@Schema(description="关键字(字典项名称)")
private String keywords;

View File

@@ -1,28 +1,38 @@
package com.youlai.system.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "部门视图对象")
@Data
public class DeptVO {
@Schema(description = "部门ID")
private Long id;
@Schema(description = "父部门ID")
private Long parentId;
@Schema(description = "部门名称")
private String name;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "状态(1:启用0:禁用)")
private Integer status;
@Schema(description = "子部门")
private List<DeptVO> children;
@Schema(description = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime createTime;
@Schema(description = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime updateTime;

View File

@@ -1,24 +0,0 @@
package com.youlai.system.pojo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description ="字典数据项分页对象")
@Data
public class DictItemPageVO {
@Schema(description="数据项ID")
private Long id;
@Schema(description="数据项名称")
private String name;
@Schema(description="")
private String value;
@Schema(description="类型状态1->启用;0->禁用")
private Integer status;
}

View File

@@ -0,0 +1,23 @@
package com.youlai.system.pojo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description ="字典分页对象")
@Data
public class DictPageVO {
@Schema(description="字典ID")
private Long id;
@Schema(description="字典名称")
private String name;
@Schema(description="字典值")
private String value;
@Schema(description="状态(1:启用;0:禁用)")
private Integer status;
}

View File

@@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description ="字典类型")
@Schema(description ="字典类型分页对象")
@Data
public class DictTypePageVO {
@@ -18,7 +18,7 @@ public class DictTypePageVO {
@Schema(description="类型编码")
private String code;
@Schema(description="类型状态1->启用;0->禁用")
@Schema(description="状态1:启用;0:禁用")
private Integer status;
}

View File

@@ -1,12 +1,16 @@
package com.youlai.system.pojo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "文件对象")
@Data
public class FileInfoVO {
@Schema(description = "文件名称")
private String name;
@Schema(description = "文件URL")
private String url;
}

View File

@@ -1,30 +0,0 @@
package com.youlai.system.pojo.vo;
import lombok.Data;
@Data
public class MenuDetailVO {
private Long id;
private Long parentId;
private String name;
private String icon;
private String routeName;
private String routePath;
private String component;
private Integer sort;
private Integer visible;
private String redirect;
private Integer type;
}

View File

@@ -11,24 +11,34 @@ import java.util.List;
@Data
public class MenuVO {
@Schema(description = "菜单ID")
private Long id;
@Schema(description = "父菜单ID")
private Long parentId;
@Schema(description = "菜单名称")
private String name;
@Schema(description = "ICON")
private String icon;
@Schema(description = "路由名称")
private String routeName;
@Schema(description = "路由相对路径")
private String routePath;
@Schema(description = "组件路径")
private String component;
@Schema(description = "菜单排序(数字越小排名越靠前)")
private Integer sort;
@Schema(description = "菜单是否可见(1:显示;0:隐藏)")
private Integer visible;
@Schema(description = "跳转路径")
private String redirect;
@Schema(description="菜单类型")
@@ -37,6 +47,7 @@ public class MenuVO {
@Schema(description="按钮权限标识")
private String perm;
@Schema(description = "子菜单")
@JsonInclude(value = JsonInclude.Include.NON_NULL)
private List<MenuVO> children;

View File

@@ -35,6 +35,7 @@ public class Option<T> {
@Schema(description="选项的标签")
private String label;
@Schema(description="子选项列表")
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<Option> children;

View File

@@ -1,24 +0,0 @@
package com.youlai.system.pojo.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description ="资源(菜单+权限)视图对象")
@Data
public class ResourceVO {
@Schema(description="选项的值")
private Long value;
@Schema(description="选项的标签")
private String label;
@Schema(description="子菜单")
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<ResourceVO> children;
}

View File

@@ -2,12 +2,11 @@ package com.youlai.system.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description ="角色分页视图对象")
@Schema(description ="角色分页对象")
@Data
public class RolePageVO {

View File

@@ -1,6 +1,7 @@
package com.youlai.system.pojo.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@@ -11,41 +12,46 @@ import java.util.List;
* @author haoxr
* @date 2020/11/28
*/
@Schema(description = "路由对象")
@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class RouteVO {
@Schema(description = "路由路径", example = "user")
private String path;
@Schema(description = "组件路径", example = "system/user/index")
private String component;
@Schema(description = "跳转链接", example = "https://www.youlai.tech")
private String redirect;
@Schema(description = "路由名称")
private String name;
@Schema(description = "路由属性")
private Meta meta;
@Schema(description = "路由属性类型")
@Data
public static class Meta {
@Schema(description = "路由title")
private String title;
@Schema(description = "ICON")
private String icon;
@Schema(description = "是否隐藏", example = "true")
private Boolean hidden;
/**
* 如果设置为 true目录没有子节点也会显示
*/
private Boolean alwaysShow;
@Schema(description = "拥有路由权限的角色编码", example = "['ADMIN','ROOT']")
private List<String> roles;
/**
* 页面缓存开启状态
*/
@Schema(description = "是否开启缓存", example = "true")
private Boolean keepAlive;
}
@Schema(description = "子路由列表")
private List<RouteVO> children;
}

View File

@@ -1,49 +0,0 @@
package com.youlai.system.pojo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* 用户表详情视图对象
*
* @author haoxr
* @date 2022/8/25
*/
@Schema
@Data
public class UserDetailVO {
@Schema(description="用户ID")
private Long id;
@Schema(description="用户名")
private String username;
@Schema(description="昵称")
private String nickname;
@Schema(description="")
private String mobile;
@Schema(description="性别")
private Integer gender;
@Schema(description="用户头像")
private String avatar;
@Schema(description="邮箱")
private String email;
@Schema(description="用户状态(1:正常;0:禁用)")
private Integer status;
@Schema(description="部门ID")
private Long deptId;
@Schema(description="角色ID集合")
private List<Long> roleIds;
}

View File

@@ -12,7 +12,7 @@ import java.util.Date;
* @author haoxr
* @date 2022/1/15 9:41
*/
@Schema(description ="用户分页视图对象")
@Schema(description ="用户分页对象")
@Data
public class UserPageVO {

View File

@@ -1,54 +0,0 @@
package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.pojo.entity.SysDictItem;
import com.youlai.system.pojo.form.DictItemForm;
import com.youlai.system.pojo.query.DictItemPageQuery;
import com.youlai.system.pojo.vo.DictItemPageVO;
/**
*
*/
public interface SysDictItemService extends IService<SysDictItem> {
/**
* 字典数据项分页列表
*
* @param queryParams
* @return
*/
Page<DictItemPageVO> listDictItemPages(DictItemPageQuery queryParams);
/**
* 字典数据项表单详情
*
* @param id 字典数据项ID
* @return
*/
DictItemForm getDictItemForm(Long id);
/**
* 新增字典数据项
*
* @param dictItemForm 字典数据项表单
* @return
*/
boolean saveDictItem(DictItemForm dictItemForm);
/**
* 修改字典数据项
*
* @param id 字典数据项ID
* @param dictItemForm 字典数据项表单
* @return
*/
boolean updateDictItem(Long id, DictItemForm dictItemForm);
/**
* 删除字典数据项
*
* @param idsStr 字典数据项ID多个以英文逗号(,)分割
* @return
*/
boolean deleteDictItems(String idsStr);
}

View File

@@ -0,0 +1,68 @@
package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.pojo.entity.SysDict;
import com.youlai.system.pojo.form.DictForm;
import com.youlai.system.pojo.query.DictPageQuery;
import com.youlai.system.pojo.vo.DictPageVO;
import com.youlai.system.pojo.vo.Option;
import java.util.List;
/**
* 字典接口
*
* @author haoxr
* @date 2023/3/4
*/
public interface SysDictService extends IService<SysDict> {
/**
* 字典数据项分页列表
*
* @param queryParams
* @return
*/
Page<DictPageVO> getDictPage(DictPageQuery queryParams);
/**
* 字典数据项表单
*
* @param id 字典数据项ID
* @return
*/
DictForm getDictForm(Long id);
/**
* 新增字典数据项
*
* @param dictForm 字典数据项表单
* @return
*/
boolean saveDict(DictForm dictForm);
/**
* 修改字典数据项
*
* @param id 字典数据项ID
* @param dictForm 字典数据项表单
* @return
*/
boolean updateDict(Long id, DictForm dictForm);
/**
* 删除字典数据项
*
* @param idsStr 字典数据项ID多个以英文逗号(,)分割
* @return
*/
boolean deleteDict(String idsStr);
/**
* 获取字典下拉列表
*
* @param typeCode
* @return
*/
List<Option> listDictOptions(String typeCode);
}

View File

@@ -24,7 +24,7 @@ public interface SysDictTypeService extends IService<SysDictType> {
* @param queryParams 分页查询对象
* @return
*/
Page<DictTypePageVO> listDictTypePages(DictTypePageQuery queryParams);
Page<DictTypePageVO> getDictTypePage(DictTypePageQuery queryParams);
/**
@@ -33,7 +33,7 @@ public interface SysDictTypeService extends IService<SysDictType> {
* @param id 字典类型ID
* @return
*/
DictTypeForm getDictTypeFormData(Long id);
DictTypeForm getDictTypeForm(Long id);
/**

View File

@@ -26,7 +26,7 @@ public interface SysRoleService extends IService<SysRole> {
* @param queryParams
* @return
*/
Page<RolePageVO> listRolePages(RolePageQuery queryParams);
Page<RolePageVO> getRolePage(RolePageQuery queryParams);
/**
@@ -43,29 +43,37 @@ public interface SysRoleService extends IService<SysRole> {
*/
boolean saveRole(RoleForm roleForm);
/**
* 获取角色表单数据
*
* @param roleId 角色ID
* @return {@link RoleForm} 角色表单数据
*/
RoleForm getRoleForm(Long roleId);
/**
* 修改角色状态
*
* @param roleId
* @param status
* @return
* @param roleId 角色ID
* @param status 角色状态(1:启用0:禁用)
* @return {@link Boolean}
*/
boolean updateRoleStatus(Long roleId, Integer status);
/**
* 批量删除角色
*
* @param ids
* @param ids 角色ID多个使用英文逗号(,)分割
* @return
*/
boolean deleteRoles(String ids);
/**
* 获取角色的资源ID集合,资源包括菜单和权限
* 获取角色的菜单ID集合
*
* @param roleId
* @return
* @param roleId 角色ID
* @return 菜单ID集合(包括按钮权限ID)
*/
List<Long> getRoleMenuIds(Long roleId);
@@ -86,4 +94,6 @@ public interface SysRoleService extends IService<SysRole> {
* @return
*/
Integer getMaximumDataScope(Set<String> roles);
}

View File

@@ -28,7 +28,7 @@ public interface SysUserService extends IService<SysUser> {
*
* @return
*/
IPage<UserPageVO> listUserPages(UserPageQuery queryParams);
IPage<UserPageVO> getUserPage(UserPageQuery queryParams);
/**

View File

@@ -65,7 +65,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
Long parentId = dept.getParentId();
// 不在缓存ID列表的parentId是顶级节点ID以此作为递归开始
if (cacheDeptIds.contains(parentId) == false) {
list.addAll(recurDepartments(parentId, deptList));
list.addAll(recurDeptList(parentId, deptList));
cacheDeptIds.add(parentId); // 避免重复递归
}
}
@@ -85,18 +85,18 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
}
/**
* 递归生成部门层级列表
* 递归生成部门树形列表
*
* @param parentId
* @param deptList
* @return
*/
public List<DeptVO> recurDepartments(Long parentId, List<SysDept> deptList) {
public List<DeptVO> recurDeptList(Long parentId, List<SysDept> deptList) {
List<DeptVO> list = deptList.stream()
.filter(dept -> dept.getParentId().equals(parentId))
.map(dept -> {
DeptVO deptVO = deptConverter.entity2Vo(dept);
List<DeptVO> children = recurDepartments(dept.getId(), deptList);
List<DeptVO> children = recurDeptList(dept.getId(), deptList);
deptVO.setChildren(children);
return deptVO;
}).collect(Collectors.toList());
@@ -181,13 +181,15 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
@Override
public boolean deleteByIds(String ids) {
// 删除部门及子部门
Optional.ofNullable(Arrays.stream(ids.split(",")))
.ifPresent(deptIds -> deptIds.forEach(deptId ->
this.remove(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getId, deptId)
.or()
.apply("concat (',',tree_path,',') like concat('%,',{0},',%')", deptId))
));
if (StrUtil.isNotBlank(ids)) {
String[] menuIds = ids.split(",");
for (String deptId : menuIds) {
this.remove(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getId, deptId)
.or()
.apply("CONCAT (',',tree_path,',') LIKE CONCAT('%,',{0},',%')", deptId));
}
}
return true;
}

View File

@@ -1,142 +0,0 @@
package com.youlai.system.service.impl;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.system.converter.DictItemConverter;
import com.youlai.system.mapper.SysDictItemMapper;
import com.youlai.system.pojo.entity.SysDictItem;
import com.youlai.system.pojo.form.DictItemForm;
import com.youlai.system.pojo.query.DictItemPageQuery;
import com.youlai.system.pojo.vo.DictItemPageVO;
import com.youlai.system.service.SysDictItemService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 数据字典项业务实现类
*
* @author haoxr
* @date 2022/10/12
*/
@Service
@RequiredArgsConstructor
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
private final DictItemConverter dictItemConverter;
/**
* 字典数据项分页列表
*
* @param queryParams
* @return
*/
@Override
public Page<DictItemPageVO> listDictItemPages(DictItemPageQuery queryParams) {
// 查询参数
int pageNum = queryParams.getPageNum();
int pageSize = queryParams.getPageSize();
String keywords = queryParams.getKeywords();
String typeCode = queryParams.getTypeCode();
// 查询数据
Page<SysDictItem> dictItemPage = this.page(
new Page<>(pageNum, pageSize),
new LambdaQueryWrapper<SysDictItem>()
.like(StrUtil.isNotBlank(keywords), SysDictItem::getName, keywords)
.eq(StrUtil.isNotBlank(typeCode), SysDictItem::getTypeCode, typeCode)
.select(SysDictItem::getId, SysDictItem::getName, SysDictItem::getValue, SysDictItem::getStatus)
);
// 实体转换
Page<DictItemPageVO> pageResult = dictItemConverter.entity2Page(dictItemPage);
return pageResult;
}
/**
* 字典数据项表单详情
*
* @param id 字典数据项ID
* @return
*/
@Override
public DictItemForm getDictItemForm(Long id) {
// 获取entity
SysDictItem entity = this.getOne(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getId, id)
.select(
SysDictItem::getId,
SysDictItem::getTypeCode,
SysDictItem::getName,
SysDictItem::getValue,
SysDictItem::getStatus,
SysDictItem::getSort,
SysDictItem::getRemark
));
Assert.isTrue(entity != null, "字典数据项不存在");
// 实体转换
DictItemForm dictItemForm = dictItemConverter.entity2Form(entity);
return dictItemForm;
}
/**
* 新增字典数据项
*
* @param dictItemForm 字典数据项表单
* @return
*/
@Override
public boolean saveDictItem(DictItemForm dictItemForm) {
// 实体对象转换 form->entity
SysDictItem entity = dictItemConverter.form2Entity(dictItemForm);
// 持久化
boolean result = this.save(entity);
return result;
}
/**
* 修改字典数据项
*
* @param id 字典数据项ID
* @param dictItemForm 字典数据项表单
* @return
*/
@Override
public boolean updateDictItem(Long id, DictItemForm dictItemForm) {
SysDictItem entity = dictItemConverter.form2Entity(dictItemForm);
boolean result = this.updateById(entity);
return result;
}
/**
* 删除字典数据项
*
* @param idsStr 字典数据项ID多个以英文逗号(,)分割
* @return
*/
@Override
public boolean deleteDictItems(String idsStr) {
Assert.isTrue(StrUtil.isNotBlank(idsStr), "删除数据为空");
//
List<Long> ids = Arrays.asList(idsStr.split(","))
.stream()
.map(id -> Long.parseLong(id))
.collect(Collectors.toList());
// 删除字典数据项
boolean result = this.removeByIds(ids);
return result;
}
}

View File

@@ -0,0 +1,166 @@
package com.youlai.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.system.converter.DictConverter;
import com.youlai.system.mapper.SysDictMapper;
import com.youlai.system.pojo.entity.SysDict;
import com.youlai.system.pojo.form.DictForm;
import com.youlai.system.pojo.query.DictPageQuery;
import com.youlai.system.pojo.vo.DictPageVO;
import com.youlai.system.pojo.vo.Option;
import com.youlai.system.service.SysDictService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 数据字典项业务实现类
*
* @author haoxr
* @date 2022/10/12
*/
@Service
@RequiredArgsConstructor
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {
private final DictConverter dictConverter;
/**
* 字典数据项分页列表
*
* @param queryParams
* @return
*/
@Override
public Page<DictPageVO> getDictPage(DictPageQuery queryParams) {
// 查询参数
int pageNum = queryParams.getPageNum();
int pageSize = queryParams.getPageSize();
String keywords = queryParams.getKeywords();
String typeCode = queryParams.getTypeCode();
// 查询数据
Page<SysDict> dictItemPage = this.page(
new Page<>(pageNum, pageSize),
new LambdaQueryWrapper<SysDict>()
.like(StrUtil.isNotBlank(keywords), SysDict::getName, keywords)
.eq(StrUtil.isNotBlank(typeCode), SysDict::getTypeCode, typeCode)
.select(SysDict::getId, SysDict::getName, SysDict::getValue, SysDict::getStatus)
);
// 实体转换
Page<DictPageVO> pageResult = dictConverter.entity2Page(dictItemPage);
return pageResult;
}
/**
* 字典数据项表单详情
*
* @param id 字典数据项ID
* @return
*/
@Override
public DictForm getDictForm(Long id) {
// 获取entity
SysDict entity = this.getOne(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getId, id)
.select(
SysDict::getId,
SysDict::getTypeCode,
SysDict::getName,
SysDict::getValue,
SysDict::getStatus,
SysDict::getSort,
SysDict::getRemark
));
Assert.isTrue(entity != null, "字典数据项不存在");
// 实体转换
DictForm dictForm = dictConverter.entity2Form(entity);
return dictForm;
}
/**
* 新增字典数据项
*
* @param dictForm 字典数据项表单
* @return
*/
@Override
public boolean saveDict(DictForm dictForm) {
// 实体对象转换 form->entity
SysDict entity = dictConverter.form2Entity(dictForm);
// 持久化
boolean result = this.save(entity);
return result;
}
/**
* 修改字典数据项
*
* @param id 字典数据项ID
* @param dictForm 字典数据项表单
* @return
*/
@Override
public boolean updateDict(Long id, DictForm dictForm) {
SysDict entity = dictConverter.form2Entity(dictForm);
boolean result = this.updateById(entity);
return result;
}
/**
* 删除字典数据项
*
* @param idsStr 字典数据项ID多个以英文逗号(,)分割
* @return
*/
@Override
public boolean deleteDict(String idsStr) {
Assert.isTrue(StrUtil.isNotBlank(idsStr), "删除数据为空");
//
List<Long> ids = Arrays.asList(idsStr.split(","))
.stream()
.map(id -> Long.parseLong(id))
.collect(Collectors.toList());
// 删除字典数据项
boolean result = this.removeByIds(ids);
return result;
}
/**
* 获取字典下拉列表
*
* @param typeCode
* @return
*/
@Override
public List<Option> listDictOptions(String typeCode) {
// 数据字典项
List<SysDict> dictList = this.list(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getTypeCode, typeCode)
.select(SysDict::getValue, SysDict::getName)
);
// 转换下拉数据
List<Option> options = CollectionUtil.emptyIfNull(dictList)
.stream()
.map(dictItem -> new Option(dictItem.getValue(), dictItem.getName()))
.collect(Collectors.toList());
return options;
}
}

View File

@@ -7,15 +7,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.system.pojo.entity.SysDict;
import com.youlai.system.pojo.vo.Option;
import com.youlai.system.converter.DictTypeConverter;
import com.youlai.system.mapper.SysDictTypeMapper;
import com.youlai.system.pojo.entity.SysDictItem;
import com.youlai.system.pojo.entity.SysDictType;
import com.youlai.system.pojo.form.DictTypeForm;
import com.youlai.system.pojo.query.DictTypePageQuery;
import com.youlai.system.pojo.vo.DictTypePageVO;
import com.youlai.system.service.SysDictItemService;
import com.youlai.system.service.SysDictService;
import com.youlai.system.service.SysDictTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {
private final SysDictItemService dictItemService;
private final SysDictService dictItemService;
private final DictTypeConverter dictTypeConverter;
/**
@@ -46,7 +46,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
* @return
*/
@Override
public Page<DictTypePageVO> listDictTypePages(DictTypePageQuery queryParams) {
public Page<DictTypePageVO> getDictTypePage(DictTypePageQuery queryParams) {
// 查询参数
int pageNum = queryParams.getPageNum();
int pageSize = queryParams.getPageSize();
@@ -74,7 +74,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
* @return
*/
@Override
public DictTypeForm getDictTypeFormData(Long id) {
public DictTypeForm getDictTypeForm(Long id) {
// 获取entity
SysDictType entity = this.getOne(new LambdaQueryWrapper<SysDictType>()
.eq(SysDictType::getId, id)
@@ -128,9 +128,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
String oldCode = sysDictType.getCode();
String newCode = dictTypeForm.getCode();
if (!StrUtil.equals(oldCode, newCode)) {
dictItemService.update(new LambdaUpdateWrapper<SysDictItem>()
.eq(SysDictItem::getTypeCode, oldCode)
.set(SysDictItem::getTypeCode, newCode)
dictItemService.update(new LambdaUpdateWrapper<SysDict>()
.eq(SysDict::getTypeCode, oldCode)
.set(SysDict::getTypeCode, newCode)
);
}
}
@@ -162,8 +162,8 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
.collect(Collectors.toList()
);
if (CollectionUtil.isNotEmpty(dictTypeCodes)) {
dictItemService.remove(new LambdaQueryWrapper<SysDictItem>()
.in(SysDictItem::getTypeCode, dictTypeCodes));
dictItemService.remove(new LambdaQueryWrapper<SysDict>()
.in(SysDict::getTypeCode, dictTypeCodes));
}
// 删除字典类型
boolean result = this.removeByIds(ids);
@@ -179,9 +179,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
@Override
public List<Option> listDictItemsByTypeCode(String typeCode) {
// 数据字典项
List<SysDictItem> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getTypeCode, typeCode)
.select(SysDictItem::getValue, SysDictItem::getName)
List<SysDict> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getTypeCode, typeCode)
.select(SysDict::getValue, SysDict::getName)
);
// 转换下拉数据

View File

@@ -50,7 +50,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
* @return
*/
@Override
public Page<RolePageVO> listRolePages(RolePageQuery queryParams) {
public Page<RolePageVO> getRolePage(RolePageQuery queryParams) {
// 查询参数
int pageNum = queryParams.getPageNum();
int pageSize = queryParams.getPageSize();
@@ -88,11 +88,13 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
);
// 实体转换
List<Option> list = roleConverter.roles2Options(roleList);
List<Option> list = roleConverter.entities2Options(roleList);
return list;
}
/**
* 保存角色
*
* @param roleForm
* @return
*/
@@ -116,12 +118,25 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
return result;
}
/**
* 获取角色表单数据
*
* @param roleId 角色ID
* @return {@link RoleForm} 角色表单数据
*/
@Override
public RoleForm getRoleForm(Long roleId) {
SysRole entity = this.getById(roleId);
RoleForm roleForm = roleConverter.entity2Form(entity);
return roleForm;
}
/**
* 修改角色状态
*
* @param roleId
* @param status
* @return
* @param roleId 角色ID
* @param status 角色状态(1:启用0:禁用)
* @return {@link Boolean}
*/
@Override
public boolean updateRoleStatus(Long roleId, Integer status) {
@@ -134,7 +149,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
/**
* 批量删除角色
*
* @param ids
* @param ids 角色ID多个使用英文逗号(,)分割
* @return
*/
@Override
@@ -154,14 +169,13 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
}
/**
* 获取角色的资源ID集合,资源包括菜单和权限
* 获取角色的菜单ID集合
*
* @param roleId
* @return
* @param roleId 角色ID
* @return 菜单ID集合(包括按钮权限ID)
*/
@Override
public List<Long> getRoleMenuIds(Long roleId) {
// 获取角色拥有的菜单ID集合
List<Long> menuIds = sysRoleMenuService.listMenuIdsByRoleId(roleId);
return menuIds;
}

View File

@@ -65,7 +65,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return
*/
@Override
public IPage<UserPageVO> listUserPages(UserPageQuery queryParams) {
public IPage<UserPageVO> getUserPage(UserPageQuery queryParams) {
// 参数构建
int pageNum = queryParams.getPageNum();
@@ -73,7 +73,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
Page<UserBO> page = new Page<>(pageNum, pageSize);
// 查询数据
Page<UserBO> userBoPage = this.baseMapper.listUserPages(page, queryParams);
Page<UserBO> userBoPage = this.baseMapper.getUserPage(page, queryParams);
// 实体转换
Page<UserPageVO> userVoPage = userConverter.bo2Vo(userBoPage);

View File

@@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysDictItemMapper">
<mapper namespace="com.youlai.system.mapper.SysDictMapper">
</mapper>

View File

@@ -5,7 +5,7 @@
<mapper namespace="com.youlai.system.mapper.SysUserMapper">
<!-- 用户分页列表 -->
<select id="listUserPages" resultType="com.youlai.system.pojo.bo.UserBO">
<select id="getUserPage" resultType="com.youlai.system.pojo.bo.UserBO">
SELECT
u.id,
u.username,