refactor: 系统功能重构
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.youlai</groupId>
|
<groupId>com.youlai</groupId>
|
||||||
<artifactId>youlai-boot</artifactId>
|
<artifactId>youlai-boot</artifactId>
|
||||||
<version>2.8.1</version>
|
<version>2.9.0</version>
|
||||||
<description>基于 Java 17 + SpringBoot 3 + Spring Security 构建的权限管理系统。</description>
|
<description>基于 Java 17 + SpringBoot 3 + Spring Security 构建的权限管理系统。</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ INSERT INTO `sys_dept` VALUES (3, '测试部门', 1, '0,1', 1, 1, 0, NULL, '2022
|
|||||||
DROP TABLE IF EXISTS `sys_dict`;
|
DROP TABLE IF EXISTS `sys_dict`;
|
||||||
CREATE TABLE `sys_dict` (
|
CREATE TABLE `sys_dict` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
`type_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典类型编码',
|
`type_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典编码',
|
||||||
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项名称',
|
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项名称',
|
||||||
`value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项值',
|
`value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项值',
|
||||||
`sort` int NULL DEFAULT 0 COMMENT '排序',
|
`sort` int NULL DEFAULT 0 COMMENT '排序',
|
||||||
@@ -69,10 +69,10 @@ INSERT INTO `sys_dict` VALUES (2, 'gender', '女', '2', 2, 1, 0, NULL, '2019-04-
|
|||||||
INSERT INTO `sys_dict` 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
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `sys_dict_type`;
|
DROP TABLE IF EXISTS `sys_dict`;
|
||||||
CREATE TABLE `sys_dict_type` (
|
CREATE TABLE `sys_dict` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键 ',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键 ',
|
||||||
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型名称',
|
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型名称',
|
||||||
`code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型编码',
|
`code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型编码',
|
||||||
@@ -82,12 +82,12 @@ CREATE TABLE `sys_dict_type` (
|
|||||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `type_code`(`code` ASC) USING BTREE
|
UNIQUE INDEX `type_code`(`code` ASC) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 89 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典类型表' ROW_FORMAT = DYNAMIC;
|
) ENGINE = InnoDB AUTO_INCREMENT = 89 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典表' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_dict_type
|
-- Records of sys_dict
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `sys_dict_type` VALUES (1, '性别', 'gender', 1, NULL, '2019-12-06 19:03:32', '2022-06-12 16:21:28');
|
INSERT INTO `sys_dict` VALUES (1, '性别', 'gender', 1, NULL, '2019-12-06 19:03:32', '2022-06-12 16:21:28');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_menu
|
-- Table structure for sys_menu
|
||||||
@@ -148,9 +148,9 @@ INSERT INTO `sys_menu` VALUES (75, 4, '0,1,4', '菜单删除', 4, '', NULL, 'sys
|
|||||||
INSERT INTO `sys_menu` VALUES (76, 5, '0,1,5', '部门新增', 4, '', NULL, 'sys:dept:add', NULL, NULL, 1, 1, '', NULL, '2023-05-20 23:45:00', '2023-05-20 23:45:00', NULL);
|
INSERT INTO `sys_menu` VALUES (76, 5, '0,1,5', '部门新增', 4, '', NULL, 'sys:dept:add', NULL, NULL, 1, 1, '', NULL, '2023-05-20 23:45:00', '2023-05-20 23:45:00', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (77, 5, '0,1,5', '部门编辑', 4, '', NULL, 'sys:dept:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-20 23:46:16', '2023-05-20 23:46:16', NULL);
|
INSERT INTO `sys_menu` VALUES (77, 5, '0,1,5', '部门编辑', 4, '', NULL, 'sys:dept:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-20 23:46:16', '2023-05-20 23:46:16', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (78, 5, '0,1,5', '部门删除', 4, '', NULL, 'sys:dept:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-20 23:46:36', '2023-05-20 23:46:36', NULL);
|
INSERT INTO `sys_menu` VALUES (78, 5, '0,1,5', '部门删除', 4, '', NULL, 'sys:dept:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-20 23:46:36', '2023-05-20 23:46:36', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (79, 6, '0,1,6', '字典类型新增', 4, '', NULL, 'sys:dict_type:add', NULL, NULL, 1, 1, '', NULL, '2023-05-21 00:16:06', '2023-05-21 00:16:06', NULL);
|
INSERT INTO `sys_menu` VALUES (79, 6, '0,1,6', '字典新增', 4, '', NULL, 'sys:dict_type:add', NULL, NULL, 1, 1, '', NULL, '2023-05-21 00:16:06', '2023-05-21 00:16:06', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (81, 6, '0,1,6', '字典类型编辑', 4, '', NULL, 'sys:dict_type:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-21 00:27:37', '2023-05-21 00:27:37', NULL);
|
INSERT INTO `sys_menu` VALUES (81, 6, '0,1,6', '字典编辑', 4, '', NULL, 'sys:dict_type:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-21 00:27:37', '2023-05-21 00:27:37', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (84, 6, '0,1,6', '字典类型删除', 4, '', NULL, 'sys:dict_type:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-21 00:29:39', '2023-05-21 00:29:39', NULL);
|
INSERT INTO `sys_menu` VALUES (84, 6, '0,1,6', '字典删除', 4, '', NULL, 'sys:dict_type:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-21 00:29:39', '2023-05-21 00:29:39', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (85, 6, '0,1,6', '字典数据新增', 4, '', NULL, 'sys:dict:add', NULL, NULL, 1, 4, '', NULL, '2023-05-21 00:46:56', '2023-05-21 00:47:06', NULL);
|
INSERT INTO `sys_menu` VALUES (85, 6, '0,1,6', '字典数据新增', 4, '', NULL, 'sys:dict:add', NULL, NULL, 1, 4, '', NULL, '2023-05-21 00:46:56', '2023-05-21 00:47:06', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (86, 6, '0,1,6', '字典数据编辑', 4, '', NULL, 'sys:dict:edit', NULL, NULL, 1, 5, '', NULL, '2023-05-21 00:47:36', '2023-05-21 00:47:36', NULL);
|
INSERT INTO `sys_menu` VALUES (86, 6, '0,1,6', '字典数据编辑', 4, '', NULL, 'sys:dict:edit', NULL, NULL, 1, 5, '', NULL, '2023-05-21 00:47:36', '2023-05-21 00:47:36', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (87, 6, '0,1,6', '字典数据删除', 4, '', NULL, 'sys:dict:delete', NULL, NULL, 1, 6, '', NULL, '2023-05-21 00:48:10', '2023-05-21 00:48:20', NULL);
|
INSERT INTO `sys_menu` VALUES (87, 6, '0,1,6', '字典数据删除', 4, '', NULL, 'sys:dict:delete', NULL, NULL, 1, 6, '', NULL, '2023-05-21 00:48:10', '2023-05-21 00:48:20', NULL);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ INSERT INTO `sys_dept` VALUES (3, '测试部门', 1, '0,1', 1, 1, 0, NULL, '2022
|
|||||||
DROP TABLE IF EXISTS `sys_dict`;
|
DROP TABLE IF EXISTS `sys_dict`;
|
||||||
CREATE TABLE `sys_dict` (
|
CREATE TABLE `sys_dict` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
`id` bigint 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 NULL DEFAULT 0 COMMENT '排序',
|
||||||
@@ -71,10 +71,10 @@ INSERT INTO `sys_dict` VALUES (2, 'gender', '女', '2', 2, 1, 0, NULL, '2019-04-
|
|||||||
INSERT INTO `sys_dict` 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
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `sys_dict_type`;
|
DROP TABLE IF EXISTS `sys_dict`;
|
||||||
CREATE TABLE `sys_dict_type` (
|
CREATE TABLE `sys_dict` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键 ',
|
`id` bigint 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 '类型编码',
|
||||||
@@ -84,12 +84,12 @@ CREATE TABLE `sys_dict_type` (
|
|||||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `type_code`(`code` ASC) USING BTREE
|
UNIQUE INDEX `type_code`(`code` ASC) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 89 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
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `sys_dict_type` VALUES (1, '性别', 'gender', 1, NULL, '2019-12-06 19:03:32', '2022-06-12 16:21:28');
|
INSERT INTO `sys_dict` VALUES (1, '性别', 'gender', 1, NULL, '2019-12-06 19:03:32', '2022-06-12 16:21:28');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_menu
|
-- Table structure for sys_menu
|
||||||
@@ -150,9 +150,9 @@ INSERT INTO `sys_menu` VALUES (75, 4, '0,1,4', '菜单删除', 4, '', NULL, 'sys
|
|||||||
INSERT INTO `sys_menu` VALUES (76, 5, '0,1,5', '部门新增', 4, '', NULL, 'sys:dept:add', NULL, NULL, 1, 1, '', NULL, '2023-05-20 23:45:00', '2023-05-20 23:45:00', NULL);
|
INSERT INTO `sys_menu` VALUES (76, 5, '0,1,5', '部门新增', 4, '', NULL, 'sys:dept:add', NULL, NULL, 1, 1, '', NULL, '2023-05-20 23:45:00', '2023-05-20 23:45:00', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (77, 5, '0,1,5', '部门编辑', 4, '', NULL, 'sys:dept:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-20 23:46:16', '2023-05-20 23:46:16', NULL);
|
INSERT INTO `sys_menu` VALUES (77, 5, '0,1,5', '部门编辑', 4, '', NULL, 'sys:dept:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-20 23:46:16', '2023-05-20 23:46:16', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (78, 5, '0,1,5', '部门删除', 4, '', NULL, 'sys:dept:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-20 23:46:36', '2023-05-20 23:46:36', NULL);
|
INSERT INTO `sys_menu` VALUES (78, 5, '0,1,5', '部门删除', 4, '', NULL, 'sys:dept:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-20 23:46:36', '2023-05-20 23:46:36', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (79, 6, '0,1,6', '字典类型新增', 4, '', NULL, 'sys:dict_type:add', NULL, NULL, 1, 1, '', NULL, '2023-05-21 00:16:06', '2023-05-21 00:16:06', NULL);
|
INSERT INTO `sys_menu` VALUES (79, 6, '0,1,6', '字典新增', 4, '', NULL, 'sys:dict_type:add', NULL, NULL, 1, 1, '', NULL, '2023-05-21 00:16:06', '2023-05-21 00:16:06', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (81, 6, '0,1,6', '字典类型编辑', 4, '', NULL, 'sys:dict_type:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-21 00:27:37', '2023-05-21 00:27:37', NULL);
|
INSERT INTO `sys_menu` VALUES (81, 6, '0,1,6', '字典编辑', 4, '', NULL, 'sys:dict_type:edit', NULL, NULL, 1, 2, '', NULL, '2023-05-21 00:27:37', '2023-05-21 00:27:37', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (84, 6, '0,1,6', '字典类型删除', 4, '', NULL, 'sys:dict_type:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-21 00:29:39', '2023-05-21 00:29:39', NULL);
|
INSERT INTO `sys_menu` VALUES (84, 6, '0,1,6', '字典删除', 4, '', NULL, 'sys:dict_type:delete', NULL, NULL, 1, 3, '', NULL, '2023-05-21 00:29:39', '2023-05-21 00:29:39', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (85, 6, '0,1,6', '字典数据新增', 4, '', NULL, 'sys:dict:add', NULL, NULL, 1, 4, '', NULL, '2023-05-21 00:46:56', '2023-05-21 00:47:06', NULL);
|
INSERT INTO `sys_menu` VALUES (85, 6, '0,1,6', '字典数据新增', 4, '', NULL, 'sys:dict:add', NULL, NULL, 1, 4, '', NULL, '2023-05-21 00:46:56', '2023-05-21 00:47:06', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (86, 6, '0,1,6', '字典数据编辑', 4, '', NULL, 'sys:dict:edit', NULL, NULL, 1, 5, '', NULL, '2023-05-21 00:47:36', '2023-05-21 00:47:36', NULL);
|
INSERT INTO `sys_menu` VALUES (86, 6, '0,1,6', '字典数据编辑', 4, '', NULL, 'sys:dict:edit', NULL, NULL, 1, 5, '', NULL, '2023-05-21 00:47:36', '2023-05-21 00:47:36', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (87, 6, '0,1,6', '字典数据删除', 4, '', NULL, 'sys:dict:delete', NULL, NULL, 1, 6, '', NULL, '2023-05-21 00:48:10', '2023-05-21 00:48:20', NULL);
|
INSERT INTO `sys_menu` VALUES (87, 6, '0,1,6', '字典数据删除', 4, '', NULL, 'sys:dict:delete', NULL, NULL, 1, 6, '', NULL, '2023-05-21 00:48:10', '2023-05-21 00:48:20', NULL);
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package com.youlai.system.common.exception;
|
|||||||
|
|
||||||
import com.youlai.system.common.result.IResultCode;
|
import com.youlai.system.common.result.IResultCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.slf4j.helpers.MessageFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义业务异常
|
* 自定义业务异常
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author Ray
|
||||||
* @since 2022/7/31
|
* @since 2022/7/31
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@@ -19,17 +20,19 @@ public class BusinessException extends RuntimeException {
|
|||||||
this.resultCode = errorCode;
|
this.resultCode = errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BusinessException(String message){
|
public BusinessException(String message, Throwable cause) {
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BusinessException(String message, Throwable cause){
|
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BusinessException(Throwable cause){
|
public BusinessException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BusinessException(String message, Object... args) {
|
||||||
|
super(formatMessage(message, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatMessage(String message, Object... args) {
|
||||||
|
return MessageFormatter.arrayFormat(message, args).getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.youlai.system.controller;
|
package com.youlai.system.controller;
|
||||||
|
|
||||||
import com.youlai.system.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
|
import com.youlai.system.plugin.norepeat.annotation.PreventRepeatSubmit;
|
||||||
import com.youlai.system.common.model.Option;
|
import com.youlai.system.common.model.Option;
|
||||||
import com.youlai.system.common.result.Result;
|
import com.youlai.system.common.result.Result;
|
||||||
import com.youlai.system.model.form.DeptForm;
|
import com.youlai.system.model.form.DeptForm;
|
||||||
@@ -11,7 +11,6 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
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;
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -29,23 +28,36 @@ import java.util.List;
|
|||||||
@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 = "获取部门列表")
|
@Operation(summary = "获取部门列表")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public Result<List<DeptVO>> listDepartments(
|
public Result<List<DeptVO>> getDeptList(
|
||||||
@ParameterObject DeptQuery queryParams
|
DeptQuery queryParams
|
||||||
) {
|
) {
|
||||||
List<DeptVO> list = deptService.listDepartments(queryParams);
|
List<DeptVO> list = deptService.getDeptList(queryParams);
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取部门下拉选项")
|
@Operation(summary = "获取部门下拉选项")
|
||||||
@GetMapping("/options")
|
@GetMapping("/options")
|
||||||
public Result<List<Option>> listDeptOptions() {
|
public Result<List<Option>> getDeptOptions() {
|
||||||
List<Option> list = deptService.listDeptOptions();
|
List<Option> list = deptService.listDeptOptions();
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增部门")
|
||||||
|
@PostMapping
|
||||||
|
@PreAuthorize("@ss.hasPerm('sys:dept:add')")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
public Result saveDept(
|
||||||
|
@Valid @RequestBody DeptForm formData
|
||||||
|
) {
|
||||||
|
Long id = deptService.saveDept(formData);
|
||||||
|
return Result.success(id);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取部门表单数据")
|
@Operation(summary = "获取部门表单数据")
|
||||||
@GetMapping("/{deptId}/form")
|
@GetMapping("/{deptId}/form")
|
||||||
public Result<DeptForm> getDeptForm(
|
public Result<DeptForm> getDeptForm(
|
||||||
@@ -55,17 +67,6 @@ public class SysDeptController {
|
|||||||
return Result.success(deptForm);
|
return Result.success(deptForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "新增部门")
|
|
||||||
@PostMapping
|
|
||||||
@PreAuthorize("@ss.hasPerm('sys:dept:add')")
|
|
||||||
@PreventDuplicateSubmit
|
|
||||||
public Result saveDept(
|
|
||||||
@Valid @RequestBody DeptForm formData
|
|
||||||
) {
|
|
||||||
Long id = deptService.saveDept(formData);
|
|
||||||
return Result.success(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "修改部门")
|
@Operation(summary = "修改部门")
|
||||||
@PutMapping(value = "/{deptId}")
|
@PutMapping(value = "/{deptId}")
|
||||||
@PreAuthorize("@ss.hasPerm('sys:dept:edit')")
|
@PreAuthorize("@ss.hasPerm('sys:dept:edit')")
|
||||||
|
|||||||
@@ -3,26 +3,24 @@ package com.youlai.system.controller;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
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.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
|
|
||||||
import com.youlai.system.model.form.DictForm;
|
|
||||||
import com.youlai.system.model.form.DictTypeForm;
|
|
||||||
import com.youlai.system.model.query.DictPageQuery;
|
|
||||||
import com.youlai.system.model.query.DictTypePageQuery;
|
|
||||||
import com.youlai.system.model.vo.DictPageVO;
|
import com.youlai.system.model.vo.DictPageVO;
|
||||||
import com.youlai.system.model.vo.DictTypePageVO;
|
import com.youlai.system.plugin.norepeat.annotation.PreventRepeatSubmit;
|
||||||
import com.youlai.system.common.model.Option;
|
import com.youlai.system.model.form.DictForm;
|
||||||
|
import com.youlai.system.model.query.DictTypePageQuery;
|
||||||
import com.youlai.system.service.SysDictService;
|
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.Parameter;
|
||||||
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;
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
/**
|
||||||
|
* 字典控制层
|
||||||
|
*
|
||||||
|
* @author Ray Hao
|
||||||
|
* @since 2.9.0
|
||||||
|
*/
|
||||||
@Tag(name = "06.字典接口")
|
@Tag(name = "06.字典接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/dict")
|
@RequestMapping("/api/v1/dict")
|
||||||
@@ -31,21 +29,19 @@ public class SysDictController {
|
|||||||
|
|
||||||
private final SysDictService dictService;
|
private final SysDictService dictService;
|
||||||
|
|
||||||
private final SysDictTypeService dictTypeService;
|
|
||||||
|
|
||||||
@Operation(summary = "字典分页列表")
|
@Operation(summary = "字典分页列表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public PageResult<DictPageVO> getDictPage(
|
public PageResult<DictPageVO> getDictPage(
|
||||||
@ParameterObject DictPageQuery queryParams
|
DictTypePageQuery queryParams
|
||||||
) {
|
) {
|
||||||
Page<DictPageVO> result = dictService.getDictPage(queryParams);
|
Page<DictPageVO> result = dictService.getDictPage(queryParams);
|
||||||
return PageResult.success(result);
|
return PageResult.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "字典数据表单数据")
|
@Operation(summary = "字典表单")
|
||||||
@GetMapping("/{id}/form")
|
@GetMapping("/{id}/form")
|
||||||
public Result<DictForm> getDictForm(
|
public Result<DictForm> getDictForm(
|
||||||
@Parameter(description ="字典ID") @PathVariable Long id
|
@Parameter(description = "字典ID") @PathVariable Long id
|
||||||
) {
|
) {
|
||||||
DictForm formData = dictService.getDictForm(id);
|
DictForm formData = dictService.getDictForm(id);
|
||||||
return Result.success(formData);
|
return Result.success(formData);
|
||||||
@@ -54,11 +50,9 @@ public class SysDictController {
|
|||||||
@Operation(summary = "新增字典")
|
@Operation(summary = "新增字典")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@ss.hasPerm('sys:dict:add')")
|
@PreAuthorize("@ss.hasPerm('sys:dict:add')")
|
||||||
@PreventDuplicateSubmit
|
@PreventRepeatSubmit
|
||||||
public Result saveDict(
|
public Result saveDict(@RequestBody DictForm formData) {
|
||||||
@RequestBody DictForm DictForm
|
boolean result = dictService.saveDict(formData);
|
||||||
) {
|
|
||||||
boolean result = dictService.saveDict(DictForm);
|
|
||||||
return Result.judge(result);
|
return Result.judge(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,70 +70,12 @@ public class SysDictController {
|
|||||||
@Operation(summary = "删除字典")
|
@Operation(summary = "删除字典")
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
@PreAuthorize("@ss.hasPerm('sys:dict:delete')")
|
@PreAuthorize("@ss.hasPerm('sys:dict:delete')")
|
||||||
public Result deleteDict(
|
public Result deleteDictionaries(
|
||||||
@Parameter(description ="字典ID,多个以英文逗号(,)拼接") @PathVariable String ids
|
@Parameter(description = "字典ID,多个以英文逗号(,)拼接") @PathVariable String ids
|
||||||
) {
|
) {
|
||||||
boolean result = dictService.deleteDict(ids);
|
dictService.deleteDictByIds(ids);
|
||||||
return Result.judge(result);
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "字典下拉列表")
|
|
||||||
@GetMapping("/{typeCode}/options")
|
|
||||||
public Result<List<Option>> listDictOptions(
|
|
||||||
@Parameter(description ="字典类型编码") @PathVariable String typeCode
|
|
||||||
) {
|
|
||||||
List<Option> list = dictService.listDictOptions(typeCode);
|
|
||||||
return Result.success(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------*/
|
|
||||||
@Operation(summary = "字典类型分页列表")
|
|
||||||
@GetMapping("/types/page")
|
|
||||||
public PageResult<DictTypePageVO> getDictTypePage(
|
|
||||||
@ParameterObject DictTypePageQuery queryParams
|
|
||||||
) {
|
|
||||||
Page<DictTypePageVO> result = dictTypeService.getDictTypePage(queryParams);
|
|
||||||
return PageResult.success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "字典类型表单数据")
|
|
||||||
@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 = "新增字典类型")
|
|
||||||
@PostMapping("/types")
|
|
||||||
@PreAuthorize("@ss.hasPerm('sys:dict_type:add')")
|
|
||||||
@PreventDuplicateSubmit
|
|
||||||
public Result saveDictType(@RequestBody DictTypeForm dictTypeForm) {
|
|
||||||
boolean result = dictTypeService.saveDictType(dictTypeForm);
|
|
||||||
return Result.judge(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "修改字典类型")
|
|
||||||
@PutMapping("/types/{id}")
|
|
||||||
@PreAuthorize("@ss.hasPerm('sys:dict_type:edit')")
|
|
||||||
public Result updateDictType(@PathVariable Long id, @RequestBody DictTypeForm dictTypeForm) {
|
|
||||||
boolean status = dictTypeService.updateDictType(id, dictTypeForm);
|
|
||||||
return Result.judge(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "删除字典类型")
|
|
||||||
@DeleteMapping("/types/{ids}")
|
|
||||||
@PreAuthorize("@ss.hasPerm('sys:dict_type:delete')")
|
|
||||||
public Result deleteDictTypes(
|
|
||||||
@Parameter(description ="字典类型ID,多个以英文逗号(,)分割") @PathVariable String ids
|
|
||||||
) {
|
|
||||||
boolean result = dictTypeService.deleteDictTypes(ids);
|
|
||||||
|
|
||||||
|
|
||||||
return Result.judge(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.youlai.system.controller;
|
package com.youlai.system.controller;
|
||||||
|
|
||||||
import com.youlai.system.common.result.Result;
|
import com.youlai.system.common.result.Result;
|
||||||
import com.youlai.system.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
|
import com.youlai.system.plugin.norepeat.annotation.PreventRepeatSubmit;
|
||||||
import com.youlai.system.model.form.MenuForm;
|
import com.youlai.system.model.form.MenuForm;
|
||||||
import com.youlai.system.model.query.MenuQuery;
|
import com.youlai.system.model.query.MenuQuery;
|
||||||
import com.youlai.system.model.vo.MenuVO;
|
import com.youlai.system.model.vo.MenuVO;
|
||||||
@@ -10,12 +10,9 @@ import com.youlai.system.model.vo.RouteVO;
|
|||||||
import com.youlai.system.service.SysMenuService;
|
import com.youlai.system.service.SysMenuService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
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 lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -38,7 +35,7 @@ public class SysMenuController {
|
|||||||
|
|
||||||
@Operation(summary = "菜单列表")
|
@Operation(summary = "菜单列表")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public Result<List<MenuVO>> listMenus( @ParameterObject MenuQuery queryParams) {
|
public Result<List<MenuVO>> listMenus(MenuQuery queryParams) {
|
||||||
List<MenuVO> menuList = menuService.listMenus(queryParams);
|
List<MenuVO> menuList = menuService.listMenus(queryParams);
|
||||||
return Result.success(menuList);
|
return Result.success(menuList);
|
||||||
}
|
}
|
||||||
@@ -69,7 +66,7 @@ public class SysMenuController {
|
|||||||
@Operation(summary = "新增菜单")
|
@Operation(summary = "新增菜单")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@ss.hasPerm('sys:menu:add')")
|
@PreAuthorize("@ss.hasPerm('sys:menu:add')")
|
||||||
@PreventDuplicateSubmit
|
@PreventRepeatSubmit
|
||||||
public Result addMenu(@RequestBody MenuForm menuForm) {
|
public Result addMenu(@RequestBody MenuForm menuForm) {
|
||||||
boolean result = menuService.saveMenu(menuForm);
|
boolean result = menuService.saveMenu(menuForm);
|
||||||
return Result.judge(result);
|
return Result.judge(result);
|
||||||
@@ -89,7 +86,7 @@ public class SysMenuController {
|
|||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
@PreAuthorize("@ss.hasPerm('sys:menu:delete')")
|
@PreAuthorize("@ss.hasPerm('sys:menu:delete')")
|
||||||
public Result deleteMenu(
|
public Result deleteMenu(
|
||||||
@Parameter(description ="菜单ID,多个以英文(,)分割") @PathVariable("id") Long id
|
@Parameter(description = "菜单ID,多个以英文(,)分割") @PathVariable("id") Long id
|
||||||
) {
|
) {
|
||||||
boolean result = menuService.deleteMenu(id);
|
boolean result = menuService.deleteMenu(id);
|
||||||
return Result.judge(result);
|
return Result.judge(result);
|
||||||
@@ -102,7 +99,7 @@ public class SysMenuController {
|
|||||||
@Parameter(description = "显示状态(1:显示;0:隐藏)") Integer visible
|
@Parameter(description = "显示状态(1:显示;0:隐藏)") Integer visible
|
||||||
|
|
||||||
) {
|
) {
|
||||||
boolean result =menuService.updateMenuVisible(menuId, visible);
|
boolean result = menuService.updateMenuVisible(menuId, visible);
|
||||||
return Result.judge(result);
|
return Result.judge(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.youlai.system.controller;
|
package com.youlai.system.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.youlai.system.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
|
import com.youlai.system.plugin.norepeat.annotation.PreventRepeatSubmit;
|
||||||
import com.youlai.system.common.model.Option;
|
import com.youlai.system.common.model.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;
|
||||||
@@ -13,7 +13,6 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
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;
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ public class SysRoleController {
|
|||||||
@Operation(summary = "角色分页列表")
|
@Operation(summary = "角色分页列表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public PageResult<RolePageVO> getRolePage(
|
public PageResult<RolePageVO> getRolePage(
|
||||||
@ParameterObject RolePageQuery queryParams
|
RolePageQuery queryParams
|
||||||
) {
|
) {
|
||||||
Page<RolePageVO> result = roleService.getRolePage(queryParams);
|
Page<RolePageVO> result = roleService.getRolePage(queryParams);
|
||||||
return PageResult.success(result);
|
return PageResult.success(result);
|
||||||
@@ -48,7 +47,7 @@ public class SysRoleController {
|
|||||||
@Operation(summary = "新增角色")
|
@Operation(summary = "新增角色")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@ss.hasPerm('sys:role:add')")
|
@PreAuthorize("@ss.hasPerm('sys:role:add')")
|
||||||
@PreventDuplicateSubmit
|
@PreventRepeatSubmit
|
||||||
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);
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
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.common.util.ExcelUtils;
|
import com.youlai.system.common.util.ExcelUtils;
|
||||||
import com.youlai.system.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
|
import com.youlai.system.model.dto.UserImportDTO;
|
||||||
|
import com.youlai.system.plugin.norepeat.annotation.PreventRepeatSubmit;
|
||||||
import com.youlai.system.plugin.easyexcel.UserImportListener;
|
import com.youlai.system.plugin.easyexcel.UserImportListener;
|
||||||
import com.youlai.system.model.vo.UserImportVO;
|
|
||||||
import com.youlai.system.model.form.UserForm;
|
import com.youlai.system.model.form.UserForm;
|
||||||
import com.youlai.system.model.entity.SysUser;
|
import com.youlai.system.model.entity.SysUser;
|
||||||
import com.youlai.system.model.query.UserPageQuery;
|
import com.youlai.system.model.query.UserPageQuery;
|
||||||
import com.youlai.system.model.vo.UserExportVO;
|
import com.youlai.system.model.dto.UserExportDTO;
|
||||||
import com.youlai.system.model.vo.UserInfoVO;
|
import com.youlai.system.model.vo.UserInfoVO;
|
||||||
import com.youlai.system.model.vo.UserPageVO;
|
import com.youlai.system.model.vo.UserPageVO;
|
||||||
import com.youlai.system.service.SysUserService;
|
import com.youlai.system.service.SysUserService;
|
||||||
@@ -21,7 +21,6 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
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;
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -54,7 +53,7 @@ public class SysUserController {
|
|||||||
@Operation(summary = "用户分页列表")
|
@Operation(summary = "用户分页列表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public PageResult<UserPageVO> listPagedUsers(
|
public PageResult<UserPageVO> listPagedUsers(
|
||||||
@ParameterObject UserPageQuery queryParams
|
UserPageQuery queryParams
|
||||||
) {
|
) {
|
||||||
IPage<UserPageVO> result = userService.listPagedUsers(queryParams);
|
IPage<UserPageVO> result = userService.listPagedUsers(queryParams);
|
||||||
return PageResult.success(result);
|
return PageResult.success(result);
|
||||||
@@ -63,7 +62,7 @@ public class SysUserController {
|
|||||||
@Operation(summary = "新增用户")
|
@Operation(summary = "新增用户")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@ss.hasPerm('sys:user:add')")
|
@PreAuthorize("@ss.hasPerm('sys:user:add')")
|
||||||
@PreventDuplicateSubmit
|
@PreventRepeatSubmit
|
||||||
public Result saveUser(
|
public Result saveUser(
|
||||||
@RequestBody @Valid UserForm userForm
|
@RequestBody @Valid UserForm userForm
|
||||||
) {
|
) {
|
||||||
@@ -149,9 +148,9 @@ public class SysUserController {
|
|||||||
|
|
||||||
@Operation(summary = "导入用户")
|
@Operation(summary = "导入用户")
|
||||||
@PostMapping("/import")
|
@PostMapping("/import")
|
||||||
public Result importUsers(@Parameter(description = "部门ID") Long deptId, MultipartFile file) throws IOException {
|
public Result importUsers( MultipartFile file) throws IOException {
|
||||||
UserImportListener listener = new UserImportListener(deptId);
|
UserImportListener listener = new UserImportListener();
|
||||||
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportVO.class, listener);
|
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportDTO.class, listener);
|
||||||
return Result.success(msg);
|
return Result.success(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +161,8 @@ public class SysUserController {
|
|||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||||||
|
|
||||||
List<UserExportVO> exportUserList = userService.listExportUsers(queryParams);
|
List<UserExportDTO> exportUserList = userService.listExportUsers(queryParams);
|
||||||
EasyExcel.write(response.getOutputStream(), UserExportVO.class).sheet("用户列表")
|
EasyExcel.write(response.getOutputStream(), UserExportDTO.class).sheet("用户列表")
|
||||||
.doWrite(exportUserList);
|
.doWrite(exportUserList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ import org.mapstruct.Mapper;
|
|||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface DeptConverter {
|
public interface DeptConverter {
|
||||||
|
|
||||||
DeptForm entity2Form(SysDept entity);
|
DeptForm convertToForm(SysDept entity);
|
||||||
DeptVO entity2Vo(SysDept entity);
|
|
||||||
|
|
||||||
SysDept form2Entity(DeptForm deptForm);
|
DeptVO convertToVo(SysDept entity);
|
||||||
|
|
||||||
|
SysDept convertToEntity(DeptForm deptForm);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,22 +4,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.youlai.system.model.entity.SysDict;
|
import com.youlai.system.model.entity.SysDict;
|
||||||
import com.youlai.system.model.form.DictForm;
|
import com.youlai.system.model.form.DictForm;
|
||||||
import com.youlai.system.model.vo.DictPageVO;
|
import com.youlai.system.model.vo.DictPageVO;
|
||||||
import org.mapstruct.InheritInverseConfiguration;
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典数据项对象转换器
|
* 字典 对象转换器
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author Ray Hao
|
||||||
* @since 2022/6/8
|
* @since 2022/6/8
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface DictConverter {
|
public interface DictConverter {
|
||||||
|
|
||||||
Page<DictPageVO> entity2Page(Page<SysDict> page);
|
Page<DictPageVO> convertToPageVo(Page<SysDict> page);
|
||||||
|
|
||||||
DictForm entity2Form(SysDict entity);
|
DictForm convertToForm(SysDict entity);
|
||||||
|
|
||||||
@InheritInverseConfiguration(name="entity2Form")
|
SysDict convertToEntity(DictForm entity);
|
||||||
SysDict form2Entity(DictForm entity);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.youlai.system.converter;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.youlai.system.common.model.Option;
|
||||||
|
import com.youlai.system.model.entity.SysDictItem;
|
||||||
|
import com.youlai.system.model.form.DictForm;
|
||||||
|
import com.youlai.system.model.vo.DictPageVO;
|
||||||
|
import org.mapstruct.InheritInverseConfiguration;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项 对象转换器
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 2022/6/8
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface DictItemConverter {
|
||||||
|
|
||||||
|
Page<DictPageVO> convertToPageVo(Page<SysDictItem> page);
|
||||||
|
|
||||||
|
DictForm convertToForm(SysDictItem entity);
|
||||||
|
|
||||||
|
SysDictItem convertToEntity(DictForm.DictItem dictFormDictItems);
|
||||||
|
List<SysDictItem> convertToEntity(List<DictForm.DictItem> dictFormDictItems);
|
||||||
|
|
||||||
|
DictForm.DictItem convertToDictFormDictItem(SysDictItem entity);
|
||||||
|
List<DictForm.DictItem> convertToDictFormDictItem(List<SysDictItem> entities);
|
||||||
|
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(target = "value", source = "id"),
|
||||||
|
@Mapping(target = "label", source = "name")
|
||||||
|
})
|
||||||
|
Option convertToOption(SysDictItem dictItem);
|
||||||
|
List<Option> convertToOption(List<SysDictItem> dictItems);
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.youlai.system.converter;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.youlai.system.model.entity.SysDictType;
|
|
||||||
import com.youlai.system.model.form.DictTypeForm;
|
|
||||||
import com.youlai.system.model.vo.DictTypePageVO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典类型对象转换器
|
|
||||||
*
|
|
||||||
* @author haoxr
|
|
||||||
* @since 2022/6/8
|
|
||||||
*/
|
|
||||||
@Mapper(componentModel = "spring")
|
|
||||||
public interface DictTypeConverter {
|
|
||||||
|
|
||||||
Page<DictTypePageVO> entity2Page(Page<SysDictType> page);
|
|
||||||
|
|
||||||
DictTypeForm entity2Form(SysDictType entity);
|
|
||||||
|
|
||||||
SysDictType form2Entity(DictTypeForm entity);
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ import org.mapstruct.Mapping;
|
|||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface MenuConverter {
|
public interface MenuConverter {
|
||||||
|
|
||||||
MenuVO entity2Vo(SysMenu entity);
|
MenuVO convertToVo(SysMenu entity);
|
||||||
|
|
||||||
@Mapping(target = "params", ignore = true)
|
@Mapping(target = "params", ignore = true)
|
||||||
MenuForm convertToForm(SysMenu entity);
|
MenuForm convertToForm(SysMenu entity);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface RoleConverter {
|
public interface RoleConverter {
|
||||||
|
|
||||||
Page<RolePageVO> entity2Page(Page<SysRole> page);
|
Page<RolePageVO> convertToPageVo(Page<SysRole> page);
|
||||||
|
|
||||||
@Mappings({
|
@Mappings({
|
||||||
@Mapping(target = "value", source = "id"),
|
@Mapping(target = "value", source = "id"),
|
||||||
@@ -31,7 +31,7 @@ public interface RoleConverter {
|
|||||||
|
|
||||||
List<Option> entities2Options(List<SysRole> roles);
|
List<Option> entities2Options(List<SysRole> roles);
|
||||||
|
|
||||||
SysRole form2Entity(RoleForm roleForm);
|
SysRole convertToEntity(RoleForm roleForm);
|
||||||
|
|
||||||
RoleForm entity2Form(SysRole entity);
|
RoleForm convertToForm(SysRole entity);
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.youlai.system.model.bo.UserBO;
|
import com.youlai.system.model.bo.UserBO;
|
||||||
import com.youlai.system.model.entity.SysUser;
|
import com.youlai.system.model.entity.SysUser;
|
||||||
import com.youlai.system.model.form.UserForm;
|
import com.youlai.system.model.form.UserForm;
|
||||||
import com.youlai.system.model.vo.UserImportVO;
|
import com.youlai.system.model.dto.UserImportDTO;
|
||||||
import com.youlai.system.model.vo.UserInfoVO;
|
import com.youlai.system.model.vo.UserInfoVO;
|
||||||
import com.youlai.system.model.vo.UserPageVO;
|
import com.youlai.system.model.vo.UserPageVO;
|
||||||
import org.mapstruct.InheritInverseConfiguration;
|
import org.mapstruct.InheritInverseConfiguration;
|
||||||
@@ -28,16 +28,16 @@ public interface UserConverter {
|
|||||||
|
|
||||||
Page<UserPageVO> bo2PageVo(Page<UserBO> bo);
|
Page<UserPageVO> bo2PageVo(Page<UserBO> bo);
|
||||||
|
|
||||||
UserForm entity2Form(SysUser entity);
|
UserForm convertToForm(SysUser entity);
|
||||||
|
|
||||||
@InheritInverseConfiguration(name = "entity2Form")
|
@InheritInverseConfiguration(name = "convertToForm")
|
||||||
SysUser form2Entity(UserForm entity);
|
SysUser convertToEntity(UserForm entity);
|
||||||
|
|
||||||
@Mappings({
|
@Mappings({
|
||||||
@Mapping(target = "userId", source = "id")
|
@Mapping(target = "userId", source = "id")
|
||||||
})
|
})
|
||||||
UserInfoVO toUserInfoVo(SysUser entity);
|
UserInfoVO toUserInfoVo(SysUser entity);
|
||||||
|
|
||||||
SysUser importVo2Entity(UserImportVO vo);
|
SysUser convertToEntity(UserImportDTO vo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.youlai.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.youlai.system.model.entity.SysDictItem;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项 访问层
|
||||||
|
*
|
||||||
|
* @author Ray Hao
|
||||||
|
* @since 2.9.0
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,12 +1,29 @@
|
|||||||
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.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.youlai.system.model.entity.SysDict;
|
import com.youlai.system.model.entity.SysDict;
|
||||||
|
import com.youlai.system.model.query.DictTypePageQuery;
|
||||||
|
import com.youlai.system.model.vo.DictPageVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典 访问层
|
||||||
|
*
|
||||||
|
* @author Ray Hao
|
||||||
|
* @since 2.9.0
|
||||||
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SysDictMapper extends BaseMapper<SysDict> {
|
public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典分页列表
|
||||||
|
*
|
||||||
|
* @param page 分页参数
|
||||||
|
* @param queryParams 查询参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<DictPageVO> getDictPage(Page<DictPageVO> page, DictTypePageQuery queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package com.youlai.system.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.youlai.system.model.entity.SysDictType;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -20,11 +20,4 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
|||||||
|
|
||||||
List<RouteBO> listRoutes();
|
List<RouteBO> listRoutes();
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色权限集合
|
|
||||||
*
|
|
||||||
* @param roles
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Set<String> listRolePerms(Set<String> roles);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.youlai.system.model.entity.SysRoleMenu;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色菜单访问层
|
* 角色菜单访问层
|
||||||
@@ -28,4 +29,13 @@ public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
|
|||||||
* 获取权限和拥有权限的角色列表
|
* 获取权限和拥有权限的角色列表
|
||||||
*/
|
*/
|
||||||
List<RolePermsBO> getRolePermsList(String roleCode);
|
List<RolePermsBO> getRolePermsList(String roleCode);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色权限集合
|
||||||
|
*
|
||||||
|
* @param roles
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Set<String> listRolePerms(Set<String> roles);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.youlai.system.model.bo.UserBO;
|
|||||||
import com.youlai.system.model.entity.SysUser;
|
import com.youlai.system.model.entity.SysUser;
|
||||||
import com.youlai.system.model.dto.UserAuthInfo;
|
import com.youlai.system.model.dto.UserAuthInfo;
|
||||||
import com.youlai.system.model.query.UserPageQuery;
|
import com.youlai.system.model.query.UserPageQuery;
|
||||||
import com.youlai.system.model.vo.UserExportVO;
|
import com.youlai.system.model.dto.UserExportDTO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -55,5 +55,5 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@DataPermission(deptAlias = "u")
|
@DataPermission(deptAlias = "u")
|
||||||
List<UserExportVO> listExportUsers(UserPageQuery queryParams);
|
List<UserExportDTO> listExportUsers(UserPageQuery queryParams);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,19 @@ public class RouteBO {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单类型(1-菜单;2-目录;3-外链;4-按钮权限)
|
* 菜单类型(1-菜单 2-目录 3-外链 4-按钮)
|
||||||
*/
|
*/
|
||||||
private MenuTypeEnum type;
|
private MenuTypeEnum type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由路径(浏览器地址栏路径)
|
* 路由名称(Vue Router 中定义的路由名称)
|
||||||
*/
|
*/
|
||||||
private String path;
|
private String routeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由路径(Vue Router 中定义的 URL 路径)
|
||||||
|
*/
|
||||||
|
private String routePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件路径(vue页面完整路径,省略.vue后缀)
|
* 组件路径(vue页面完整路径,省略.vue后缀)
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package com.youlai.system.model.bo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* user表单持久化对象
|
|
||||||
*
|
|
||||||
* @author haoxr
|
|
||||||
* @since 2022/6/10
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class UserFormBO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名
|
|
||||||
*/
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
private String nickname;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号
|
|
||||||
*/
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 性别(1:男;2:女)
|
|
||||||
*/
|
|
||||||
private Integer gender;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户头像
|
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态(1:启用;0:禁用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色ID集合
|
|
||||||
*/
|
|
||||||
private List<Long> roleIds;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -9,17 +9,17 @@ import lombok.NoArgsConstructor;
|
|||||||
/**
|
/**
|
||||||
* 验证码响应对象
|
* 验证码响应对象
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author Ray Hao
|
||||||
* @since 2023/03/24
|
* @since 2023/03/24
|
||||||
*/
|
*/
|
||||||
@Schema(description ="验证码响应对象")
|
@Schema(description = "验证码响应对象")
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class CaptchaResult {
|
public class CaptchaResult {
|
||||||
|
|
||||||
@Schema(description = "验证码缓存key")
|
@Schema(description = "验证码ID")
|
||||||
private String captchaKey;
|
private String captchaKey;
|
||||||
|
|
||||||
@Schema(description = "验证码图片Base64字符串")
|
@Schema(description = "验证码图片Base64字符串")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.youlai.system.model.vo;
|
package com.youlai.system.model.dto;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||||
@@ -16,7 +16,7 @@ import java.time.LocalDateTime;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ColumnWidth(20)
|
@ColumnWidth(20)
|
||||||
public class UserExportVO {
|
public class UserExportDTO {
|
||||||
|
|
||||||
@ExcelProperty(value = "用户名")
|
@ExcelProperty(value = "用户名")
|
||||||
private String username;
|
private String username;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.youlai.system.model.vo;
|
package com.youlai.system.model.dto;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -10,7 +10,7 @@ import lombok.Data;
|
|||||||
* @since 2022/4/10
|
* @since 2022/4/10
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class UserImportVO {
|
public class UserImportDTO {
|
||||||
|
|
||||||
@ExcelProperty(value = "用户名")
|
@ExcelProperty(value = "用户名")
|
||||||
private String username;
|
private String username;
|
||||||
@@ -30,4 +30,7 @@ public class UserImportVO {
|
|||||||
@ExcelProperty("角色")
|
@ExcelProperty("角色")
|
||||||
private String roleCodes;
|
private String roleCodes;
|
||||||
|
|
||||||
|
@ExcelProperty("部门")
|
||||||
|
private String deptCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门表
|
* 部门 实体
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 2024/06/23
|
||||||
*/
|
*/
|
||||||
@Data
|
@Getter
|
||||||
|
@Setter
|
||||||
public class SysDept extends BaseEntity {
|
public class SysDept extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
@@ -22,6 +27,11 @@ public class SysDept extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门编码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父节点id
|
* 父节点id
|
||||||
*/
|
*/
|
||||||
@@ -38,17 +48,18 @@ public class SysDept extends BaseEntity {
|
|||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(1:正常;0:禁用)
|
* 状态(1-正常 0-禁用)
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 逻辑删除标识(1:已删除;0:未删除)
|
* 创建人 ID
|
||||||
*/
|
*/
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
private Long createBy;
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人 ID
|
||||||
|
*/
|
||||||
private Long updateBy;
|
private Long updateBy;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,18 @@
|
|||||||
package com.youlai.system.model.entity;
|
package com.youlai.system.model.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.youlai.system.common.base.BaseEntity;
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典数据表
|
* 字典实体
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author haoxr
|
||||||
* @since 2022/12/17
|
* @since 2022/12/17
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class SysDict implements Serializable {
|
public class SysDict extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@@ -23,41 +20,23 @@ public class SysDict implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典类型编码
|
* 类型名称
|
||||||
*/
|
|
||||||
private String typeCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典项名称
|
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典项值
|
* 类型编码
|
||||||
*/
|
*/
|
||||||
private String value;
|
private String code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序
|
* 状态(0:正常;1:禁用)
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态(1:正常;0:禁用)
|
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否默认(1:是;0:否)
|
|
||||||
*/
|
|
||||||
private Integer defaulted;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
@TableField(exist = false)
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
}
|
||||||
@@ -2,17 +2,19 @@ package com.youlai.system.model.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典类型实体
|
* 字典项实体
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author haoxr
|
||||||
* @since 2022/12/17
|
* @since 2022/12/17
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class SysDictType extends BaseEntity {
|
public class SysDictItem implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@@ -20,17 +22,27 @@ public class SysDictType extends BaseEntity {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型名称
|
* 字典类ID
|
||||||
|
*/
|
||||||
|
private Long dictId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型编码
|
* 字典项值
|
||||||
*/
|
*/
|
||||||
private String code;
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(0:正常;1:禁用)
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(1-正常,0-禁用)
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@@ -2,19 +2,21 @@ package com.youlai.system.model.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
|
||||||
import com.youlai.system.common.enums.MenuTypeEnum;
|
import com.youlai.system.common.enums.MenuTypeEnum;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单实体对象
|
* 菜单 实体
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author Ray
|
||||||
* @since 2023/3/6
|
* @since 2023/3/6
|
||||||
*/
|
*/
|
||||||
@TableName(value ="sys_menu")
|
@Getter
|
||||||
@Data
|
@Setter
|
||||||
public class SysMenu extends BaseEntity {
|
public class SysMenu {
|
||||||
/**
|
/**
|
||||||
* 菜单ID
|
* 菜单ID
|
||||||
*/
|
*/
|
||||||
@@ -37,9 +39,14 @@ public class SysMenu extends BaseEntity {
|
|||||||
private MenuTypeEnum type;
|
private MenuTypeEnum type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由路径(浏览器地址栏路径)
|
* 路由名称(Vue Router 中定义的路由名称)
|
||||||
*/
|
*/
|
||||||
private String path;
|
private String routeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由路径(Vue Router 中定义的 URL 路径)
|
||||||
|
*/
|
||||||
|
private String routePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件路径(vue页面完整路径,省略.vue后缀)
|
* 组件路径(vue页面完整路径,省略.vue后缀)
|
||||||
@@ -92,4 +99,14 @@ public class SysMenu extends BaseEntity {
|
|||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private String params;
|
private String params;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,18 +2,21 @@ package com.youlai.system.model.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色表
|
* 角色 实体
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 2024/6/23
|
||||||
*/
|
*/
|
||||||
@TableName(value ="sys_role")
|
@Getter
|
||||||
@Data
|
@Setter
|
||||||
public class SysRole extends BaseEntity {
|
public class SysRole extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
*
|
* 主键
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -34,17 +37,22 @@ public class SysRole extends BaseEntity {
|
|||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色状态(1-正常;0-停用)
|
* 角色状态(1-正常 0-停用)
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标识(0-未删除;1-已删除)
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限
|
* 数据权限
|
||||||
*/
|
*/
|
||||||
private Integer dataScope;
|
private Integer dataScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人 ID
|
||||||
|
*/
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人 ID
|
||||||
|
*/
|
||||||
|
private Long updateBy;
|
||||||
}
|
}
|
||||||
@@ -3,15 +3,17 @@ package com.youlai.system.model.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.youlai.system.common.base.BaseEntity;
|
import com.youlai.system.common.base.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户表
|
* 用户 实体
|
||||||
*/
|
*/
|
||||||
@Data
|
@Getter
|
||||||
|
@Setter
|
||||||
public class SysUser extends BaseEntity {
|
public class SysUser extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
*
|
* 用户 ID
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -27,7 +29,7 @@ public class SysUser extends BaseEntity {
|
|||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 性别((1:男;2:女))
|
* 性别((1-男 2-女 0-保密)
|
||||||
*/
|
*/
|
||||||
private Integer gender;
|
private Integer gender;
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ public class SysUser extends BaseEntity {
|
|||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户状态((1:正常;0:禁用))
|
* 状态((1-正常 0-禁用)
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@@ -62,8 +64,12 @@ public class SysUser extends BaseEntity {
|
|||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 逻辑删除标识(0:未删除;1:已删除)
|
* 创建人 ID
|
||||||
*/
|
*/
|
||||||
private Integer deleted;
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人 ID
|
||||||
|
*/
|
||||||
|
private Long updateBy;
|
||||||
}
|
}
|
||||||
@@ -2,26 +2,31 @@ package com.youlai.system.model.form;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@Schema(description = "部门表单对象")
|
@Schema(description = "部门表单对象")
|
||||||
@Data
|
@Getter
|
||||||
|
@Setter
|
||||||
public class DeptForm {
|
public class DeptForm {
|
||||||
|
|
||||||
@Schema(description="部门ID")
|
@Schema(description="部门ID", example = "1001")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description="部门名称")
|
@Schema(description="部门名称", example = "研发部")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description="父部门ID")
|
@Schema(description="部门编号", example = "RD001")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description="父部门ID", example = "1000")
|
||||||
@NotNull(message = "父部门ID不能为空")
|
@NotNull(message = "父部门ID不能为空")
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
@Schema(description="状态(1:启用;0:禁用)")
|
@Schema(description="状态(1:启用;0:禁用)", example = "1")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description="排序(数字越小排名越靠前)")
|
@Schema(description="排序(数字越小排名越靠前)", example = "1")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,30 +3,57 @@ package com.youlai.system.model.form;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@Schema(description = "字典表单对象")
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典表单对象
|
||||||
|
*
|
||||||
|
* @author Ray Hao
|
||||||
|
* @since 2.9.0
|
||||||
|
*/
|
||||||
|
@Schema(description = "字典")
|
||||||
@Data
|
@Data
|
||||||
public class DictForm {
|
public class DictForm {
|
||||||
|
|
||||||
@Schema(description="字典ID")
|
@Schema(description = "字典ID",example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description="类型编码")
|
@Schema(description = "字典名称",example = "性别")
|
||||||
private String typeCode;
|
|
||||||
|
|
||||||
@Schema(description="字典名称")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description="字典值")
|
@Schema(description = "字典编码", example ="gender")
|
||||||
private String value;
|
private String code;
|
||||||
|
|
||||||
@Schema(description="状态(1:启用;0:禁用)")
|
@Schema(description = "字典状态(1-启用,0-禁用)", example = "1")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description="排序")
|
@Schema(description = "字典数据项列表",example = "[{\"id\":1,\"name\":\"男\",\"value\":\"1\",\"sort\":1,\"status\":1},{\"id\":2,\"name\":\"女\",\"value\":\"2\",\"sort\":2,\"status\":1}]")
|
||||||
|
private List<DictItem> dictItems;
|
||||||
|
|
||||||
|
@Schema(description = "字典数据项")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public static class DictItem {
|
||||||
|
|
||||||
|
@Schema(description = "字典ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "字典名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "字典值")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
@Schema(description = "字典备注")
|
@Schema(description = "状态(1-启用,0-禁用)")
|
||||||
private String remark;
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.youlai.system.model.form;
|
|
||||||
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Schema(description = "字典类型")
|
|
||||||
@Data
|
|
||||||
public class DictTypeForm {
|
|
||||||
|
|
||||||
@Schema(description="字典类型ID")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description="类型名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Schema(description="类型编码")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@Schema(description="类型状态(1:启用;0:禁用)")
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
@Schema(description = "备注")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,13 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单表单对象
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 2024/06/23
|
||||||
|
*/
|
||||||
@Schema(description = "菜单表单对象")
|
@Schema(description = "菜单表单对象")
|
||||||
@Data
|
@Data
|
||||||
public class MenuForm {
|
public class MenuForm {
|
||||||
@@ -21,11 +26,14 @@ public class MenuForm {
|
|||||||
@Schema(description = "菜单名称")
|
@Schema(description = "菜单名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "菜单类型(1-菜单;2-目录;3-外链;4-按钮权限)")
|
@Schema(description = "菜单类型(1-菜单 2-目录 3-外链 4-按钮)")
|
||||||
private MenuTypeEnum type;
|
private MenuTypeEnum type;
|
||||||
|
|
||||||
|
@Schema(description = "路由名称")
|
||||||
|
private String routeName;
|
||||||
|
|
||||||
@Schema(description = "路由路径")
|
@Schema(description = "路由路径")
|
||||||
private String path;
|
private String routePath;
|
||||||
|
|
||||||
@Schema(description = "组件路径(vue页面完整路径,省略.vue后缀)")
|
@Schema(description = "组件路径(vue页面完整路径,省略.vue后缀)")
|
||||||
private String component;
|
private String component;
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ public class DictPageQuery extends BasePageQuery {
|
|||||||
@Schema(description="关键字(字典项名称)")
|
@Schema(description="关键字(字典项名称)")
|
||||||
private String keywords;
|
private String keywords;
|
||||||
|
|
||||||
@Schema(description="字典类型编码")
|
@Schema(description="字典编码")
|
||||||
private String typeCode;
|
private String typeCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.youlai.system.common.base.BasePageQuery;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description ="字典类型分页查询对象")
|
@Schema(description ="字典分页查询对象")
|
||||||
@Data
|
@Data
|
||||||
public class DictTypePageQuery extends BasePageQuery {
|
public class DictTypePageQuery extends BasePageQuery {
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ public class DeptVO {
|
|||||||
@Schema(description = "部门名称")
|
@Schema(description = "部门名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "部门编号")
|
||||||
|
private String code;
|
||||||
|
|
||||||
@Schema(description = "排序")
|
@Schema(description = "排序")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,58 @@ package com.youlai.system.model.vo;
|
|||||||
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@Schema(description ="字典分页对象")
|
import java.util.List;
|
||||||
@Data
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典分页VO
|
||||||
|
*
|
||||||
|
* @author Ray
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
|
@Schema(description = "字典分页对象")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class DictPageVO {
|
public class DictPageVO {
|
||||||
|
|
||||||
@Schema(description="字典ID")
|
@Schema(description = "字典ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description="字典名称")
|
@Schema(description = "字典名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description="字典值")
|
@Schema(description = "字典编码")
|
||||||
private String value;
|
private String code;
|
||||||
|
|
||||||
@Schema(description="状态(1:启用;0:禁用)")
|
@Schema(description = "字典状态(1-启用,0-禁用)")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "字典项列表")
|
||||||
|
private List<DictItem> dictItems;
|
||||||
|
|
||||||
|
@Schema(description = "字典")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public static class DictItem {
|
||||||
|
|
||||||
|
@Schema(description = "字典项ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "字典项名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "字典项值")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@Schema(description = "状态(1-启用,0-禁用)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.youlai.system.model.vo;
|
|
||||||
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Schema(description ="字典类型分页对象")
|
|
||||||
@Data
|
|
||||||
public class DictTypePageVO {
|
|
||||||
|
|
||||||
@Schema(description="字典类型ID")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description="类型名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Schema(description="类型编码")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@Schema(description="状态:1:启用;0:禁用")
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -23,8 +23,11 @@ public class MenuVO {
|
|||||||
@Schema(description="菜单类型")
|
@Schema(description="菜单类型")
|
||||||
private MenuTypeEnum type;
|
private MenuTypeEnum type;
|
||||||
|
|
||||||
|
@Schema(description = "路由名称")
|
||||||
|
private String routeName;
|
||||||
|
|
||||||
@Schema(description = "路由路径")
|
@Schema(description = "路由路径")
|
||||||
private String path;
|
private String routePath;
|
||||||
|
|
||||||
@Schema(description = "组件路径")
|
@Schema(description = "组件路径")
|
||||||
private String component;
|
private String component;
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ import com.youlai.system.common.constant.SystemConstants;
|
|||||||
import com.youlai.system.common.enums.GenderEnum;
|
import com.youlai.system.common.enums.GenderEnum;
|
||||||
import com.youlai.system.common.enums.StatusEnum;
|
import com.youlai.system.common.enums.StatusEnum;
|
||||||
import com.youlai.system.converter.UserConverter;
|
import com.youlai.system.converter.UserConverter;
|
||||||
|
import com.youlai.system.model.dto.UserImportDTO;
|
||||||
|
import com.youlai.system.model.entity.SysDept;
|
||||||
import com.youlai.system.model.entity.SysRole;
|
import com.youlai.system.model.entity.SysRole;
|
||||||
import com.youlai.system.model.entity.SysUser;
|
import com.youlai.system.model.entity.SysUser;
|
||||||
import com.youlai.system.model.entity.SysUserRole;
|
import com.youlai.system.model.entity.SysUserRole;
|
||||||
import com.youlai.system.model.vo.UserImportVO;
|
import com.youlai.system.service.SysDeptService;
|
||||||
import com.youlai.system.service.SysRoleService;
|
import com.youlai.system.service.SysRoleService;
|
||||||
import com.youlai.system.service.SysUserRoleService;
|
import com.youlai.system.service.SysUserRoleService;
|
||||||
import com.youlai.system.service.SysUserService;
|
import com.youlai.system.service.SysUserService;
|
||||||
@@ -30,11 +32,11 @@ import java.util.stream.Collectors;
|
|||||||
* <p>
|
* <p>
|
||||||
* <a href="https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read#%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E8%AF%BB%E7%9A%84%E7%9B%91%E5%90%AC%E5%99%A8">最简单的读的监听器</a>
|
* <a href="https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read#%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E8%AF%BB%E7%9A%84%E7%9B%91%E5%90%AC%E5%99%A8">最简单的读的监听器</a>
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author Ray
|
||||||
* @since 2022/4/10 20:49
|
* @since 2022/4/10
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
|
public class UserImportListener extends MyAnalysisEventListener<UserImportDTO> {
|
||||||
|
|
||||||
|
|
||||||
// 有效条数
|
// 有效条数
|
||||||
@@ -46,25 +48,19 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
|
|||||||
// 导入返回信息
|
// 导入返回信息
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
|
|
||||||
// 部门ID
|
|
||||||
private final Long deptId;
|
|
||||||
|
|
||||||
private final SysUserService userService;
|
private final SysUserService userService;
|
||||||
|
|
||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
private final UserConverter userConverter;
|
private final UserConverter userConverter;
|
||||||
|
|
||||||
private final SysRoleService roleService;
|
private final SysRoleService roleService;
|
||||||
|
|
||||||
private final SysUserRoleService userRoleService;
|
private final SysUserRoleService userRoleService;
|
||||||
|
private final SysDeptService deptService;
|
||||||
|
|
||||||
public UserImportListener(Long deptId) {
|
public UserImportListener() {
|
||||||
this.deptId = deptId;
|
|
||||||
this.userService = SpringUtil.getBean(SysUserService.class);
|
this.userService = SpringUtil.getBean(SysUserService.class);
|
||||||
this.passwordEncoder = SpringUtil.getBean(PasswordEncoder.class);
|
this.passwordEncoder = SpringUtil.getBean(PasswordEncoder.class);
|
||||||
this.roleService = SpringUtil.getBean(SysRoleService.class);
|
this.roleService = SpringUtil.getBean(SysRoleService.class);
|
||||||
this.userRoleService = SpringUtil.getBean(SysUserRoleService.class);
|
this.userRoleService = SpringUtil.getBean(SysUserRoleService.class);
|
||||||
|
this.deptService = SpringUtil.getBean(SysDeptService.class);
|
||||||
this.userConverter = SpringUtil.getBean(UserConverter.class);
|
this.userConverter = SpringUtil.getBean(UserConverter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,16 +70,15 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
|
|||||||
* 1. 数据校验;全字段校验
|
* 1. 数据校验;全字段校验
|
||||||
* 2. 数据持久化;
|
* 2. 数据持久化;
|
||||||
*
|
*
|
||||||
* @param userImportVO 一行数据,类似于 {@link AnalysisContext#readRowHolder()}
|
* @param userImportDTO 一行数据,类似于 {@link AnalysisContext#readRowHolder()}
|
||||||
* @param analysisContext
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void invoke(UserImportVO userImportVO, AnalysisContext analysisContext) {
|
public void invoke(UserImportDTO userImportDTO, AnalysisContext analysisContext) {
|
||||||
log.info("解析到一条用户数据:{}", JSONUtil.toJsonStr(userImportVO));
|
log.info("解析到一条用户数据:{}", JSONUtil.toJsonStr(userImportDTO));
|
||||||
// 校验数据
|
// 校验数据
|
||||||
StringBuilder validationMsg = new StringBuilder();
|
StringBuilder validationMsg = new StringBuilder();
|
||||||
|
|
||||||
String username = userImportVO.getUsername();
|
String username = userImportDTO.getUsername();
|
||||||
if (StrUtil.isBlank(username)) {
|
if (StrUtil.isBlank(username)) {
|
||||||
validationMsg.append("用户名为空;");
|
validationMsg.append("用户名为空;");
|
||||||
} else {
|
} else {
|
||||||
@@ -93,12 +88,12 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String nickname = userImportVO.getNickname();
|
String nickname = userImportDTO.getNickname();
|
||||||
if (StrUtil.isBlank(nickname)) {
|
if (StrUtil.isBlank(nickname)) {
|
||||||
validationMsg.append("用户昵称为空;");
|
validationMsg.append("用户昵称为空;");
|
||||||
}
|
}
|
||||||
|
|
||||||
String mobile = userImportVO.getMobile();
|
String mobile = userImportDTO.getMobile();
|
||||||
if (StrUtil.isBlank(mobile)) {
|
if (StrUtil.isBlank(mobile)) {
|
||||||
validationMsg.append("手机号码为空;");
|
validationMsg.append("手机号码为空;");
|
||||||
} else {
|
} else {
|
||||||
@@ -109,29 +104,38 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
|
|||||||
|
|
||||||
if (validationMsg.isEmpty()) {
|
if (validationMsg.isEmpty()) {
|
||||||
// 校验通过,持久化至数据库
|
// 校验通过,持久化至数据库
|
||||||
SysUser entity = userConverter.importVo2Entity(userImportVO);
|
SysUser entity = userConverter.convertToEntity(userImportDTO);
|
||||||
entity.setDeptId(deptId); // 部门
|
|
||||||
entity.setPassword(passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD)); // 默认密码
|
entity.setPassword(passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD)); // 默认密码
|
||||||
// 性别翻译
|
// 性别翻译
|
||||||
String genderLabel = userImportVO.getGenderLabel();
|
String genderLabel = userImportDTO.getGenderLabel();
|
||||||
if (StrUtil.isNotBlank(genderLabel)) {
|
if (StrUtil.isNotBlank(genderLabel)) {
|
||||||
Integer genderValue = (Integer) IBaseEnum.getValueByLabel(genderLabel, GenderEnum.class);
|
Integer genderValue = (Integer) IBaseEnum.getValueByLabel(genderLabel, GenderEnum.class);
|
||||||
entity.setGender(genderValue);
|
entity.setGender(genderValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 角色解析
|
// 角色解析
|
||||||
String roleCodes = userImportVO.getRoleCodes();
|
String roleCodes = userImportDTO.getRoleCodes();
|
||||||
List<Long> roleIds = null;
|
List<Long> roleIds = null;
|
||||||
if (StrUtil.isNotBlank(roleCodes)) {
|
if (StrUtil.isNotBlank(roleCodes)) {
|
||||||
roleIds = roleService.list(
|
roleIds = roleService.list(
|
||||||
new LambdaQueryWrapper<SysRole>()
|
new LambdaQueryWrapper<SysRole>()
|
||||||
.in(SysRole::getCode, roleCodes.split(","))
|
.in(SysRole::getCode, (Object) roleCodes.split(","))
|
||||||
.eq(SysRole::getStatus, StatusEnum.ENABLE.getValue())
|
.eq(SysRole::getStatus, StatusEnum.ENABLE.getValue())
|
||||||
.select(SysRole::getId)
|
.select(SysRole::getId)
|
||||||
).stream()
|
).stream()
|
||||||
.map(SysRole::getId)
|
.map(SysRole::getId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
// 部门解析
|
||||||
|
String deptCode = userImportDTO.getDeptCode();
|
||||||
|
if (StrUtil.isNotBlank(deptCode)) {
|
||||||
|
SysDept dept = deptService.getOne(new LambdaQueryWrapper<SysDept>().eq(SysDept::getCode, deptCode)
|
||||||
|
.select(SysDept::getId)
|
||||||
|
);
|
||||||
|
if (dept != null) {
|
||||||
|
entity.setDeptId(dept.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean saveResult = userService.save(entity);
|
boolean saveResult = userService.save(entity);
|
||||||
@@ -150,18 +154,17 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
invalidCount++;
|
invalidCount++;
|
||||||
msg.append("第" + (validCount + invalidCount) + "行数据校验失败:").append(validationMsg + "<br/>");
|
msg.append("第").append(validCount + invalidCount).append("行数据校验失败:").append(validationMsg + "<br/>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有数据解析完成会来调用
|
* 所有数据解析完成会来调用
|
||||||
*
|
|
||||||
* @param analysisContext
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
log.info("所有数据解析完成!");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +172,6 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
|
|||||||
@Override
|
@Override
|
||||||
public String getMsg() {
|
public String getMsg() {
|
||||||
// 总结信息
|
// 总结信息
|
||||||
String summaryMsg = StrUtil.format("导入用户结束:成功{}条,失败{}条;<br/>{}", validCount, invalidCount, msg);
|
return StrUtil.format("导入用户结束:成功{}条,失败{}条;<br/>{}", validCount, invalidCount, msg);
|
||||||
return summaryMsg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.youlai.system.plugin.dupsubmit.annotation;
|
package com.youlai.system.plugin.norepeat.annotation;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防止重复提交注解
|
* 防止重复提交注解
|
||||||
|
* <p>
|
||||||
|
* 该注解用于方法上,防止在指定时间内的重复提交。
|
||||||
|
* 默认时间为5秒。
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author haoxr
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
@@ -13,10 +16,10 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Inherited
|
@Inherited
|
||||||
public @interface PreventDuplicateSubmit {
|
public @interface PreventRepeatSubmit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防重提交锁过期时间(秒)
|
* 锁过期时间(秒)
|
||||||
* <p>
|
* <p>
|
||||||
* 默认5秒内不允许重复提交
|
* 默认5秒内不允许重复提交
|
||||||
*/
|
*/
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.youlai.system.plugin.dupsubmit.aspect;
|
package com.youlai.system.plugin.norepeat.aspect;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.jwt.JWTUtil;
|
import cn.hutool.jwt.JWTUtil;
|
||||||
@@ -6,7 +6,7 @@ import cn.hutool.jwt.RegisteredPayload;
|
|||||||
import com.youlai.system.common.constant.SecurityConstants;
|
import com.youlai.system.common.constant.SecurityConstants;
|
||||||
import com.youlai.system.common.exception.BusinessException;
|
import com.youlai.system.common.exception.BusinessException;
|
||||||
import com.youlai.system.common.result.ResultCode;
|
import com.youlai.system.common.result.ResultCode;
|
||||||
import com.youlai.system.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
|
import com.youlai.system.plugin.norepeat.annotation.PreventRepeatSubmit;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -41,17 +41,17 @@ public class DuplicateSubmitAspect {
|
|||||||
/**
|
/**
|
||||||
* 防重复提交切点
|
* 防重复提交切点
|
||||||
*/
|
*/
|
||||||
@Pointcut("@annotation(preventDuplicateSubmit)")
|
@Pointcut("@annotation(preventRepeatSubmit)")
|
||||||
public void preventDuplicateSubmitPointCut(PreventDuplicateSubmit preventDuplicateSubmit) {
|
public void preventDuplicateSubmitPointCut(PreventRepeatSubmit preventRepeatSubmit) {
|
||||||
log.info("定义防重复提交切点");
|
log.info("定义防重复提交切点");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Around("preventDuplicateSubmitPointCut(preventDuplicateSubmit)")
|
@Around("preventDuplicateSubmitPointCut(preventRepeatSubmit)")
|
||||||
public Object doAround(ProceedingJoinPoint pjp, PreventDuplicateSubmit preventDuplicateSubmit) throws Throwable {
|
public Object doAround(ProceedingJoinPoint pjp, PreventRepeatSubmit preventRepeatSubmit) throws Throwable {
|
||||||
|
|
||||||
String resubmitLockKey = generateResubmitLockKey();
|
String resubmitLockKey = generateResubmitLockKey();
|
||||||
if (resubmitLockKey != null) {
|
if (resubmitLockKey != null) {
|
||||||
int expire = preventDuplicateSubmit.expire(); // 防重提交锁过期时间
|
int expire = preventRepeatSubmit.expire(); // 防重提交锁过期时间
|
||||||
RLock lock = redissonClient.getLock(resubmitLockKey);
|
RLock lock = redissonClient.getLock(resubmitLockKey);
|
||||||
boolean lockResult = lock.tryLock(0, expire, TimeUnit.SECONDS); // 获取锁失败,直接返回 false
|
boolean lockResult = lock.tryLock(0, expire, TimeUnit.SECONDS); // 获取锁失败,直接返回 false
|
||||||
if (!lockResult) {
|
if (!lockResult) {
|
||||||
@@ -21,7 +21,7 @@ public interface SysDeptService extends IService<SysDept> {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DeptVO> listDepartments(DeptQuery queryParams);
|
List<DeptVO> getDeptList(DeptQuery queryParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门树形下拉选项
|
* 部门树形下拉选项
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.youlai.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.youlai.system.model.entity.SysDictItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项 接口
|
||||||
|
*
|
||||||
|
* @author Ray Hao
|
||||||
|
* @since 2023/3/4
|
||||||
|
*/
|
||||||
|
public interface SysDictItemService extends IService<SysDictItem> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典ID删除字典项
|
||||||
|
*
|
||||||
|
* @param dictId 字典ID
|
||||||
|
*/
|
||||||
|
void removeByDictId(Long dictId);
|
||||||
|
}
|
||||||
@@ -2,68 +2,74 @@ package com.youlai.system.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.youlai.system.common.model.Option;
|
||||||
import com.youlai.system.model.entity.SysDict;
|
import com.youlai.system.model.entity.SysDict;
|
||||||
import com.youlai.system.model.form.DictForm;
|
import com.youlai.system.model.form.DictForm;
|
||||||
import com.youlai.system.model.query.DictPageQuery;
|
import com.youlai.system.model.query.DictTypePageQuery;
|
||||||
import com.youlai.system.model.vo.DictPageVO;
|
import com.youlai.system.model.vo.DictPageVO;
|
||||||
import com.youlai.system.common.model.Option;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典接口
|
* 数据字典业务接口
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author haoxr
|
||||||
* @since 2023/3/4
|
* @since 2022/10/12
|
||||||
*/
|
*/
|
||||||
public interface SysDictService extends IService<SysDict> {
|
public interface SysDictService extends IService<SysDict> {
|
||||||
/**
|
|
||||||
* 字典数据项分页列表
|
|
||||||
*
|
|
||||||
* @param queryParams
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Page<DictPageVO> getDictPage(DictPageQuery queryParams);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典数据项表单
|
* 字典分页列表
|
||||||
*
|
*
|
||||||
* @param id 字典数据项ID
|
* @param queryParams 分页查询对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<DictPageVO> getDictPage(DictTypePageQuery queryParams);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典表单详情
|
||||||
|
*
|
||||||
|
* @param id 字典ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
DictForm getDictForm(Long id);
|
DictForm getDictForm(Long id);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典数据项
|
* 新增字典
|
||||||
*
|
*
|
||||||
* @param dictForm 字典数据项表单
|
* @param dictForm 字典表单
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean saveDict(DictForm dictForm);
|
boolean saveDict(DictForm dictForm);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改字典数据项
|
* 修改字典
|
||||||
*
|
*
|
||||||
* @param id 字典数据项ID
|
* @param id
|
||||||
* @param dictForm 字典数据项表单
|
* @param dictForm 字典表单
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean updateDict(Long id, DictForm dictForm);
|
boolean updateDict(Long id, DictForm dictForm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除字典数据项
|
* 删除字典
|
||||||
*
|
*
|
||||||
* @param idsStr 字典数据项ID,多个以英文逗号(,)分割
|
* @param idsStr 字典ID,多个以英文逗号(,)分割
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean deleteDict(String idsStr);
|
void deleteDictByIds(String idsStr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取字典下拉列表
|
* 获取字典的数据项
|
||||||
*
|
*
|
||||||
* @param typeCode
|
* @param typeCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Option> listDictOptions(String typeCode);
|
List<Option> listDictItemsByCode(String typeCode);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,73 +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.common.model.Option;
|
|
||||||
import com.youlai.system.model.entity.SysDictType;
|
|
||||||
import com.youlai.system.model.form.DictTypeForm;
|
|
||||||
import com.youlai.system.model.query.DictTypePageQuery;
|
|
||||||
import com.youlai.system.model.vo.DictTypePageVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据字典类型业务接口
|
|
||||||
*
|
|
||||||
* @author haoxr
|
|
||||||
* @since 2022/10/12
|
|
||||||
*/
|
|
||||||
public interface SysDictTypeService extends IService<SysDictType> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典类型分页列表
|
|
||||||
*
|
|
||||||
* @param queryParams 分页查询对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Page<DictTypePageVO> getDictTypePage(DictTypePageQuery queryParams);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字典类型表单详情
|
|
||||||
*
|
|
||||||
* @param id 字典类型ID
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
DictTypeForm getDictTypeForm(Long id);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增字典类型
|
|
||||||
*
|
|
||||||
* @param dictTypeForm 字典类型表单
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean saveDictType(DictTypeForm dictTypeForm);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改字典类型
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param dictTypeForm 字典类型表单
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean updateDictType(Long id, DictTypeForm dictTypeForm);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除字典类型
|
|
||||||
*
|
|
||||||
* @param idsStr 字典类型ID,多个以英文逗号(,)分割
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean deleteDictTypes(String idsStr);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字典类型的数据项
|
|
||||||
*
|
|
||||||
* @param typeCode
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Option> listDictItemsByTypeCode(String typeCode);
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ import com.youlai.system.model.vo.MenuVO;
|
|||||||
import com.youlai.system.model.vo.RouteVO;
|
import com.youlai.system.model.vo.RouteVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单业务接口
|
* 菜单业务接口
|
||||||
@@ -21,31 +20,24 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单表格列表
|
* 获取菜单表格列表
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
List<MenuVO> listMenus(MenuQuery queryParams);
|
List<MenuVO> listMenus(MenuQuery queryParams);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单下拉列表
|
* 获取菜单下拉列表
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
List<Option> listMenuOptions();
|
List<Option> listMenuOptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增菜单
|
* 新增菜单
|
||||||
*
|
*
|
||||||
* @param menu
|
* @param menuForm 菜单表单对象
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
boolean saveMenu(MenuForm menu);
|
boolean saveMenu(MenuForm menuForm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取路由列表
|
* 获取路由列表
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
List<RouteVO> listRoutes();
|
List<RouteVO> listRoutes();
|
||||||
|
|
||||||
@@ -53,32 +45,21 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||||||
* 修改菜单显示状态
|
* 修改菜单显示状态
|
||||||
*
|
*
|
||||||
* @param menuId 菜单ID
|
* @param menuId 菜单ID
|
||||||
* @param visible 是否显示(1->显示;2->隐藏)
|
* @param visible 是否显示(1-显示 2-隐藏)
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
boolean updateMenuVisible(Long menuId, Integer visible);
|
boolean updateMenuVisible(Long menuId, Integer visible);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色权限集合
|
|
||||||
*
|
|
||||||
* @param roles
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Set<String> listRolePerms(Set<String> roles);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单表单数据
|
* 获取菜单表单数据
|
||||||
*
|
*
|
||||||
* @param id 菜单ID
|
* @param id 菜单ID
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
MenuForm getMenuForm(Long id);
|
MenuForm getMenuForm(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单
|
* 删除菜单
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id 菜单ID
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
boolean deleteMenu(Long id);
|
boolean deleteMenu(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.youlai.system.model.entity.SysRoleMenu;
|
import com.youlai.system.model.entity.SysRoleMenu;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色菜单业务接口
|
* 角色菜单业务接口
|
||||||
@@ -43,4 +44,11 @@ public interface SysRoleMenuService extends IService<SysRoleMenu> {
|
|||||||
*/
|
*/
|
||||||
void refreshRolePermsCache(String oldRoleCode, String newRoleCode);
|
void refreshRolePermsCache(String oldRoleCode, String newRoleCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色权限集合
|
||||||
|
*
|
||||||
|
* @param roles 角色编码集合
|
||||||
|
* @return 权限集合
|
||||||
|
*/
|
||||||
|
Set<String> getRolePermsByRoleCodes(Set<String> roles);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.youlai.system.model.entity.SysUser;
|
|||||||
import com.youlai.system.model.form.UserForm;
|
import com.youlai.system.model.form.UserForm;
|
||||||
import com.youlai.system.model.dto.UserAuthInfo;
|
import com.youlai.system.model.dto.UserAuthInfo;
|
||||||
import com.youlai.system.model.query.UserPageQuery;
|
import com.youlai.system.model.query.UserPageQuery;
|
||||||
import com.youlai.system.model.vo.UserExportVO;
|
import com.youlai.system.model.dto.UserExportDTO;
|
||||||
import com.youlai.system.model.vo.UserInfoVO;
|
import com.youlai.system.model.vo.UserInfoVO;
|
||||||
import com.youlai.system.model.vo.UserPageVO;
|
import com.youlai.system.model.vo.UserPageVO;
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public interface SysUserService extends IService<SysUser> {
|
|||||||
* @param queryParams
|
* @param queryParams
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<UserExportVO> listExportUsers(UserPageQuery queryParams);
|
List<UserExportDTO> listExportUsers(UserPageQuery queryParams);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门业务实现类
|
* 部门 业务实现类
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author Ray
|
||||||
* @since 2021-08-22
|
* @since 2021/08/22
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -40,7 +40,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
* 获取部门列表
|
* 获取部门列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DeptVO> listDepartments(DeptQuery queryParams) {
|
public List<DeptVO> getDeptList(DeptQuery queryParams) {
|
||||||
// 查询参数
|
// 查询参数
|
||||||
String keywords = queryParams.getKeywords();
|
String keywords = queryParams.getKeywords();
|
||||||
Integer status = queryParams.getStatus();
|
Integer status = queryParams.getStatus();
|
||||||
@@ -85,11 +85,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
return deptList.stream()
|
return 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.convertToVo(dept);
|
||||||
List<DeptVO> children = recurDeptList(dept.getId(), deptList);
|
List<DeptVO> children = recurDeptList(dept.getId(), deptList);
|
||||||
deptVO.setChildren(children);
|
deptVO.setChildren(children);
|
||||||
return deptVO;
|
return deptVO;
|
||||||
}).collect(Collectors.toList());
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,14 +134,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
@Override
|
@Override
|
||||||
public Long saveDept(DeptForm formData) {
|
public Long saveDept(DeptForm formData) {
|
||||||
// 校验部门名称是否存在
|
// 校验部门名称是否存在
|
||||||
String name = formData.getName();
|
String code = formData.getCode();
|
||||||
long count = this.count(new LambdaQueryWrapper<SysDept>()
|
long count = this.count(new LambdaQueryWrapper<SysDept>()
|
||||||
.eq(SysDept::getName, name)
|
.eq(SysDept::getCode, code)
|
||||||
);
|
);
|
||||||
Assert.isTrue(count == 0, "部门名称已存在");
|
Assert.isTrue(count == 0, "部门编号已存在");
|
||||||
|
|
||||||
// form->entity
|
// form->entity
|
||||||
SysDept entity = deptConverter.form2Entity(formData);
|
SysDept entity = deptConverter.convertToEntity(formData);
|
||||||
|
|
||||||
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
||||||
String treePath = generateDeptTreePath(formData.getParentId());
|
String treePath = generateDeptTreePath(formData.getParentId());
|
||||||
@@ -154,6 +154,20 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
return entity.getId();
|
return entity.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门表单
|
||||||
|
*
|
||||||
|
* @param deptId 部门ID
|
||||||
|
* @return 部门表单对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DeptForm getDeptForm(Long deptId) {
|
||||||
|
SysDept entity = this.getById(deptId);
|
||||||
|
return deptConverter.convertToForm(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新部门
|
* 更新部门
|
||||||
*
|
*
|
||||||
@@ -163,16 +177,17 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long updateDept(Long deptId, DeptForm formData) {
|
public Long updateDept(Long deptId, DeptForm formData) {
|
||||||
// 校验部门名称是否存在
|
// 校验部门名称/部门编号是否存在
|
||||||
String name = formData.getName();
|
String code = formData.getCode();
|
||||||
long count = this.count(new LambdaQueryWrapper<SysDept>()
|
long count = this.count(new LambdaQueryWrapper<SysDept>()
|
||||||
.eq(SysDept::getName, name)
|
|
||||||
.ne(SysDept::getId, deptId)
|
.ne(SysDept::getId, deptId)
|
||||||
|
.eq(SysDept::getCode, code)
|
||||||
);
|
);
|
||||||
Assert.isTrue(count == 0, "部门名称已存在");
|
Assert.isTrue(count == 0, "部门编号已存在");
|
||||||
|
|
||||||
|
|
||||||
// form->entity
|
// form->entity
|
||||||
SysDept entity = deptConverter.form2Entity(formData);
|
SysDept entity = deptConverter.convertToEntity(formData);
|
||||||
entity.setId(deptId);
|
entity.setId(deptId);
|
||||||
|
|
||||||
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
// 生成部门路径(tree_path),格式:父节点tree_path + , + 父节点ID,用于删除部门时级联删除子部门
|
||||||
@@ -194,7 +209,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
* @return 部门表格层级列表
|
* @return 部门表格层级列表
|
||||||
*/
|
*/
|
||||||
public static List<Option> recurDeptTreeOptions(long parentId, List<SysDept> deptList) {
|
public static List<Option> recurDeptTreeOptions(long parentId, List<SysDept> deptList) {
|
||||||
List<Option> list = CollectionUtil.emptyIfNull(deptList).stream()
|
return CollectionUtil.emptyIfNull(deptList).stream()
|
||||||
.filter(dept -> dept.getParentId().equals(parentId))
|
.filter(dept -> dept.getParentId().equals(parentId))
|
||||||
.map(dept -> {
|
.map(dept -> {
|
||||||
Option option = new Option(dept.getId(), dept.getName());
|
Option option = new Option(dept.getId(), dept.getName());
|
||||||
@@ -205,7 +220,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
return option;
|
return option;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -230,28 +244,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取部门详情
|
|
||||||
*
|
|
||||||
* @param deptId 部门ID
|
|
||||||
* @return 部门表单对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public DeptForm getDeptForm(Long deptId) {
|
|
||||||
|
|
||||||
SysDept entity = this.getOne(new LambdaQueryWrapper<SysDept>()
|
|
||||||
.eq(SysDept::getId, deptId)
|
|
||||||
.select(
|
|
||||||
SysDept::getId,
|
|
||||||
SysDept::getName,
|
|
||||||
SysDept::getParentId,
|
|
||||||
SysDept::getStatus,
|
|
||||||
SysDept::getSort
|
|
||||||
));
|
|
||||||
|
|
||||||
return deptConverter.entity2Form(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门路径生成
|
* 部门路径生成
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.youlai.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.youlai.system.mapper.SysDictItemMapper;
|
||||||
|
import com.youlai.system.model.entity.SysDictItem;
|
||||||
|
import com.youlai.system.service.SysDictItemService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据字典 服务实现类
|
||||||
|
*
|
||||||
|
* @author haoxr
|
||||||
|
* @since 2022/10/12
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典ID删除字典项
|
||||||
|
*
|
||||||
|
* @param dictId 字典ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeByDictId(Long dictId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,28 +1,32 @@
|
|||||||
package com.youlai.system.service.impl;
|
package com.youlai.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
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.converter.DictConverter;
|
import com.youlai.system.converter.DictConverter;
|
||||||
import com.youlai.system.mapper.SysDictMapper;
|
import com.youlai.system.converter.DictItemConverter;
|
||||||
import com.youlai.system.model.entity.SysDict;
|
import com.youlai.system.model.entity.SysDict;
|
||||||
import com.youlai.system.model.form.DictForm;
|
import com.youlai.system.model.entity.SysDictItem;
|
||||||
import com.youlai.system.model.query.DictPageQuery;
|
|
||||||
import com.youlai.system.model.vo.DictPageVO;
|
|
||||||
import com.youlai.system.common.model.Option;
|
import com.youlai.system.common.model.Option;
|
||||||
|
import com.youlai.system.mapper.SysDictMapper;
|
||||||
|
import com.youlai.system.model.form.DictForm;
|
||||||
|
import com.youlai.system.model.query.DictTypePageQuery;
|
||||||
|
import com.youlai.system.model.vo.DictPageVO;
|
||||||
|
import com.youlai.system.service.SysDictItemService;
|
||||||
import com.youlai.system.service.SysDictService;
|
import com.youlai.system.service.SysDictService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据字典项业务实现类
|
* 数据字典业务实现类
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author haoxr
|
||||||
* @since 2022/10/12
|
* @since 2022/10/12
|
||||||
@@ -31,133 +35,193 @@ import java.util.stream.Collectors;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {
|
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {
|
||||||
|
|
||||||
|
private final SysDictItemService dictItemService;
|
||||||
private final DictConverter dictConverter;
|
private final DictConverter dictConverter;
|
||||||
|
private final DictItemConverter dictItemConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典数据项分页列表
|
* 字典分页列表
|
||||||
*
|
*
|
||||||
* @param queryParams
|
* @param queryParams 分页查询对象
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<DictPageVO> getDictPage(DictPageQuery queryParams) {
|
public Page<DictPageVO> getDictPage(DictTypePageQuery queryParams) {
|
||||||
// 查询参数
|
// 查询参数
|
||||||
int pageNum = queryParams.getPageNum();
|
int pageNum = queryParams.getPageNum();
|
||||||
int pageSize = queryParams.getPageSize();
|
int pageSize = queryParams.getPageSize();
|
||||||
String keywords = queryParams.getKeywords();
|
|
||||||
String typeCode = queryParams.getTypeCode();
|
|
||||||
|
|
||||||
// 查询数据
|
// 查询数据
|
||||||
Page<SysDict> dictItemPage = this.page(
|
return this.baseMapper.getDictPage(new Page<>(pageNum, pageSize), queryParams);
|
||||||
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
|
* @param dictForm 字典表单数据
|
||||||
* @return
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveDict(DictForm dictForm) {
|
||||||
|
// 保存字典
|
||||||
|
SysDict entity = dictConverter.convertToEntity(dictForm);
|
||||||
|
|
||||||
|
// 校验 code 是否唯一
|
||||||
|
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
||||||
|
.eq(SysDict::getCode, entity.getCode())
|
||||||
|
);
|
||||||
|
Assert.isTrue(count == 0, "字典编码已存在");
|
||||||
|
|
||||||
|
boolean result = this.save(entity);
|
||||||
|
// 保存字典项
|
||||||
|
if (result) {
|
||||||
|
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
|
||||||
|
List<SysDictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
|
||||||
|
dictItems.forEach(dictItem -> dictItem.setDictId(entity.getId()));
|
||||||
|
dictItemService.saveBatch(dictItems);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典表单详情
|
||||||
|
*
|
||||||
|
* @param id 字典ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DictForm getDictForm(Long id) {
|
public DictForm getDictForm(Long id) {
|
||||||
// 获取entity
|
// 获取字典
|
||||||
SysDict entity = this.getOne(new LambdaQueryWrapper<SysDict>()
|
SysDict entity = this.getById(id);
|
||||||
.eq(SysDict::getId, id)
|
Assert.isTrue(entity != null, "字典不存在");
|
||||||
.select(
|
DictForm dictForm = dictConverter.convertToForm(entity);
|
||||||
SysDict::getId,
|
|
||||||
SysDict::getTypeCode,
|
|
||||||
SysDict::getName,
|
|
||||||
SysDict::getValue,
|
|
||||||
SysDict::getStatus,
|
|
||||||
SysDict::getSort,
|
|
||||||
SysDict::getRemark
|
|
||||||
));
|
|
||||||
Assert.isTrue(entity != null, "字典数据项不存在");
|
|
||||||
|
|
||||||
// 实体转换
|
// 获取字典项集合
|
||||||
DictForm dictForm = dictConverter.entity2Form(entity);
|
List<SysDictItem> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
|
||||||
|
.eq(SysDictItem::getDictId, id)
|
||||||
|
);
|
||||||
|
// 转换数据项
|
||||||
|
List<DictForm.DictItem> dictItemList = dictItemConverter.convertToDictFormDictItem(dictItems);
|
||||||
|
dictForm.setDictItems(dictItemList);
|
||||||
return dictForm;
|
return dictForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典数据项
|
* 修改字典
|
||||||
*
|
*
|
||||||
* @param dictForm 字典数据项表单
|
* @param id 字典ID
|
||||||
* @return
|
* @param dictForm 字典表单
|
||||||
*/
|
|
||||||
@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
|
@Override
|
||||||
public boolean updateDict(Long id, DictForm dictForm) {
|
public boolean updateDict(Long id, DictForm dictForm) {
|
||||||
SysDict entity = dictConverter.form2Entity(dictForm);
|
// 更新字典
|
||||||
|
SysDict entity = dictConverter.convertToEntity(dictForm);
|
||||||
|
|
||||||
|
// 校验 code 是否唯一
|
||||||
|
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
||||||
|
.eq(SysDict::getCode, entity.getCode())
|
||||||
|
.ne(SysDict::getId, id)
|
||||||
|
);
|
||||||
|
Assert.isTrue(count == 0, "字典编码已存在");
|
||||||
|
|
||||||
boolean result = this.updateById(entity);
|
boolean result = this.updateById(entity);
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (result) {
|
||||||
* 删除字典数据项
|
// 更新字典项
|
||||||
*
|
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
|
||||||
* @param idsStr 字典数据项ID,多个以英文逗号(,)分割
|
List<SysDictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
|
||||||
* @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);
|
List<SysDictItem> currentDictItemEntities = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
|
||||||
return result;
|
.eq(SysDictItem::getDictId, id)
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字典下拉列表
|
|
||||||
*
|
|
||||||
* @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)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// 转换下拉数据
|
// 获取当前数据库中存在的字典项ID集合
|
||||||
List<Option> options = CollectionUtil.emptyIfNull(dictList)
|
Set<Long> currentDictItemIds = currentDictItemEntities.stream()
|
||||||
.stream()
|
.map(SysDictItem::getId)
|
||||||
.map(dictItem -> new Option(dictItem.getValue(), dictItem.getName()))
|
.collect(Collectors.toSet());
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
// 获取新提交的字典项ID集合
|
||||||
|
Set<Long> newAttrIds = dictItems.stream()
|
||||||
|
.map(SysDictItem::getId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 需要删除的字典项ID集合(存在于数据库但不在新提交的字典项中)
|
||||||
|
Set<Long> idsToDelete = new HashSet<>(currentDictItemIds);
|
||||||
|
idsToDelete.removeAll(newAttrIds);
|
||||||
|
|
||||||
|
// 删除不在新提交字典项中的旧字典项
|
||||||
|
if (!idsToDelete.isEmpty()) {
|
||||||
|
dictItemService.removeByIds(idsToDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新或新增字典项
|
||||||
|
for (SysDictItem dictItem : dictItems) {
|
||||||
|
if (dictItem.getId() != null && currentDictItemIds.contains(dictItem.getId())) {
|
||||||
|
// 更新现有字典项
|
||||||
|
dictItemService.updateById(dictItem);
|
||||||
|
} else {
|
||||||
|
// 新增字典项
|
||||||
|
dictItem.setDictId(id);
|
||||||
|
dictItemService.save(dictItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典
|
||||||
|
*
|
||||||
|
* @param ids 字典ID,多个以英文逗号(,)分割
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deleteDictByIds(String ids) {
|
||||||
|
|
||||||
|
Assert.isTrue(StrUtil.isNotBlank(ids), "请选择需要删除的字典");
|
||||||
|
|
||||||
|
List<String> idList = Arrays.stream(ids.split(","))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
for (String id : idList) {
|
||||||
|
boolean result = this.removeById(id);
|
||||||
|
if (result) {
|
||||||
|
// 删除字典下的字典项
|
||||||
|
dictItemService.removeByDictId(Convert.toLong(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典的数据项
|
||||||
|
*
|
||||||
|
* @param code 字典编码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Option> listDictItemsByCode(String code) {
|
||||||
|
// 根据字典编码获取字典ID
|
||||||
|
SysDict dict = this.getOne(new LambdaQueryWrapper<SysDict>()
|
||||||
|
.eq(SysDict::getCode, code)
|
||||||
|
.select(SysDict::getId)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
// 如果字典不存在,则返回空集合
|
||||||
|
if (dict == null) {
|
||||||
|
return CollectionUtil.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取字典项
|
||||||
|
List<SysDictItem> dictItems = dictItemService.list(
|
||||||
|
new LambdaQueryWrapper<SysDictItem>()
|
||||||
|
.eq(SysDictItem::getDictId, dict.getId())
|
||||||
|
);
|
||||||
|
|
||||||
|
// 转换为 Option
|
||||||
|
List<Option> options = dictItemConverter.convertToOption(dictItems);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,206 +0,0 @@
|
|||||||
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.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.youlai.system.model.entity.SysDict;
|
|
||||||
import com.youlai.system.common.model.Option;
|
|
||||||
import com.youlai.system.converter.DictTypeConverter;
|
|
||||||
import com.youlai.system.mapper.SysDictTypeMapper;
|
|
||||||
import com.youlai.system.model.entity.SysDictType;
|
|
||||||
import com.youlai.system.model.form.DictTypeForm;
|
|
||||||
import com.youlai.system.model.query.DictTypePageQuery;
|
|
||||||
import com.youlai.system.model.vo.DictTypePageVO;
|
|
||||||
import com.youlai.system.service.SysDictService;
|
|
||||||
import com.youlai.system.service.SysDictTypeService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据字典类型业务实现类
|
|
||||||
*
|
|
||||||
* @author haoxr
|
|
||||||
* @since 2022/10/12
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {
|
|
||||||
|
|
||||||
|
|
||||||
private final SysDictService dictItemService;
|
|
||||||
private final DictTypeConverter dictTypeConverter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典分页列表
|
|
||||||
*
|
|
||||||
* @param queryParams 分页查询对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Page<DictTypePageVO> getDictTypePage(DictTypePageQuery queryParams) {
|
|
||||||
// 查询参数
|
|
||||||
int pageNum = queryParams.getPageNum();
|
|
||||||
int pageSize = queryParams.getPageSize();
|
|
||||||
String keywords = queryParams.getKeywords();
|
|
||||||
|
|
||||||
// 查询数据
|
|
||||||
Page<SysDictType> dictTypePage = this.page(
|
|
||||||
new Page<>(pageNum, pageSize),
|
|
||||||
new LambdaQueryWrapper<SysDictType>()
|
|
||||||
.like(StrUtil.isNotBlank(keywords), SysDictType::getName, keywords)
|
|
||||||
.or()
|
|
||||||
.like(StrUtil.isNotBlank(keywords), SysDictType::getCode, keywords)
|
|
||||||
.select(
|
|
||||||
SysDictType::getId,
|
|
||||||
SysDictType::getName,
|
|
||||||
SysDictType::getCode,
|
|
||||||
SysDictType::getStatus,
|
|
||||||
SysDictType::getRemark
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 实体转换
|
|
||||||
Page<DictTypePageVO> pageResult = dictTypeConverter.entity2Page(dictTypePage);
|
|
||||||
return pageResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字典类型表单详情
|
|
||||||
*
|
|
||||||
* @param id 字典类型ID
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public DictTypeForm getDictTypeForm(Long id) {
|
|
||||||
// 获取entity
|
|
||||||
SysDictType entity = this.getOne(new LambdaQueryWrapper<SysDictType>()
|
|
||||||
.eq(SysDictType::getId, id)
|
|
||||||
.select(
|
|
||||||
SysDictType::getId,
|
|
||||||
SysDictType::getName,
|
|
||||||
SysDictType::getCode,
|
|
||||||
SysDictType::getStatus,
|
|
||||||
SysDictType::getRemark
|
|
||||||
));
|
|
||||||
Assert.isTrue(entity != null, "字典类型不存在");
|
|
||||||
|
|
||||||
// 实体转换
|
|
||||||
DictTypeForm dictTypeForm = dictTypeConverter.entity2Form(entity);
|
|
||||||
return dictTypeForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增字典类型
|
|
||||||
*
|
|
||||||
* @param dictTypeForm
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean saveDictType(DictTypeForm dictTypeForm) {
|
|
||||||
// 实体对象转换 form->entity
|
|
||||||
SysDictType entity = dictTypeConverter.form2Entity(dictTypeForm);
|
|
||||||
// 持久化
|
|
||||||
boolean result = this.save(entity);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改字典类型
|
|
||||||
*
|
|
||||||
* @param id 字典类型ID
|
|
||||||
* @param dictTypeForm 字典类型表单
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean updateDictType(Long id, DictTypeForm dictTypeForm) {
|
|
||||||
// 获取字典类型
|
|
||||||
SysDictType sysDictType = this.getById(id);
|
|
||||||
Assert.isTrue(sysDictType != null, "字典类型不存在");
|
|
||||||
|
|
||||||
SysDictType entity = dictTypeConverter.form2Entity(dictTypeForm);
|
|
||||||
boolean result = this.updateById(entity);
|
|
||||||
if (result) {
|
|
||||||
// 字典类型code变化,同步修改字典项的类型code
|
|
||||||
String oldCode = sysDictType.getCode();
|
|
||||||
String newCode = dictTypeForm.getCode();
|
|
||||||
if (!StrUtil.equals(oldCode, newCode)) {
|
|
||||||
dictItemService.update(new LambdaUpdateWrapper<SysDict>()
|
|
||||||
.eq(SysDict::getTypeCode, oldCode)
|
|
||||||
.set(SysDict::getTypeCode, newCode)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除字典类型
|
|
||||||
*
|
|
||||||
* @param idsStr 字典类型ID,多个以英文逗号(,)分割
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public boolean deleteDictTypes(String idsStr) {
|
|
||||||
|
|
||||||
Assert.isTrue(StrUtil.isNotBlank(idsStr), "删除数据为空");
|
|
||||||
|
|
||||||
List ids = Arrays.asList(idsStr.split(","))
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
// 删除字典数据项
|
|
||||||
List<String> dictTypeCodes = this.list(new LambdaQueryWrapper<SysDictType>()
|
|
||||||
.in(SysDictType::getId, ids)
|
|
||||||
.select(SysDictType::getCode))
|
|
||||||
.stream()
|
|
||||||
.map(dictType -> dictType.getCode())
|
|
||||||
.collect(Collectors.toList()
|
|
||||||
);
|
|
||||||
if (CollectionUtil.isNotEmpty(dictTypeCodes)) {
|
|
||||||
dictItemService.remove(new LambdaQueryWrapper<SysDict>()
|
|
||||||
.in(SysDict::getTypeCode, dictTypeCodes));
|
|
||||||
}
|
|
||||||
// 删除字典类型
|
|
||||||
boolean result = this.removeByIds(ids);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字典类型的数据项
|
|
||||||
*
|
|
||||||
* @param typeCode
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Option> listDictItemsByTypeCode(String typeCode) {
|
|
||||||
// 数据字典项
|
|
||||||
List<SysDict> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDict>()
|
|
||||||
.eq(SysDict::getTypeCode, typeCode)
|
|
||||||
.select(SysDict::getValue, SysDict::getName)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 转换下拉数据
|
|
||||||
List<Option> options = CollectionUtil.emptyIfNull(dictItems)
|
|
||||||
.stream()
|
|
||||||
.map(dictItem -> new Option(dictItem.getValue(), dictItem.getName()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
.stream()
|
.stream()
|
||||||
.filter(menu -> menu.getParentId().equals(parentId))
|
.filter(menu -> menu.getParentId().equals(parentId))
|
||||||
.map(entity -> {
|
.map(entity -> {
|
||||||
MenuVO menuVO = menuConverter.entity2Vo(entity);
|
MenuVO menuVO = menuConverter.convertToVo(entity);
|
||||||
List<MenuVO> children = buildMenuTree(entity.getId(), menuList);
|
List<MenuVO> children = buildMenuTree(entity.getId(), menuList);
|
||||||
menuVO.setChildren(children);
|
menuVO.setChildren(children);
|
||||||
return menuVO;
|
return menuVO;
|
||||||
@@ -144,8 +144,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
@Cacheable(cacheNames = "menu", key = "'routes'")
|
@Cacheable(cacheNames = "menu", key = "'routes'")
|
||||||
public List<RouteVO> listRoutes() {
|
public List<RouteVO> listRoutes() {
|
||||||
List<RouteBO> menuList = this.baseMapper.listRoutes();
|
List<RouteBO> menuList = this.baseMapper.listRoutes();
|
||||||
List<RouteVO> routes = buildRoutes(SystemConstants.ROOT_NODE_ID, menuList);
|
return buildRoutes(SystemConstants.ROOT_NODE_ID, menuList);
|
||||||
return routes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,9 +176,17 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
*/
|
*/
|
||||||
private RouteVO toRouteVo(RouteBO routeBO) {
|
private RouteVO toRouteVo(RouteBO routeBO) {
|
||||||
RouteVO routeVO = new RouteVO();
|
RouteVO routeVO = new RouteVO();
|
||||||
String routeName = StringUtils.capitalize(StrUtil.toCamelCase(routeBO.getPath(), '-')); // 路由 name 需要驼峰,首字母大写
|
// 获取路由名称
|
||||||
routeVO.setName(routeName); // 根据name路由跳转 this.$router.push({name:xxx})
|
String routeName = routeBO.getRouteName();
|
||||||
routeVO.setPath(routeBO.getPath()); // 根据path路由跳转 this.$router.push({path:xxx})
|
if (StrUtil.isBlank(routeName)) {
|
||||||
|
// 路由 name 需要驼峰,首字母大写
|
||||||
|
routeName = StringUtils.capitalize(StrUtil.toCamelCase(routeBO.getRoutePath(), '-'));
|
||||||
|
}
|
||||||
|
// 根据name路由跳转 this.$router.push({name:xxx})
|
||||||
|
routeVO.setName(routeName);
|
||||||
|
|
||||||
|
// 根据path路由跳转 this.$router.push({path:xxx})
|
||||||
|
routeVO.setPath(routeBO.getRoutePath());
|
||||||
routeVO.setRedirect(routeBO.getRedirect());
|
routeVO.setRedirect(routeBO.getRedirect());
|
||||||
routeVO.setComponent(routeBO.getComponent());
|
routeVO.setComponent(routeBO.getComponent());
|
||||||
|
|
||||||
@@ -200,7 +207,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
if (StrUtil.isNotBlank(paramsJson)) {
|
if (StrUtil.isNotBlank(paramsJson)) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
Map<String, String> paramMap = objectMapper.readValue(paramsJson, new TypeReference<>() {});
|
Map<String, String> paramMap = objectMapper.readValue(paramsJson, new TypeReference<>() {
|
||||||
|
});
|
||||||
meta.setParams(paramMap);
|
meta.setParams(paramMap);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("解析参数失败", e);
|
throw new RuntimeException("解析参数失败", e);
|
||||||
@@ -220,9 +228,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
MenuTypeEnum menuType = menuForm.getType();
|
MenuTypeEnum menuType = menuForm.getType();
|
||||||
|
|
||||||
if (menuType == MenuTypeEnum.CATALOG) { // 如果是外链
|
if (menuType == MenuTypeEnum.CATALOG) { // 如果是外链
|
||||||
String path = menuForm.getPath();
|
String path = menuForm.getRoutePath();
|
||||||
if (menuForm.getParentId() == 0 && !path.startsWith("/")) {
|
if (menuForm.getParentId() == 0 && !path.startsWith("/")) {
|
||||||
menuForm.setPath("/" + path); // 一级目录需以 / 开头
|
menuForm.setRoutePath("/" + path); // 一级目录需以 / 开头
|
||||||
}
|
}
|
||||||
menuForm.setComponent("Layout");
|
menuForm.setComponent("Layout");
|
||||||
} else if (menuType == MenuTypeEnum.EXTLINK) { // 如果是目录
|
} else if (menuType == MenuTypeEnum.EXTLINK) { // 如果是目录
|
||||||
@@ -239,7 +247,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
if (CollectionUtil.isNotEmpty(params)) {
|
if (CollectionUtil.isNotEmpty(params)) {
|
||||||
entity.setParams(JSONUtil.toJsonStr(params.stream()
|
entity.setParams(JSONUtil.toJsonStr(params.stream()
|
||||||
.collect(Collectors.toMap(KeyValue::getKey, KeyValue::getValue))));
|
.collect(Collectors.toMap(KeyValue::getKey, KeyValue::getValue))));
|
||||||
}else{
|
} else {
|
||||||
entity.setParams(null);
|
entity.setParams(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,17 +293,6 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色权限(Code)集合
|
|
||||||
*
|
|
||||||
* @param roles 角色Code集合
|
|
||||||
* @return 权限集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Set<String> listRolePerms(Set<String> roles) {
|
|
||||||
return this.baseMapper.listRolePerms(roles);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单表单数据
|
* 获取菜单表单数据
|
||||||
*
|
*
|
||||||
@@ -313,7 +310,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
// 解析 JSON 字符串为 Map<String, String>
|
// 解析 JSON 字符串为 Map<String, String>
|
||||||
Map<String, String> paramMap = objectMapper.readValue(params, new TypeReference<>() {});
|
Map<String, String> paramMap = objectMapper.readValue(params, new TypeReference<>() {
|
||||||
|
});
|
||||||
|
|
||||||
// 转换为 List<KeyValue> 格式 [{key:"id", value:"1"}, {key:"name", value:"张三"}]
|
// 转换为 List<KeyValue> 格式 [{key:"id", value:"1"}, {key:"name", value:"张三"}]
|
||||||
List<KeyValue> transformedList = paramMap.entrySet().stream()
|
List<KeyValue> transformedList = paramMap.entrySet().stream()
|
||||||
@@ -353,5 +351,4 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.youlai.system.model.entity.SysRoleMenu;
|
|||||||
import com.youlai.system.service.SysRoleMenuService;
|
import com.youlai.system.service.SysRoleMenuService;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -19,11 +20,12 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* 角色菜单业务实现
|
* 角色菜单业务实现
|
||||||
*
|
*
|
||||||
* @author haoxr
|
* @author Ray
|
||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {
|
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {
|
||||||
|
|
||||||
private final RedisTemplate<String, Object> redisTemplate;
|
private final RedisTemplate<String, Object> redisTemplate;
|
||||||
@@ -33,6 +35,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
|
|||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initRolePermsCache() {
|
public void initRolePermsCache() {
|
||||||
|
log.info("初始化权限缓存... ");
|
||||||
refreshRolePermsCache();
|
refreshRolePermsCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +86,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
|
|||||||
redisTemplate.opsForHash().delete(SecurityConstants.ROLE_PERMS_PREFIX, oldRoleCode);
|
redisTemplate.opsForHash().delete(SecurityConstants.ROLE_PERMS_PREFIX, oldRoleCode);
|
||||||
|
|
||||||
// 添加新角色权限缓存
|
// 添加新角色权限缓存
|
||||||
List<RolePermsBO> list =this.baseMapper.getRolePermsList(newRoleCode);
|
List<RolePermsBO> list = this.baseMapper.getRolePermsList(newRoleCode);
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
RolePermsBO rolePerms = list.get(0);
|
RolePermsBO rolePerms = list.get(0);
|
||||||
if (rolePerms == null) {
|
if (rolePerms == null) {
|
||||||
@@ -95,6 +98,16 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色权限集合
|
||||||
|
*
|
||||||
|
* @param roles 角色编码集合
|
||||||
|
* @return 权限集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<String> getRolePermsByRoleCodes(Set<String> roles) {
|
||||||
|
return this.baseMapper.listRolePerms(roles);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色拥有的菜单ID集合
|
* 获取角色拥有的菜单ID集合
|
||||||
@@ -104,8 +117,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listMenuIdsByRoleId(Long roleId) {
|
public List<Long> listMenuIdsByRoleId(Long roleId) {
|
||||||
List<Long> menuIds = this.baseMapper.listMenuIdsByRoleId(roleId);
|
return this.baseMapper.listMenuIdsByRoleId(roleId);
|
||||||
return menuIds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 实体转换
|
// 实体转换
|
||||||
return roleConverter.entity2Page(rolePage);
|
return roleConverter.convertToPageVo(rolePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,7 +118,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
Assert.isTrue(count == 0, "角色名称或角色编码已存在,请修改后重试!");
|
Assert.isTrue(count == 0, "角色名称或角色编码已存在,请修改后重试!");
|
||||||
|
|
||||||
// 实体转换
|
// 实体转换
|
||||||
SysRole role = roleConverter.form2Entity(roleForm);
|
SysRole role = roleConverter.convertToEntity(roleForm);
|
||||||
|
|
||||||
boolean result = this.saveOrUpdate(role);
|
boolean result = this.saveOrUpdate(role);
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -143,7 +143,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
@Override
|
@Override
|
||||||
public RoleForm getRoleForm(Long roleId) {
|
public RoleForm getRoleForm(Long roleId) {
|
||||||
SysRole entity = this.getById(roleId);
|
SysRole entity = this.getById(roleId);
|
||||||
return roleConverter.entity2Form(entity);
|
return roleConverter.convertToForm(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import com.youlai.system.model.bo.UserBO;
|
|||||||
import com.youlai.system.model.entity.SysUser;
|
import com.youlai.system.model.entity.SysUser;
|
||||||
import com.youlai.system.model.form.UserForm;
|
import com.youlai.system.model.form.UserForm;
|
||||||
import com.youlai.system.model.query.UserPageQuery;
|
import com.youlai.system.model.query.UserPageQuery;
|
||||||
import com.youlai.system.model.vo.UserExportVO;
|
import com.youlai.system.model.dto.UserExportDTO;
|
||||||
import com.youlai.system.model.vo.UserInfoVO;
|
import com.youlai.system.model.vo.UserInfoVO;
|
||||||
import com.youlai.system.model.vo.UserPageVO;
|
import com.youlai.system.model.vo.UserPageVO;
|
||||||
import com.youlai.system.security.service.PermissionService;
|
import com.youlai.system.security.service.PermissionService;
|
||||||
@@ -49,7 +49,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
|
|
||||||
private final UserConverter userConverter;
|
private final UserConverter userConverter;
|
||||||
|
|
||||||
private final SysMenuService menuService;
|
private final SysRoleMenuService roleMenuService;
|
||||||
|
|
||||||
private final SysRoleService roleService;
|
private final SysRoleService roleService;
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
Assert.isTrue(count == 0, "用户名已存在");
|
Assert.isTrue(count == 0, "用户名已存在");
|
||||||
|
|
||||||
// 实体转换 form->entity
|
// 实体转换 form->entity
|
||||||
SysUser entity = userConverter.form2Entity(userForm);
|
SysUser entity = userConverter.convertToEntity(userForm);
|
||||||
|
|
||||||
// 设置默认加密密码
|
// 设置默认加密密码
|
||||||
String defaultEncryptPwd = passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD);
|
String defaultEncryptPwd = passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD);
|
||||||
@@ -141,7 +141,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
Assert.isTrue(count == 0, "用户名已存在");
|
Assert.isTrue(count == 0, "用户名已存在");
|
||||||
|
|
||||||
// form -> entity
|
// form -> entity
|
||||||
SysUser entity = userConverter.form2Entity(userForm);
|
SysUser entity = userConverter.convertToEntity(userForm);
|
||||||
|
|
||||||
// 修改用户
|
// 修改用户
|
||||||
boolean result = this.updateById(entity);
|
boolean result = this.updateById(entity);
|
||||||
@@ -197,7 +197,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
if (userAuthInfo != null) {
|
if (userAuthInfo != null) {
|
||||||
Set<String> roles = userAuthInfo.getRoles();
|
Set<String> roles = userAuthInfo.getRoles();
|
||||||
if (CollectionUtil.isNotEmpty(roles)) {
|
if (CollectionUtil.isNotEmpty(roles)) {
|
||||||
Set<String> perms = menuService.listRolePerms(roles);
|
Set<String> perms = roleMenuService.getRolePermsByRoleCodes(roles);
|
||||||
userAuthInfo.setPerms(perms);
|
userAuthInfo.setPerms(perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,10 +213,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
* 获取导出用户列表
|
* 获取导出用户列表
|
||||||
*
|
*
|
||||||
* @param queryParams 查询参数
|
* @param queryParams 查询参数
|
||||||
* @return {@link List<UserExportVO>} 导出用户列表
|
* @return {@link List< UserExportDTO >} 导出用户列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<UserExportVO> listExportUsers(UserPageQuery queryParams) {
|
public List<UserExportDTO> listExportUsers(UserPageQuery queryParams) {
|
||||||
return this.baseMapper.listExportUsers(queryParams);
|
return this.baseMapper.listExportUsers(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
24
src/main/resources/mapper/SysDictItemMapper.xml
Normal file
24
src/main/resources/mapper/SysDictItemMapper.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.youlai.system.mapper.SysDictItemMapper">
|
||||||
|
|
||||||
|
<!-- 根据字典编码获取字典列表 -->
|
||||||
|
<select id="listDictItemsByDictId" resultType="com.youlai.system.model.vo.DictPageVO$DictItem">
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
`name`,
|
||||||
|
value,
|
||||||
|
sort,
|
||||||
|
status
|
||||||
|
FROM
|
||||||
|
sys_dict_item
|
||||||
|
<where>
|
||||||
|
dict_id = #{dictId}
|
||||||
|
</where>
|
||||||
|
ORDER BY
|
||||||
|
sort ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -4,4 +4,32 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.youlai.system.mapper.SysDictMapper">
|
<mapper namespace="com.youlai.system.mapper.SysDictMapper">
|
||||||
|
|
||||||
|
<!-- 字典映射 -->
|
||||||
|
<resultMap id="DictMap" type="com.youlai.system.model.vo.DictPageVO">
|
||||||
|
<collection property="dictItems"
|
||||||
|
column="{dictId=id}"
|
||||||
|
select="com.youlai.system.mapper.SysDictItemMapper.listDictItemsByDictId">
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
<!-- 字典分页列表 -->
|
||||||
|
<select id="getDictPage" resultMap="DictMap">
|
||||||
|
SELECT
|
||||||
|
t1.id,
|
||||||
|
t1.name,
|
||||||
|
t1.code,
|
||||||
|
t1.status
|
||||||
|
FROM
|
||||||
|
sys_dict t1
|
||||||
|
<where>
|
||||||
|
t1.is_deleted = 0
|
||||||
|
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
||||||
|
AND (
|
||||||
|
t1.name LIKE CONCAT('%',#{queryParams.keywords},'%')
|
||||||
|
OR t1.code LIKE CONCAT('%',#{queryParams.keywords},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY
|
||||||
|
t1.create_time DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.youlai.system.mapper.SysDictTypeMapper">
|
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="com.youlai.system.model.entity.SysDictType">
|
|
||||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
|
||||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
|
||||||
<result property="code" column="code" jdbcType="VARCHAR"/>
|
|
||||||
<result property="status" column="status" jdbcType="TINYINT"/>
|
|
||||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
|
||||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
||||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
id,name,code,
|
|
||||||
status,remark,create_time,
|
|
||||||
update_time
|
|
||||||
</sql>
|
|
||||||
</mapper>
|
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
<result property="parentId" column="parent_id" jdbcType="BIGINT"/>
|
<result property="parentId" column="parent_id" jdbcType="BIGINT"/>
|
||||||
<result property="path" column="path" jdbcType="VARCHAR"/>
|
<result property="routeName" column="route_name" jdbcType="VARCHAR"/>
|
||||||
|
<result property="routePath" column="route_path" jdbcType="VARCHAR"/>
|
||||||
<result property="component" column="component" jdbcType="VARCHAR"/>
|
<result property="component" column="component" jdbcType="VARCHAR"/>
|
||||||
<result property="redirect" column="redirect" jdbcType="VARCHAR"/>
|
<result property="redirect" column="redirect" jdbcType="VARCHAR"/>
|
||||||
<result property="icon" column="icon" jdbcType="VARCHAR"/>
|
<result property="icon" column="icon" jdbcType="VARCHAR"/>
|
||||||
@@ -30,7 +31,8 @@
|
|||||||
t1.id,
|
t1.id,
|
||||||
t1.name,
|
t1.name,
|
||||||
t1.parent_id,
|
t1.parent_id,
|
||||||
t1.path,
|
t1.route_name,
|
||||||
|
t1.route_path,
|
||||||
t1.component,
|
t1.component,
|
||||||
t1.icon,
|
t1.icon,
|
||||||
t1.sort,
|
t1.sort,
|
||||||
@@ -47,30 +49,9 @@
|
|||||||
LEFT JOIN sys_role t3 ON t2.role_id = t3.id
|
LEFT JOIN sys_role t3 ON t2.role_id = t3.id
|
||||||
WHERE
|
WHERE
|
||||||
t1.type != '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
|
t1.type != '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
|
||||||
ORDER BY t1.sort asc
|
ORDER BY
|
||||||
|
t1.sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 获取角色拥有的权限集合 -->
|
|
||||||
<select id="listRolePerms" resultType="java.lang.String">
|
|
||||||
SELECT
|
|
||||||
DISTINCT t1.perm
|
|
||||||
FROM
|
|
||||||
sys_menu t1
|
|
||||||
INNER JOIN sys_role_menu t2 ON t1.id = t2.menu_id
|
|
||||||
INNER JOIN sys_role t3 ON t3.id = t2.role_id
|
|
||||||
WHERE
|
|
||||||
t1.type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
|
|
||||||
AND t1.perm IS NOT NULL
|
|
||||||
<choose>
|
|
||||||
<when test="roles!=null and roles.size()>0">
|
|
||||||
AND t3.CODE IN
|
|
||||||
<foreach collection="roles" item="role" separator="," open="(" close=")">
|
|
||||||
#{role}
|
|
||||||
</foreach>
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
AND t1.id = -1
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
rm.role_id = #{roleId}
|
rm.role_id = #{roleId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 权限和拥有权限的角色集合的Map -->
|
<!-- 权限和拥有权限的角色的映射 -->
|
||||||
<resultMap id="PremRolesMap" type="com.youlai.system.model.bo.RolePermsBO">
|
<resultMap id="PremRolesMap" type="com.youlai.system.model.bo.RolePermsBO">
|
||||||
<result property="roleCode" column="role_code"/>
|
<result property="roleCode" column="role_code"/>
|
||||||
<collection property="perms" ofType="string" javaType="java.util.Set">
|
<collection property="perms" ofType="string" javaType="java.util.Set">
|
||||||
@@ -26,11 +26,11 @@
|
|||||||
<!-- 获取权限和拥有权限的角色列表 -->
|
<!-- 获取权限和拥有权限的角色列表 -->
|
||||||
<select id="getRolePermsList" resultMap="PremRolesMap">
|
<select id="getRolePermsList" resultMap="PremRolesMap">
|
||||||
SELECT
|
SELECT
|
||||||
t2.`code` role_code,
|
t3.perm,
|
||||||
t3.perm
|
t2.`code` role_code
|
||||||
FROM
|
FROM
|
||||||
`sys_role_menu` t1
|
`sys_role_menu` t1
|
||||||
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.deleted = 0 AND t2.`status` = 1
|
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.is_deleted = 0 AND t2.`status` = 1
|
||||||
INNER JOIN sys_menu t3 ON t1.menu_id = t3.id
|
INNER JOIN sys_menu t3 ON t1.menu_id = t3.id
|
||||||
WHERE
|
WHERE
|
||||||
type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
|
type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
|
||||||
@@ -38,4 +38,21 @@
|
|||||||
AND t2.`code` = #{roleCode}
|
AND t2.`code` = #{roleCode}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取角色拥有的权限列表 -->
|
||||||
|
<select id="listRolePerms" resultType="java.lang.String">
|
||||||
|
SELECT
|
||||||
|
DISTINCT t2.perm
|
||||||
|
FROM
|
||||||
|
sys_role_menu t1
|
||||||
|
INNER JOIN sys_menu t2 ON t2.id = t1.menu_id
|
||||||
|
INNER JOIN sys_role t3 ON t3.id = t1.role_id
|
||||||
|
WHERE
|
||||||
|
t2.type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
|
||||||
|
AND t2.perm IS NOT NULL
|
||||||
|
AND t3.CODE IN
|
||||||
|
<foreach collection="roles" item="role" separator="," open="(" close=")">
|
||||||
|
#{role}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
LEFT JOIN sys_user_role sur ON u.id = sur.user_id
|
LEFT JOIN sys_user_role sur ON u.id = sur.user_id
|
||||||
LEFT JOIN sys_role r ON sur.role_id = r.id
|
LEFT JOIN sys_role r ON sur.role_id = r.id
|
||||||
<where>
|
<where>
|
||||||
u.deleted = 0 AND u.username != 'root'
|
u.is_deleted = 0 AND u.username != 'root'
|
||||||
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
||||||
AND (
|
AND (
|
||||||
u.username LIKE CONCAT('%',#{queryParams.keywords},'%')
|
u.username LIKE CONCAT('%',#{queryParams.keywords},'%')
|
||||||
@@ -112,11 +112,11 @@
|
|||||||
LEFT JOIN sys_user_role t2 ON t2.user_id = t1.id
|
LEFT JOIN sys_user_role t2 ON t2.user_id = t1.id
|
||||||
LEFT JOIN sys_role t3 ON t3.id = t2.role_id
|
LEFT JOIN sys_role t3 ON t3.id = t2.role_id
|
||||||
WHERE
|
WHERE
|
||||||
t1.username = #{username} AND t1.deleted=0
|
t1.username = #{username} AND t1.is_deleted=0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 获取用户导出列表 -->
|
<!-- 获取用户导出列表 -->
|
||||||
<select id="listExportUsers" resultType="com.youlai.system.model.vo.UserExportVO">
|
<select id="listExportUsers" resultType="com.youlai.system.model.dto.UserExportDTO">
|
||||||
SELECT
|
SELECT
|
||||||
u.username,
|
u.username,
|
||||||
u.nickname,
|
u.nickname,
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
sys_user u
|
sys_user u
|
||||||
LEFT JOIN sys_dept d ON u.dept_id = d.id
|
LEFT JOIN sys_dept d ON u.dept_id = d.id
|
||||||
<where>
|
<where>
|
||||||
u.deleted = 0 AND u.username != 'root'
|
u.is_deleted = 0 AND u.username != 'root'
|
||||||
<if test='keywords!=null and keywords.trim() neq ""'>
|
<if test='keywords!=null and keywords.trim() neq ""'>
|
||||||
AND (u.username LIKE CONCAT('%',#{keywords},'%')
|
AND (u.username LIKE CONCAT('%',#{keywords},'%')
|
||||||
OR u.nickname LIKE CONCAT('%',#{keywords},'%')
|
OR u.nickname LIKE CONCAT('%',#{keywords},'%')
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
sys_user_role t1
|
sys_user_role t1
|
||||||
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.deleted = 0
|
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.is_deleted = 0
|
||||||
INNER JOIN sys_user t3 ON t1.user_id = t3.id
|
INNER JOIN sys_user t3 ON t1.user_id = t3.id
|
||||||
AND t3.deleted = 0
|
AND t3.is_deleted = 0
|
||||||
WHERE
|
WHERE
|
||||||
t1.role_id = #{roleId}
|
t1.role_id = #{roleId}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ public interface ${entity}Converter{
|
|||||||
|
|
||||||
Page<${entity}PageVO> bo2PageVo(Page<${entity}BO> bo);
|
Page<${entity}PageVO> bo2PageVo(Page<${entity}BO> bo);
|
||||||
|
|
||||||
${entity}Form entity2Form(${entity} entity);
|
${entity}Form convertToForm(${entity} entity);
|
||||||
|
|
||||||
@InheritInverseConfiguration(name = "entity2Form")
|
@InheritInverseConfiguration(name = "convertToForm")
|
||||||
${entity} form2Entity(${entity}Form entity);
|
${entity} convertToEntity(${entity}Form entity);
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.m
|
|||||||
@Override
|
@Override
|
||||||
public ${entity}Form get${entity}FormData(Long id) {
|
public ${entity}Form get${entity}FormData(Long id) {
|
||||||
${entity} entity = this.getById(id);
|
${entity} entity = this.getById(id);
|
||||||
return ${firstCharLowerCaseEntity}Converter.entity2Form(entity);
|
return ${firstCharLowerCaseEntity}Converter.convertToForm(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +80,7 @@ public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.m
|
|||||||
@Override
|
@Override
|
||||||
public boolean save${entity}(${entity}Form formData) {
|
public boolean save${entity}(${entity}Form formData) {
|
||||||
// 实体转换 form->entity
|
// 实体转换 form->entity
|
||||||
${entity} entity = ${firstCharLowerCaseEntity}Converter.form2Entity(formData);
|
${entity} entity = ${firstCharLowerCaseEntity}Converter.convertToEntity(formData);
|
||||||
return this.save(entity);
|
return this.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.m
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean update${entity}(Long id,${entity}Form formData) {
|
public boolean update${entity}(Long id,${entity}Form formData) {
|
||||||
${entity} entity = ${firstCharLowerCaseEntity}Converter.form2Entity(formData);
|
${entity} entity = ${firstCharLowerCaseEntity}Converter.convertToEntity(formData);
|
||||||
return this.updateById(entity);
|
return this.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user