9 Commits

59 changed files with 852 additions and 867 deletions

View File

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

View File

@@ -9,7 +9,7 @@ CREATE DATABASE IF NOT EXISTS youlai_boot DEFAULT CHARACTER SET utf8mb4 DEFAULT
-- ---------------------------- -- ----------------------------
-- 2. 创建表 -- 2. 创建表 && 数据初始化
-- ---------------------------- -- ----------------------------
use youlai_boot; use youlai_boot;
@@ -21,17 +21,17 @@ SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_dept`; DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `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 '部门名称', `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路径', `tree_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '父节点id路径',
`sort` int NULL DEFAULT 0 COMMENT '显示顺序', `sort` int(0) NULL DEFAULT 0 COMMENT '显示顺序',
`status` tinyint NULL DEFAULT 1 COMMENT '状态(1:正常;0:禁用)', `status` tinyint(0) NULL DEFAULT 1 COMMENT '状态(1:正常;0:禁用)',
`deleted` tinyint NULL DEFAULT 0 COMMENT '逻辑删除标识(1:已删除;0:未删除)', `deleted` tinyint(0) NULL DEFAULT 0 COMMENT '逻辑删除标识(1:已删除;0:未删除)',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE 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 -- 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'); 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`; DROP TABLE IF EXISTS `sys_dict`;
CREATE TABLE `sys_dict_item` ( CREATE TABLE `sys_dict` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
`type_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL 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 '字典项名称', `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 '字典项值', `value` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典项值',
`sort` int NULL DEFAULT 0 COMMENT '排序', `sort` int(0) NULL DEFAULT 0 COMMENT '排序',
`status` tinyint NULL DEFAULT 0 COMMENT '状态(1:正常;0:禁用)', `status` tinyint(0) NULL DEFAULT 0 COMMENT '状态(1:正常;0:禁用)',
`defaulted` tinyint 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 '备注', `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 65 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_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` 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` 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 (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 -- Table structure for sys_dict_type
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_dict_type`; DROP TABLE IF EXISTS `sys_dict_type`;
CREATE TABLE `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 '类型名称', `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 '类型编码', `code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '类型编码',
`status` tinyint(1) NULL DEFAULT 0 COMMENT '状态(0:正常;1:禁用)', `status` tinyint(1) NULL DEFAULT 0 COMMENT '状态(0:正常;1:禁用)',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `type_code`(`code`) 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 -- 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`; DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu` ( CREATE TABLE `sys_menu` (
`id` bigint NOT NULL AUTO_INCREMENT, `id` bigint(0) NOT NULL AUTO_INCREMENT,
`parent_id` bigint NOT NULL COMMENT '父菜单ID', `parent_id` bigint(0) NOT NULL COMMENT '父菜单ID',
`name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '菜单名称', `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 '路由路径(浏览器地址栏路径)', `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后缀)', `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 '权限标识', `perm` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限标识',
`visible` tinyint(1) NOT NULL DEFAULT 1 COMMENT '显示状态(1-显示;0-隐藏)', `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 '菜单图标', `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 '外链路径', `redirect_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '外链路径',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `redirect` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci 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 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 -- 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 (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, '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, '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, '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, '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, '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, 7, 'nested', '/nested/level1/level2', '2022-02-16 23:11:00', '2022-02-16 23:11:00'); 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', '2022-02-16 23:13:38', '2022-02-16 23:13:38'); 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', '2022-02-16 23:14:23', '2022-02-16 23:14:23'); 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 (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 (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 (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/', '', NULL, 1, 1, 'link', '', '2022-02-18 00:01:40', '2022-02-18 00:01:40'); 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 (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 (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 (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 (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', 'component/editor', NULL, 1, 1, '', '', NULL, NULL); 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', 'component/uploader', NULL, 1, 2, '', '', '2022-11-20 23:16:30', '2022-11-20 23:16:32'); 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 -- Table structure for sys_role
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_role`; DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `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 '角色名称', `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 '角色编码', `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-停用)', `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-已删除)', `deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除1-已删除)',
`create_time` datetime NULL DEFAULT NULL COMMENT '更新时间', `create_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `update_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `name`(`name`) 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 -- 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 (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 (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 (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 -- Table structure for sys_role_menu
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_role_menu`; DROP TABLE IF EXISTS `sys_role_menu`;
CREATE TABLE `sys_role_menu` ( CREATE TABLE `sys_role_menu` (
`role_id` bigint NOT NULL COMMENT '角色ID', `role_id` bigint(0) NOT NULL COMMENT '角色ID',
`menu_id` bigint 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; ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色和菜单关联表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Records of sys_role_menu -- 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, 26);
INSERT INTO `sys_role_menu` VALUES (2, 30); INSERT INTO `sys_role_menu` VALUES (2, 30);
INSERT INTO `sys_role_menu` VALUES (2, 31); 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, 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 -- Table structure for sys_user
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_user`; DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `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 '用户名', `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 '昵称', `nickname` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '昵称',
`gender` tinyint(1) NULL DEFAULT 1 COMMENT '性别((1:男;2:女))', `gender` tinyint(1) NULL DEFAULT 1 COMMENT '性别((1:男;2:女))',
`password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码', `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 '用户头像', `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 '联系方式', `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系方式',
`status` tinyint(1) NULL DEFAULT 1 COMMENT '用户状态((1:正常;0:禁用))', `status` tinyint(1) NULL DEFAULT 1 COMMENT '用户状态((1:正常;0:禁用))',
`email` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户邮箱', `email` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户邮箱',
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除标识(0:未删除;1:已删除)', `deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除标识(0:未删除;1:已删除)',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `login_name`(`username`) 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 -- 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 (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 (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 -- Table structure for sys_user_role
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`; DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role` ( CREATE TABLE `sys_user_role` (
`user_id` bigint NOT NULL COMMENT '用户ID', `user_id` bigint(0) NOT NULL COMMENT '用户ID',
`role_id` bigint NOT NULL COMMENT '角色ID', `role_id` bigint(0) NOT NULL COMMENT '角色ID',
PRIMARY KEY (`user_id`, `role_id`) USING BTREE 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 -- Records of sys_user_role

View File

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

View File

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

View File

@@ -1,18 +1,23 @@
package com.youlai.system.config; 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.Info;
import io.swagger.v3.oas.models.info.License; 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 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.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; 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 * @author haoxr
* @date 2023/2/17 * @date 2023/2/17
@@ -20,55 +25,47 @@ import org.springframework.http.HttpHeaders;
@Configuration @Configuration
public class SwaggerConfig { 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 * @return
*/ */
@Bean @Bean
public GroupedOpenApi systemApi(OperationCustomizer operationCustomizer) { public GroupedOpenApi groupedOpenApi() {
return GroupedOpenApi.builder() String paths[] = {"/api/**"};
.group("系统接口")
.packagesToScan("com.youlai.system.controller") String packagesToScan[] = {"com.youlai.system.controller"};
.pathsToMatch( "/api/**") return GroupedOpenApi.builder().group("系统接口")
.addOperationCustomizer(operationCustomizer) .packagesToScan(packagesToScan)
.pathsToMatch(paths)
.build(); .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.pojo.vo.FileInfoVO;
import com.youlai.system.service.FileService; import com.youlai.system.service.FileService;
import io.swagger.v3.oas.annotations.Parameter; 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.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -11,7 +12,7 @@ import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@Tag(name = "文件接口") @Tag(name = "08.文件接口")
@RestController @RestController
@RequestMapping("/api/v1/files") @RequestMapping("/api/v1/files")
@RequiredArgsConstructor @RequiredArgsConstructor
@@ -20,19 +21,19 @@ public class FileController {
private final FileService fileService; private final FileService fileService;
@PostMapping @PostMapping
@Operation(summary = "文件上传") @Operation(summary = "文件上传", security = {@SecurityRequirement(name = "Authorization")})
public Result<FileInfoVO> uploadFile( public Result<FileInfoVO> uploadFile(
@Parameter(name ="表单文件对象") @RequestParam(value = "file") MultipartFile file @Parameter(description ="表单文件对象") @RequestParam(value = "file") MultipartFile file
) { ) {
FileInfoVO fileInfoVO = fileService.uploadFile(file); FileInfoVO fileInfoVO = fileService.uploadFile(file);
return Result.success(fileInfoVO); return Result.success(fileInfoVO);
} }
@DeleteMapping @DeleteMapping
@Operation(summary = "文件删除") @Operation(summary = "文件删除", security = {@SecurityRequirement(name = "Authorization")})
@SneakyThrows @SneakyThrows
public Result deleteFile( public Result deleteFile(
@Parameter(name ="文件路径") @RequestParam String filePath @Parameter(description ="文件路径") @RequestParam String filePath
) { ) {
boolean result = fileService.deleteFile(filePath); boolean result = fileService.deleteFile(filePath);
return Result.judge(result); 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.pojo.vo.DeptVO;
import com.youlai.system.service.SysDeptService; import com.youlai.system.service.SysDeptService;
import io.swagger.v3.oas.annotations.Parameter; 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.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -22,15 +23,13 @@ import java.util.List;
* @author haoxr * @author haoxr
* @date 2020/11/6 * @date 2020/11/6
*/ */
@Tag(name = "部门接口") @Tag(name = "05.部门接口")
@RestController @RestController
@RequestMapping("/api/v1/dept") @RequestMapping("/api/v1/dept")
@RequiredArgsConstructor @RequiredArgsConstructor
public class SysDeptController { public class SysDeptController {
private final SysDeptService deptService; private final SysDeptService deptService;
@Operation(summary = "获取部门列表", security = {@SecurityRequirement(name = "Authorization")})
@Operation(summary = "获取部门列表")
@GetMapping @GetMapping
public Result<List<DeptVO>> listDepartments( public Result<List<DeptVO>> listDepartments(
@ParameterObject DeptQuery queryParams @ParameterObject DeptQuery queryParams
@@ -39,23 +38,23 @@ public class SysDeptController {
return Result.success(list); return Result.success(list);
} }
@Operation(summary = "获取部门下拉选项") @Operation(summary = "获取部门下拉选项", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/options") @GetMapping("/options")
public Result<List<Option>> listDeptOptions() { public Result<List<Option>> listDeptOptions() {
List<Option> list = deptService.listDeptOptions(); List<Option> list = deptService.listDeptOptions();
return Result.success(list); return Result.success(list);
} }
@Operation(summary = "获取部门详情") @Operation(summary = "获取部门详情", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{deptId}/form") @GetMapping("/{deptId}/form")
public Result<DeptForm> getDeptForm( public Result<DeptForm> getDeptForm(
@Parameter(name ="部门ID") @PathVariable Long deptId @Parameter(description ="部门ID") @PathVariable Long deptId
) { ) {
DeptForm deptForm = deptService.getDeptForm(deptId); DeptForm deptForm = deptService.getDeptForm(deptId);
return Result.success(deptForm); return Result.success(deptForm);
} }
@Operation(summary = "新增部门") @Operation(summary = "新增部门", security = {@SecurityRequirement(name = "Authorization")})
@PostMapping @PostMapping
public Result saveDept( public Result saveDept(
@Valid @RequestBody DeptForm formData @Valid @RequestBody DeptForm formData
@@ -64,7 +63,7 @@ public class SysDeptController {
return Result.success(id); return Result.success(id);
} }
@Operation(summary = "修改部门") @Operation(summary = "修改部门", security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{deptId}") @PutMapping(value = "/{deptId}")
public Result updateDept( public Result updateDept(
@PathVariable Long deptId, @PathVariable Long deptId,
@@ -74,10 +73,10 @@ public class SysDeptController {
return Result.success(deptId); return Result.success(deptId);
} }
@Operation(summary = "删除部门") @Operation(summary = "删除部门", security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public Result deleteDepartments( public Result deleteDepartments(
@Parameter(name ="部门ID多个以英文逗号(,)分割") @PathVariable("ids") String ids @Parameter(description ="部门ID多个以英文逗号(,)分割") @PathVariable("ids") String ids
) { ) {
boolean result = deptService.deleteByIds(ids); boolean result = deptService.deleteByIds(ids);
return Result.judge(result); 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; package com.youlai.system.controller;
import com.youlai.system.pojo.form.MenuForm;
import com.youlai.system.pojo.vo.Option; import com.youlai.system.pojo.vo.Option;
import com.youlai.system.common.result.Result; import com.youlai.system.common.result.Result;
import com.youlai.system.pojo.entity.SysMenu; import com.youlai.system.pojo.entity.SysMenu;
import com.youlai.system.pojo.query.MenuQuery; import com.youlai.system.pojo.query.MenuQuery;
import com.youlai.system.pojo.vo.MenuVO; 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.pojo.vo.RouteVO;
import com.youlai.system.service.SysMenuService; import com.youlai.system.service.SysMenuService;
import io.swagger.v3.oas.annotations.Parameter; 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.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -26,7 +27,7 @@ import java.util.List;
* @author haoxr * @author haoxr
* @date 2020/11/06 * @date 2020/11/06
*/ */
@Tag(name = "菜单接口") @Tag(name = "04.菜单接口")
@RestController @RestController
@RequestMapping("/api/v1/menus") @RequestMapping("/api/v1/menus")
@RequiredArgsConstructor @RequiredArgsConstructor
@@ -35,76 +36,69 @@ public class SysMenuController {
private final SysMenuService menuService; private final SysMenuService menuService;
@Operation(summary = "资源(菜单+权限)列表") @Operation(summary = "菜单列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/resources")
public Result<List<ResourceVO>> listResources() {
List<ResourceVO> resources = menuService.listResources();
return Result.success(resources);
}
@Operation(summary = "菜单列表")
@GetMapping @GetMapping
public Result listMenus( @ParameterObject MenuQuery queryParams) { public Result<List<MenuVO>> listMenus( @ParameterObject MenuQuery queryParams) {
List<MenuVO> menuList = menuService.listMenus(queryParams); List<MenuVO> menuList = menuService.listMenus(queryParams);
return Result.success(menuList); return Result.success(menuList);
} }
@Operation(summary = "菜单下拉列表") @Operation(summary = "菜单下拉列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/options") @GetMapping("/options")
public Result listMenuOptions() { public Result listMenuOptions() {
List<Option> menus = menuService.listMenuOptions(); List<Option> menus = menuService.listMenuOptions();
return Result.success(menus); return Result.success(menus);
} }
@Operation(summary = "路由列表") @Operation(summary = "路由列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/routes") @GetMapping("/routes")
public Result listRoutes() { public Result<List<RouteVO>> listRoutes() {
List<RouteVO> routeList = menuService.listRoutes(); List<RouteVO> routeList = menuService.listRoutes();
return Result.success(routeList); return Result.success(routeList);
} }
@Operation(summary = "菜单详情") @Operation(summary = "菜单表单数据",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{id}") @GetMapping("/{id}/form")
public Result detail( public Result<MenuForm> getMenuForm(
@Parameter(name = "菜单ID") @PathVariable Long id @Parameter(description = "菜单ID") @PathVariable Long id
) { ) {
SysMenu menu = menuService.getById(id); MenuForm menu = menuService.getMenuForm(id);
return Result.success(menu); return Result.success(menu);
} }
@Operation(summary = "新增菜单") @Operation(summary = "新增菜单",security = {@SecurityRequirement(name = "Authorization")})
@PostMapping @PostMapping
@CacheEvict(cacheNames = "system", key = "'routes'") @CacheEvict(cacheNames = "system", key = "'routes'")
public Result addMenu(@RequestBody SysMenu menu) { public Result addMenu(@RequestBody MenuForm menuForm) {
boolean result = menuService.saveMenu(menu); boolean result = menuService.saveMenu(menuForm);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改菜单") @Operation(summary = "修改菜单",security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{id}") @PutMapping(value = "/{id}")
@CacheEvict(cacheNames = "system", key = "'routes'") @CacheEvict(cacheNames = "system", key = "'routes'")
public Result updateMenu( public Result updateMenu(
@RequestBody SysMenu menu @RequestBody MenuForm menuForm
) { ) {
boolean result = menuService.saveMenu(menu); boolean result = menuService.saveMenu(menuForm);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "删除菜单") @Operation(summary = "删除菜单",security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}") @DeleteMapping("/{id}")
@CacheEvict(cacheNames = "system", key = "'routes'") @CacheEvict(cacheNames = "system", key = "'routes'")
public Result deleteMenus( public Result deleteMenu(
@Parameter(name ="菜单ID多个以英文(,)分割") @PathVariable("ids") String ids @Parameter(description ="菜单ID多个以英文(,)分割") @PathVariable("id") Long id
) { ) {
boolean result = menuService.removeByIds(Arrays.asList(ids.split(","))); boolean result = menuService.deleteMenu(id);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改菜单显示状态") @Operation(summary = "修改菜单显示状态",security = {@SecurityRequirement(name = "Authorization")})
@PatchMapping("/{menuId}") @PatchMapping("/{menuId}")
public Result updateMenuVisible( public Result updateMenuVisible(
@Parameter(name = "菜单ID") @PathVariable Long menuId, @Parameter(description = "菜单ID") @PathVariable Long menuId,
@Parameter(name = "显示状态(1:显示;0:隐藏)") Integer visible @Parameter(description = "显示状态(1:显示;0:隐藏)") Integer visible
) { ) {
boolean result =menuService.updateMenuVisible(menuId, 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.pojo.vo.Option;
import com.youlai.system.common.result.PageResult; import com.youlai.system.common.result.PageResult;
import com.youlai.system.common.result.Result; 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.form.RoleForm;
import com.youlai.system.pojo.query.RolePageQuery; import com.youlai.system.pojo.query.RolePageQuery;
import com.youlai.system.pojo.vo.RolePageVO; import com.youlai.system.pojo.vo.RolePageVO;
import com.youlai.system.service.SysRoleService; import com.youlai.system.service.SysRoleService;
import io.swagger.v3.oas.annotations.Parameter; 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.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.List; import java.util.List;
@Tag(name = "角色接口") @Tag(name = "03.角色接口")
@RestController @RestController
@RequestMapping("/api/v1/roles") @RequestMapping("/api/v1/roles")
@RequiredArgsConstructor @RequiredArgsConstructor
@@ -27,74 +27,74 @@ public class SysRoleController {
private final SysRoleService roleService; private final SysRoleService roleService;
@Operation(summary = "角色分页列表") @Operation(summary = "角色分页列表",security = {@SecurityRequirement(name = "Authorization")} )
@GetMapping("/pages") @GetMapping("/page")
public PageResult<RolePageVO> listRolePages( public PageResult<RolePageVO> getRolePage(
@ParameterObject RolePageQuery queryParams @ParameterObject RolePageQuery queryParams
) { ) {
Page<RolePageVO> result = roleService.listRolePages(queryParams); Page<RolePageVO> result = roleService.getRolePage(queryParams);
return PageResult.success(result); return PageResult.success(result);
} }
@Operation(summary = "角色下拉列表") @Operation(summary = "角色下拉列表",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/options") @GetMapping("/options")
public Result<List<Option>> listRoleOptions() { public Result<List<Option>> listRoleOptions() {
List<Option> list = roleService.listRoleOptions(); List<Option> list = roleService.listRoleOptions();
return Result.success(list); return Result.success(list);
} }
@Operation(summary = "角色详情") @Operation(summary = "新增角色",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{roleId}")
public Result getRoleDetail(
@Parameter(name ="角色ID") @PathVariable Long roleId
) {
SysRole role = roleService.getById(roleId);
return Result.success(role);
}
@Operation(summary = "新增角色")
@PostMapping @PostMapping
public Result addRole(@Valid @RequestBody RoleForm roleForm) { public Result addRole(@Valid @RequestBody RoleForm roleForm) {
boolean result = roleService.saveRole(roleForm); boolean result = roleService.saveRole(roleForm);
return Result.judge(result); 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}") @PutMapping(value = "/{id}")
public Result updateRole(@Valid @RequestBody RoleForm roleForm) { public Result updateRole(@Valid @RequestBody RoleForm roleForm) {
boolean result = roleService.saveRole(roleForm); boolean result = roleService.saveRole(roleForm);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "删除角色") @Operation(summary = "删除角色",security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public Result deleteRoles( public Result deleteRoles(
@Parameter(name ="删除角色,多个以英文逗号(,)分割") @PathVariable String ids @Parameter(description ="删除角色,多个以英文逗号(,)分割") @PathVariable String ids
) { ) {
boolean result = roleService.deleteRoles(ids); boolean result = roleService.deleteRoles(ids);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改角色状态") @Operation(summary = "修改角色状态",security = {@SecurityRequirement(name = "Authorization")})
@PutMapping(value = "/{roleId}/status") @PutMapping(value = "/{roleId}/status")
public Result updateRoleStatus( public Result updateRoleStatus(
@Parameter(name ="角色ID") @PathVariable Long roleId, @Parameter(description ="角色ID") @PathVariable Long roleId,
@Parameter(name ="角色状态:1-启用0-禁用") @RequestParam Integer status @Parameter(description ="状态(1:启用;0:禁用)") @RequestParam Integer status
) { ) {
boolean result = roleService.updateRoleStatus(roleId, status); boolean result = roleService.updateRoleStatus(roleId, status);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "获取角色的菜单ID集合") @Operation(summary = "获取角色的菜单ID集合",security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{roleId}/menuIds") @GetMapping("/{roleId}/menuIds")
public Result<List<Long>> getRoleMenuIds( public Result<List<Long>> getRoleMenuIds(
@Parameter(name ="角色ID") @PathVariable Long roleId @Parameter(description ="角色ID") @PathVariable Long roleId
) { ) {
List<Long> resourceIds = roleService.getRoleMenuIds(roleId); List<Long> menuIds = roleService.getRoleMenuIds(roleId);
return Result.success(resourceIds); return Result.success(menuIds);
} }
@Operation(summary = "分配角色的资源权限") @Operation(summary = "分配菜单权限给角色",security = {@SecurityRequirement(name = "Authorization")})
@PutMapping("/{roleId}/menus") @PutMapping("/{roleId}/menus")
public Result updateRoleMenus( public Result updateRoleMenus(
@PathVariable Long roleId, @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.pojo.vo.UserPageVO;
import com.youlai.system.service.SysUserService; import com.youlai.system.service.SysUserService;
import io.swagger.v3.oas.annotations.Parameter; 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.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -42,7 +43,7 @@ import java.util.List;
* @author haoxr * @author haoxr
* @date 2022/10/16 * @date 2022/10/16
*/ */
@Tag(name = "用户接口") @Tag(name = "02.用户接口")
@RestController @RestController
@RequestMapping("/api/v1/users") @RequestMapping("/api/v1/users")
@RequiredArgsConstructor @RequiredArgsConstructor
@@ -50,25 +51,16 @@ public class SysUserController {
private final SysUserService userService; private final SysUserService userService;
@Operation(summary = "用户分页列表") @Operation(summary = "用户分页列表", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/pages") @GetMapping("/page")
public PageResult<UserPageVO> listUserPages( public PageResult<UserPageVO> getUserPage(
@ParameterObject UserPageQuery queryParams @ParameterObject UserPageQuery queryParams
) { ) {
IPage<UserPageVO> result = userService.listUserPages(queryParams); IPage<UserPageVO> result = userService.getUserPage(queryParams);
return PageResult.success(result); return PageResult.success(result);
} }
@Operation(summary = "用户表单数据") @Operation(summary = "新增用户", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/{userId}/form")
public Result<UserForm> getUserForm(
@Parameter(name = "用户ID") @PathVariable Long userId
) {
UserForm formData = userService.getUserFormData(userId);
return Result.success(formData);
}
@Operation(summary = "新增用户")
@PostMapping @PostMapping
@PreAuthorize("@pms.hasPermission('sys:user:add')") @PreAuthorize("@pms.hasPermission('sys:user:add')")
public Result saveUser( public Result saveUser(
@@ -78,41 +70,50 @@ public class SysUserController {
return Result.judge(result); 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}") @PutMapping(value = "/{userId}")
@PreAuthorize("@pms.hasPermission('sys:user:edit')") @PreAuthorize("@pms.hasPermission('sys:user:edit')")
public Result updateUser( public Result updateUser(
@Parameter(name = "用户ID") @PathVariable Long userId, @Parameter(description = "用户ID") @PathVariable Long userId,
@RequestBody @Validated UserForm userForm) { @RequestBody @Validated UserForm userForm) {
boolean result = userService.updateUser(userId, userForm); boolean result = userService.updateUser(userId, userForm);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "删除用户") @Operation(summary = "删除用户", security = {@SecurityRequirement(name = "Authorization")})
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@PreAuthorize("@pms.hasPermission('sys:user:delete')") @PreAuthorize("@pms.hasPermission('sys:user:delete')")
public Result deleteUsers( public Result deleteUsers(
@Parameter(name = "用户ID多个以英文逗号(,)分割") @PathVariable String ids @Parameter(description = "用户ID多个以英文逗号(,)分割") @PathVariable String ids
) { ) {
boolean result = userService.deleteUsers(ids); boolean result = userService.deleteUsers(ids);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改用户密码") @Operation(summary = "修改用户密码", security = {@SecurityRequirement(name = "Authorization")})
@PatchMapping(value = "/{userId}/password") @PatchMapping(value = "/{userId}/password")
public Result updatePassword( public Result updatePassword(
@Parameter(name = "用户ID") @PathVariable Long userId, @Parameter(description = "用户ID") @PathVariable Long userId,
@RequestParam String password @RequestParam String password
) { ) {
boolean result = userService.updatePassword(userId, password); boolean result = userService.updatePassword(userId, password);
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改用户状态") @Operation(summary = "修改用户状态", security = {@SecurityRequirement(name = "Authorization")})
@PatchMapping(value = "/{userId}/status") @PatchMapping(value = "/{userId}/status")
public Result updatePassword( public Result updatePassword(
@Parameter(name = "用户ID") @PathVariable Long userId, @Parameter(description = "用户ID") @PathVariable Long userId,
@Parameter(name = "用户状态(1:启用;0:禁用)") @RequestParam Integer status @Parameter(description = "用户状态(1:启用;0:禁用)") @RequestParam Integer status
) { ) {
boolean result = userService.update(new LambdaUpdateWrapper<SysUser>() boolean result = userService.update(new LambdaUpdateWrapper<SysUser>()
.eq(SysUser::getId, userId) .eq(SysUser::getId, userId)
@@ -121,14 +122,14 @@ public class SysUserController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "获取当前登录用户信息") @Operation(summary = "获取当前登录用户信息", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/me") @GetMapping("/me")
public Result<UserInfoVO> getUserLoginInfo() { public Result<UserInfoVO> getUserLoginInfo() {
UserInfoVO userInfoVO = userService.getUserLoginInfo(); UserInfoVO userInfoVO = userService.getUserLoginInfo();
return Result.success(userInfoVO); return Result.success(userInfoVO);
} }
@Operation(summary = "用户导入模板下载") @Operation(summary = "用户导入模板下载", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/template") @GetMapping("/template")
public void downloadTemplate(HttpServletResponse response) throws IOException { public void downloadTemplate(HttpServletResponse response) throws IOException {
String fileName = "用户导入模板.xlsx"; String fileName = "用户导入模板.xlsx";
@@ -144,15 +145,15 @@ public class SysUserController {
excelWriter.finish(); excelWriter.finish();
} }
@Operation(summary = "导入用户") @Operation(summary = "导入用户", security = {@SecurityRequirement(name = "Authorization")})
@PostMapping("/_import") @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); UserImportListener listener = new UserImportListener(deptId);
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportVO.class, listener); String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportVO.class, listener);
return Result.success(msg); return Result.success(msg);
} }
@Operation(summary = "导出用户") @Operation(summary = "导出用户", security = {@SecurityRequirement(name = "Authorization")})
@GetMapping("/_export") @GetMapping("/_export")
public void exportUsers(UserPageQuery queryParams, HttpServletResponse response) throws IOException { public void exportUsers(UserPageQuery queryParams, HttpServletResponse response) throws IOException {
String fileName = "用户列表.xlsx"; String fileName = "用户列表.xlsx";

View File

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

View File

@@ -1,6 +1,7 @@
package com.youlai.system.converter; package com.youlai.system.converter;
import com.youlai.system.pojo.entity.SysMenu; import com.youlai.system.pojo.entity.SysMenu;
import com.youlai.system.pojo.form.MenuForm;
import com.youlai.system.pojo.vo.MenuVO; import com.youlai.system.pojo.vo.MenuVO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
@@ -13,6 +14,11 @@ import org.mapstruct.Mapper;
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface MenuConverter { 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 = "value", source = "id"),
@Mapping(target = "label", source = "name") @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); SysRole form2Entity(RoleForm roleForm);
RoleForm entity2Form(SysRole entity);
} }

View File

@@ -24,7 +24,7 @@ public class RequestLogFilter extends CommonsRequestLoggingFilter {
@Override @Override
protected void beforeRequest(HttpServletRequest request, String message) { protected void beforeRequest(HttpServletRequest request, String message) {
String requestURI = request.getRequestURI(); String requestURI = request.getRequestURI();
log.info("request uri{}", requestURI); log.info("request uri: {}", requestURI);
super.beforeRequest(request, message); 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.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler; 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.base.IBaseEnum;
import com.youlai.system.common.enums.DataScopeEnum; import com.youlai.system.common.enums.DataScopeEnum;
import com.youlai.system.framework.security.util.SecurityUtils; 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.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* 用户导入监听器 * 用户导入监听器
* <p> * <p>

View File

@@ -1,11 +1,11 @@
package com.youlai.system.mapper; package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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; import org.apache.ibatis.annotations.Mapper;
@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.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.bo.UserBO;
import com.youlai.system.pojo.entity.SysUser; import com.youlai.system.pojo.entity.SysUser;
import com.youlai.system.pojo.bo.UserAuthInfo; import com.youlai.system.pojo.bo.UserAuthInfo;
@@ -30,7 +30,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return * @return
*/ */
@DataPermission(deptAlias = "u") @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") @Schema(description = "访问token")
private String accessToken; private String accessToken;
@Schema(description = "token 类型",example = "Bearer")
private String tokenType;
@Schema(description = "刷新token") @Schema(description = "刷新token")
private String refreshToken; 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.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import lombok.Data; import lombok.Data;
/** /**
@@ -14,9 +14,8 @@ import lombok.Data;
* @author haoxr * @author haoxr
* @date 2022/12/17 * @date 2022/12/17
*/ */
@TableName(value ="sys_dict_item")
@Data @Data
public class SysDictItem implements Serializable { public class SysDict implements Serializable {
/** /**
* 主键 * 主键
*/ */

View File

@@ -1,17 +1,12 @@
package com.youlai.system.pojo.entity; package com.youlai.system.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; 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 com.youlai.system.common.base.BaseEntity;
import lombok.Data; import lombok.Data;
/** /**
* 字典类型 * 字典类型实体
* *
* @author haoxr * @author haoxr
* @date 2022/12/17 * @date 2022/12/17

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,6 @@
package com.youlai.system.pojo.form; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@@ -19,7 +17,10 @@ public class DictTypeForm {
@Schema(description="类型编码") @Schema(description="类型编码")
private String code; private String code;
@Schema(description="类型状态1->启用;0->禁用") @Schema(description="类型状态(1:启用;0:禁用)")
private Integer status; 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 * @author haoxr
* @date 2022/4/12 11:04 * @date 2022/4/12 11:04
*/ */
@Schema @Schema(description = "用户表单对象")
@Data @Data
public class UserForm { public class UserForm {

View File

@@ -3,12 +3,11 @@ package com.youlai.system.pojo.query;
import com.youlai.system.common.base.BasePageQuery; import com.youlai.system.common.base.BasePageQuery;
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; import lombok.Data;
@Schema(description ="字典数据项分页查询对象") @Schema(description ="字典数据项分页查询对象")
@Data @Data
public class DictItemPageQuery extends BasePageQuery { public class DictPageQuery extends BasePageQuery {
@Schema(description="关键字(字典项名称)") @Schema(description="关键字(字典项名称)")
private String keywords; private String keywords;

View File

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

View File

@@ -1,12 +1,16 @@
package com.youlai.system.pojo.vo; package com.youlai.system.pojo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@Schema(description = "文件对象")
@Data @Data
public class FileInfoVO { public class FileInfoVO {
@Schema(description = "文件名称")
private String name; private String name;
@Schema(description = "文件URL")
private String 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 @Data
public class MenuVO { public class MenuVO {
@Schema(description = "菜单ID")
private Long id; private Long id;
@Schema(description = "父菜单ID")
private Long parentId; private Long parentId;
@Schema(description = "菜单名称")
private String name; private String name;
@Schema(description = "ICON")
private String icon; private String icon;
@Schema(description = "路由名称")
private String routeName; private String routeName;
@Schema(description = "路由相对路径")
private String routePath; private String routePath;
@Schema(description = "组件路径")
private String component; private String component;
@Schema(description = "菜单排序(数字越小排名越靠前)")
private Integer sort; private Integer sort;
@Schema(description = "菜单是否可见(1:显示;0:隐藏)")
private Integer visible; private Integer visible;
@Schema(description = "跳转路径")
private String redirect; private String redirect;
@Schema(description="菜单类型") @Schema(description="菜单类型")
@@ -37,6 +47,7 @@ public class MenuVO {
@Schema(description="按钮权限标识") @Schema(description="按钮权限标识")
private String perm; private String perm;
@Schema(description = "子菜单")
@JsonInclude(value = JsonInclude.Include.NON_NULL) @JsonInclude(value = JsonInclude.Include.NON_NULL)
private List<MenuVO> children; private List<MenuVO> children;

View File

@@ -35,6 +35,7 @@ public class Option<T> {
@Schema(description="选项的标签") @Schema(description="选项的标签")
private String label; private String label;
@Schema(description="子选项列表")
@JsonInclude(value = JsonInclude.Include.NON_EMPTY) @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<Option> children; 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 com.fasterxml.jackson.annotation.JsonFormat;
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; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Schema(description ="角色分页视图对象") @Schema(description ="角色分页对象")
@Data @Data
public class RolePageVO { public class RolePageVO {

View File

@@ -1,6 +1,7 @@
package com.youlai.system.pojo.vo; package com.youlai.system.pojo.vo;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@@ -11,41 +12,46 @@ import java.util.List;
* @author haoxr * @author haoxr
* @date 2020/11/28 * @date 2020/11/28
*/ */
@Schema(description = "路由对象")
@Data @Data
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public class RouteVO { public class RouteVO {
@Schema(description = "路由路径", example = "user")
private String path; private String path;
@Schema(description = "组件路径", example = "system/user/index")
private String component; private String component;
@Schema(description = "跳转链接", example = "https://www.youlai.tech")
private String redirect; private String redirect;
@Schema(description = "路由名称")
private String name; private String name;
@Schema(description = "路由属性")
private Meta meta; private Meta meta;
@Schema(description = "路由属性类型")
@Data @Data
public static class Meta { public static class Meta {
@Schema(description = "路由title")
private String title; private String title;
@Schema(description = "ICON")
private String icon; private String icon;
@Schema(description = "是否隐藏", example = "true")
private Boolean hidden; private Boolean hidden;
/** @Schema(description = "拥有路由权限的角色编码", example = "['ADMIN','ROOT']")
* 如果设置为 true目录没有子节点也会显示
*/
private Boolean alwaysShow;
private List<String> roles; private List<String> roles;
/** @Schema(description = "是否开启缓存", example = "true")
* 页面缓存开启状态
*/
private Boolean keepAlive; private Boolean keepAlive;
} }
@Schema(description = "子路由列表")
private List<RouteVO> children; 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 * @author haoxr
* @date 2022/1/15 9:41 * @date 2022/1/15 9:41
*/ */
@Schema(description ="用户分页视图对象") @Schema(description ="用户分页对象")
@Data @Data
public class UserPageVO { 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 分页查询对象 * @param queryParams 分页查询对象
* @return * @return
*/ */
Page<DictTypePageVO> listDictTypePages(DictTypePageQuery queryParams); Page<DictTypePageVO> getDictTypePage(DictTypePageQuery queryParams);
/** /**
@@ -33,7 +33,7 @@ public interface SysDictTypeService extends IService<SysDictType> {
* @param id 字典类型ID * @param id 字典类型ID
* @return * @return
*/ */
DictTypeForm getDictTypeFormData(Long id); DictTypeForm getDictTypeForm(Long id);
/** /**

View File

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

View File

@@ -28,7 +28,7 @@ public interface SysUserService extends IService<SysUser> {
* *
* @return * @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(); Long parentId = dept.getParentId();
// 不在缓存ID列表的parentId是顶级节点ID以此作为递归开始 // 不在缓存ID列表的parentId是顶级节点ID以此作为递归开始
if (cacheDeptIds.contains(parentId) == false) { if (cacheDeptIds.contains(parentId) == false) {
list.addAll(recurDepartments(parentId, deptList)); list.addAll(recurDeptList(parentId, deptList));
cacheDeptIds.add(parentId); // 避免重复递归 cacheDeptIds.add(parentId); // 避免重复递归
} }
} }
@@ -85,18 +85,18 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
} }
/** /**
* 递归生成部门层级列表 * 递归生成部门树形列表
* *
* @param parentId * @param parentId
* @param deptList * @param deptList
* @return * @return
*/ */
public List<DeptVO> recurDepartments(Long parentId, List<SysDept> deptList) { public List<DeptVO> recurDeptList(Long parentId, List<SysDept> deptList) {
List<DeptVO> list = deptList.stream() List<DeptVO> list = deptList.stream()
.filter(dept -> dept.getParentId().equals(parentId)) .filter(dept -> dept.getParentId().equals(parentId))
.map(dept -> { .map(dept -> {
DeptVO deptVO = deptConverter.entity2Vo(dept); DeptVO deptVO = deptConverter.entity2Vo(dept);
List<DeptVO> children = recurDepartments(dept.getId(), deptList); List<DeptVO> children = recurDeptList(dept.getId(), deptList);
deptVO.setChildren(children); deptVO.setChildren(children);
return deptVO; return deptVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@@ -181,13 +181,15 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
@Override @Override
public boolean deleteByIds(String ids) { public boolean deleteByIds(String ids) {
// 删除部门及子部门 // 删除部门及子部门
Optional.ofNullable(Arrays.stream(ids.split(","))) if (StrUtil.isNotBlank(ids)) {
.ifPresent(deptIds -> deptIds.forEach(deptId -> String[] menuIds = ids.split(",");
for (String deptId : menuIds) {
this.remove(new LambdaQueryWrapper<SysDept>() this.remove(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getId, deptId) .eq(SysDept::getId, deptId)
.or() .or()
.apply("concat (',',tree_path,',') like concat('%,',{0},',%')", deptId)) .apply("CONCAT (',',tree_path,',') LIKE CONCAT('%,',{0},',%')", deptId));
)); }
}
return true; 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.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.pojo.vo.Option;
import com.youlai.system.converter.DictTypeConverter; import com.youlai.system.converter.DictTypeConverter;
import com.youlai.system.mapper.SysDictTypeMapper; 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.entity.SysDictType;
import com.youlai.system.pojo.form.DictTypeForm; import com.youlai.system.pojo.form.DictTypeForm;
import com.youlai.system.pojo.query.DictTypePageQuery; import com.youlai.system.pojo.query.DictTypePageQuery;
import com.youlai.system.pojo.vo.DictTypePageVO; 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 com.youlai.system.service.SysDictTypeService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService { public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {
private final SysDictItemService dictItemService; private final SysDictService dictItemService;
private final DictTypeConverter dictTypeConverter; private final DictTypeConverter dictTypeConverter;
/** /**
@@ -46,7 +46,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
* @return * @return
*/ */
@Override @Override
public Page<DictTypePageVO> listDictTypePages(DictTypePageQuery queryParams) { public Page<DictTypePageVO> getDictTypePage(DictTypePageQuery queryParams) {
// 查询参数 // 查询参数
int pageNum = queryParams.getPageNum(); int pageNum = queryParams.getPageNum();
int pageSize = queryParams.getPageSize(); int pageSize = queryParams.getPageSize();
@@ -74,7 +74,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
* @return * @return
*/ */
@Override @Override
public DictTypeForm getDictTypeFormData(Long id) { public DictTypeForm getDictTypeForm(Long id) {
// 获取entity // 获取entity
SysDictType entity = this.getOne(new LambdaQueryWrapper<SysDictType>() SysDictType entity = this.getOne(new LambdaQueryWrapper<SysDictType>()
.eq(SysDictType::getId, id) .eq(SysDictType::getId, id)
@@ -128,9 +128,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
String oldCode = sysDictType.getCode(); String oldCode = sysDictType.getCode();
String newCode = dictTypeForm.getCode(); String newCode = dictTypeForm.getCode();
if (!StrUtil.equals(oldCode, newCode)) { if (!StrUtil.equals(oldCode, newCode)) {
dictItemService.update(new LambdaUpdateWrapper<SysDictItem>() dictItemService.update(new LambdaUpdateWrapper<SysDict>()
.eq(SysDictItem::getTypeCode, oldCode) .eq(SysDict::getTypeCode, oldCode)
.set(SysDictItem::getTypeCode, newCode) .set(SysDict::getTypeCode, newCode)
); );
} }
} }
@@ -162,8 +162,8 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
.collect(Collectors.toList() .collect(Collectors.toList()
); );
if (CollectionUtil.isNotEmpty(dictTypeCodes)) { if (CollectionUtil.isNotEmpty(dictTypeCodes)) {
dictItemService.remove(new LambdaQueryWrapper<SysDictItem>() dictItemService.remove(new LambdaQueryWrapper<SysDict>()
.in(SysDictItem::getTypeCode, dictTypeCodes)); .in(SysDict::getTypeCode, dictTypeCodes));
} }
// 删除字典类型 // 删除字典类型
boolean result = this.removeByIds(ids); boolean result = this.removeByIds(ids);
@@ -179,9 +179,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
@Override @Override
public List<Option> listDictItemsByTypeCode(String typeCode) { public List<Option> listDictItemsByTypeCode(String typeCode) {
// 数据字典项 // 数据字典项
List<SysDictItem> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDictItem>() List<SysDict> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDict>()
.eq(SysDictItem::getTypeCode, typeCode) .eq(SysDict::getTypeCode, typeCode)
.select(SysDictItem::getValue, SysDictItem::getName) .select(SysDict::getValue, SysDict::getName)
); );
// 转换下拉数据 // 转换下拉数据

View File

@@ -50,7 +50,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
* @return * @return
*/ */
@Override @Override
public Page<RolePageVO> listRolePages(RolePageQuery queryParams) { public Page<RolePageVO> getRolePage(RolePageQuery queryParams) {
// 查询参数 // 查询参数
int pageNum = queryParams.getPageNum(); int pageNum = queryParams.getPageNum();
int pageSize = queryParams.getPageSize(); 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; return list;
} }
/** /**
* 保存角色
*
* @param roleForm * @param roleForm
* @return * @return
*/ */
@@ -116,12 +118,25 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
return result; 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 roleId 角色ID
* @param status * @param status 角色状态(1:启用0:禁用)
* @return * @return {@link Boolean}
*/ */
@Override @Override
public boolean updateRoleStatus(Long roleId, Integer status) { 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 * @return
*/ */
@Override @Override
@@ -154,14 +169,13 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
} }
/** /**
* 获取角色的资源ID集合,资源包括菜单和权限 * 获取角色的菜单ID集合
* *
* @param roleId * @param roleId 角色ID
* @return * @return 菜单ID集合(包括按钮权限ID)
*/ */
@Override @Override
public List<Long> getRoleMenuIds(Long roleId) { public List<Long> getRoleMenuIds(Long roleId) {
// 获取角色拥有的菜单ID集合
List<Long> menuIds = sysRoleMenuService.listMenuIdsByRoleId(roleId); List<Long> menuIds = sysRoleMenuService.listMenuIdsByRoleId(roleId);
return menuIds; return menuIds;
} }

View File

@@ -65,7 +65,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return * @return
*/ */
@Override @Override
public IPage<UserPageVO> listUserPages(UserPageQuery queryParams) { public IPage<UserPageVO> getUserPage(UserPageQuery queryParams) {
// 参数构建 // 参数构建
int pageNum = queryParams.getPageNum(); 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> 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); Page<UserPageVO> userVoPage = userConverter.bo2Vo(userBoPage);

View File

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

View File

@@ -5,7 +5,7 @@
<mapper namespace="com.youlai.system.mapper.SysUserMapper"> <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 SELECT
u.id, u.id,
u.username, u.username,