diff --git a/README.md b/README.md index e026347e..aab57f8b 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ | 依赖 | 版本 | | ---------------------- |----------------| -| Spring Boot | 3.1.0 | +| Spring Boot | 3.1.1 | | Spring Cloud | 2022.0.3 | | Spring Cloud Alibaba | 2022.0.0.0-RC2 | -| Spring Authorization Server | 1.1.0 | +| Spring Authorization Server | 1.1.1 | | Mybatis Plus | 3.5.3.1 | -| hutool | 5.8.18 | +| hutool | 5.8.20 | ### 模块说明 diff --git a/db/Dockerfile b/db/Dockerfile index ed8426c5..40194538 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -11,3 +11,5 @@ COPY ./pig.sql /docker-entrypoint-initdb.d COPY ./pig_codegen.sql /docker-entrypoint-initdb.d COPY ./pig_config.sql /docker-entrypoint-initdb.d + +COPY ./pig_job.sql /docker-entrypoint-initdb.d diff --git a/db/pig.sql b/db/pig.sql index 9850a86f..dbb77699 100644 --- a/db/pig.sql +++ b/db/pig.sql @@ -1,74 +1,48 @@ DROP DATABASE IF EXISTS `pig`; -CREATE DATABASE `pig` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +CREATE DATABASE `pig` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; SET NAMES utf8; SET FOREIGN_KEY_CHECKS = 0; USE `pig`; + -- ---------------------------- -- Table structure for sys_dept -- ---------------------------- -DROP TABLE IF EXISTS `sys_dept` ; +DROP TABLE IF EXISTS `sys_dept`; CREATE TABLE `sys_dept` ( - `dept_id` bigint NOT NULL, - `name` varchar(50) COLLATE utf8_general_ci DEFAULT NULL COMMENT '部门名称', - `sort_order` int NOT NULL DEFAULT '0' COMMENT '排序', - `del_flag` char(1) COLLATE utf8_general_ci DEFAULT '0' COMMENT '是否删除 -1:已删除 0:正常', - `parent_id` bigint DEFAULT NULL, - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `create_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建人', - `update_time` datetime DEFAULT NULL COMMENT '修改时间', - `update_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`dept_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='部门管理'; + `dept_id` bigint NOT NULL COMMENT '部门ID', + `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部门名称', + `sort_order` int NOT NULL DEFAULT '0' COMMENT '排序', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志', + `parent_id` bigint DEFAULT NULL COMMENT '父级部门ID', + PRIMARY KEY (`dept_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='部门管理'; -- ---------------------------- -- Records of sys_dept -- ---------------------------- BEGIN; -INSERT INTO `sys_dept` VALUES (1, '总经办', 0, '0', 0, '2020-03-13 13:13:16', ' ', '2020-03-13 13:14:31', ' '); -INSERT INTO `sys_dept` VALUES (2, '行政中心', 0, '0', 1, '2020-03-13 13:13:30', ' ', '2021-12-31 06:59:56', ' '); -INSERT INTO `sys_dept` VALUES (3, '技术中心', 0, '0', 1, '2020-03-13 13:14:55', ' ', '2021-12-31 06:59:56', ' '); -INSERT INTO `sys_dept` VALUES (4, '运营中心', 0, '0', 1, '2020-03-13 13:15:15', ' ', '2021-12-31 06:59:56', ' '); -INSERT INTO `sys_dept` VALUES (5, '研发中心', 0, '0', 3, '2020-03-13 13:15:34', ' ', '2021-12-31 06:59:56', ' '); -INSERT INTO `sys_dept` VALUES (6, '产品中心', 0, '0', 3, '2020-03-13 13:15:49', ' ', '2021-12-31 06:59:56', ' '); -INSERT INTO `sys_dept` VALUES (7, '测试中心', 0, '0', 3, '2020-03-13 13:16:02', ' ', '2021-12-31 06:59:56', ' '); -COMMIT; - --- ---------------------------- --- Table structure for sys_dept_relation --- ---------------------------- -DROP TABLE IF EXISTS `sys_dept_relation`; -CREATE TABLE `sys_dept_relation` ( - `ancestor` bigint NOT NULL, - `descendant` bigint NOT NULL, - PRIMARY KEY (`ancestor`,`descendant`), - KEY `idx1` (`ancestor`), - KEY `idx2` (`descendant`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='部门关系表'; - --- ---------------------------- --- Records of sys_dept_relation --- ---------------------------- -BEGIN; -INSERT INTO `sys_dept_relation` VALUES (1, 1); -INSERT INTO `sys_dept_relation` VALUES (1, 2); -INSERT INTO `sys_dept_relation` VALUES (1, 3); -INSERT INTO `sys_dept_relation` VALUES (1, 4); -INSERT INTO `sys_dept_relation` VALUES (1, 5); -INSERT INTO `sys_dept_relation` VALUES (1, 6); -INSERT INTO `sys_dept_relation` VALUES (1, 7); -INSERT INTO `sys_dept_relation` VALUES (2, 2); -INSERT INTO `sys_dept_relation` VALUES (3, 3); -INSERT INTO `sys_dept_relation` VALUES (3, 5); -INSERT INTO `sys_dept_relation` VALUES (3, 6); -INSERT INTO `sys_dept_relation` VALUES (3, 7); -INSERT INTO `sys_dept_relation` VALUES (4, 4); -INSERT INTO `sys_dept_relation` VALUES (5, 5); -INSERT INTO `sys_dept_relation` VALUES (6, 6); -INSERT INTO `sys_dept_relation` VALUES (7, 7); +INSERT INTO `sys_dept` VALUES (1, '总裁办', 1, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:07:49', '0', 0); +INSERT INTO `sys_dept` VALUES (2, '技术部', 2, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 1); +INSERT INTO `sys_dept` VALUES (3, '市场部', 3, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 1); +INSERT INTO `sys_dept` VALUES (4, '销售部', 4, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 1); +INSERT INTO `sys_dept` VALUES (5, '财务部', 5, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 1); +INSERT INTO `sys_dept` VALUES (6, '人事行政部', 6, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:53:36', '1', 1); +INSERT INTO `sys_dept` VALUES (7, '研发部', 7, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 2); +INSERT INTO `sys_dept` VALUES (8, 'UI设计部', 11, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 7); +INSERT INTO `sys_dept` VALUES (9, '产品部', 12, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 2); +INSERT INTO `sys_dept` VALUES (10, '渠道部', 13, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 3); +INSERT INTO `sys_dept` VALUES (11, '推广部', 14, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 3); +INSERT INTO `sys_dept` VALUES (12, '客服部', 15, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 4); +INSERT INTO `sys_dept` VALUES (13, '财务会计部', 16, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 13:04:47', '0', 5); +INSERT INTO `sys_dept` VALUES (14, '审计风控部', 17, 'admin', 'admin', '2023-04-03 13:04:47', '2023-04-03 14:06:57', '0', 5); COMMIT; -- ---------------------------- @@ -76,33 +50,51 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_dict`; CREATE TABLE `sys_dict` ( - `id` bigint NOT NULL, - `dict_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标识', - `description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述', - `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注', - `system_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '是否是系统内置', - `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', - `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - KEY `sys_dict_del_flag` (`del_flag`) USING BTREE + `id` bigint NOT NULL COMMENT '编号', + `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典类型', + `description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注信息', + `system_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '系统标志', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志', + PRIMARY KEY (`id`) USING BTREE, + KEY `sys_dict_del_flag` (`del_flag`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='字典表'; -- ---------------------------- -- Records of sys_dict -- ---------------------------- BEGIN; -INSERT INTO `sys_dict` VALUES (1, 'dict_type', '字典类型', NULL, '0', '0', '2019-05-16 14:16:20', '', 'admin', '2021-12-29 12:29:18'); -INSERT INTO `sys_dict` VALUES (2, 'log_type', '日志类型', NULL, '0', '0', '2020-03-13 14:21:01', '', 'admin', '2021-12-29 12:30:14'); -INSERT INTO `sys_dict` VALUES (3, 'ds_type', '驱动类型', NULL, '0', '0', '2021-10-15 16:24:35', '', 'admin', '2021-12-29 12:30:18'); -INSERT INTO `sys_dict` VALUES (4, 'param_type', '参数配置', '检索、原文、报表、安全、文档、消息、其他', '1', '0', '2022-03-25 20:51:26', 'admin', 'admin', '2022-03-25 20:51:26'); -INSERT INTO `sys_dict` VALUES (5, 'status_type', '租户状态', '租户状态', '1', '0', '2022-03-25 20:56:51', 'admin', 'admin', '2022-03-25 20:56:51'); -INSERT INTO `sys_dict` VALUES (6, 'menu_type_status', '菜单类型', NULL, '1', '0', '2022-09-18 17:12:05', 'admin', 'admin', '2022-09-18 17:12:05'); -INSERT INTO `sys_dict` VALUES (7, 'dict_css_type', '字典项展示样式', NULL, '1', '0', '2022-09-28 21:37:23', 'admin', 'admin', '2022-09-28 21:37:23'); -INSERT INTO `sys_dict` VALUES (8, 'keepalive_status', '菜单是否开启缓冲', NULL, '1', '0', '2022-09-28 21:46:12', 'admin', 'admin', '2022-09-28 21:46:12'); -INSERT INTO `sys_dict` VALUES (9, 'user_lock_flag', '用户锁定标记', NULL, '1', '0', '2022-09-28 21:51:39', 'admin', 'admin', '2022-09-28 21:51:39'); +INSERT INTO `sys_dict` VALUES (1, 'log_type', '日志类型', ' ', ' ', '2019-03-19 11:06:44', '2019-03-19 11:06:44', '异常、正常', '1', '0'); +INSERT INTO `sys_dict` VALUES (2, 'social_type', '社交登录', ' ', ' ', '2019-03-19 11:09:44', '2019-03-19 11:09:44', '微信、QQ', '1', '0'); +INSERT INTO `sys_dict` VALUES (3, 'job_type', '定时任务类型', ' ', ' ', '2019-03-19 11:22:21', '2019-03-19 11:22:21', 'quartz', '1', '0'); +INSERT INTO `sys_dict` VALUES (4, 'job_status', '定时任务状态', ' ', ' ', '2019-03-19 11:24:57', '2019-03-19 11:24:57', '发布状态、运行状态', '1', '0'); +INSERT INTO `sys_dict` VALUES (5, 'job_execute_status', '定时任务执行状态', ' ', ' ', '2019-03-19 11:26:15', '2019-03-19 11:26:15', '正常、异常', '1', '0'); +INSERT INTO `sys_dict` VALUES (6, 'misfire_policy', '定时任务错失执行策略', ' ', ' ', '2019-03-19 11:27:19', '2019-03-19 11:27:19', '周期', '1', '0'); +INSERT INTO `sys_dict` VALUES (7, 'gender', '性别', ' ', ' ', '2019-03-27 13:44:06', '2019-03-27 13:44:06', '微信用户性别', '1', '0'); +INSERT INTO `sys_dict` VALUES (8, 'subscribe', '订阅状态', ' ', ' ', '2019-03-27 13:48:33', '2019-03-27 13:48:33', '公众号订阅状态', '1', '0'); +INSERT INTO `sys_dict` VALUES (9, 'response_type', '回复', ' ', ' ', '2019-03-28 21:29:21', '2019-03-28 21:29:21', '微信消息是否已回复', '1', '0'); +INSERT INTO `sys_dict` VALUES (10, 'param_type', '参数配置', ' ', ' ', '2019-04-29 18:20:47', '2019-04-29 18:20:47', '检索、原文、报表、安全、文档、消息、其他', '1', '0'); +INSERT INTO `sys_dict` VALUES (11, 'status_type', '租户状态', ' ', ' ', '2019-05-15 16:31:08', '2019-05-15 16:31:08', '租户状态', '1', '0'); +INSERT INTO `sys_dict` VALUES (12, 'dict_type', '字典类型', ' ', ' ', '2019-05-16 14:16:20', '2019-05-16 14:20:16', '系统类不能修改', '1', '0'); +INSERT INTO `sys_dict` VALUES (13, 'channel_type', '支付类型', ' ', ' ', '2019-05-16 14:16:20', '2019-05-16 14:20:16', '系统类不能修改', '1', '0'); +INSERT INTO `sys_dict` VALUES (14, 'grant_types', '授权类型', ' ', ' ', '2019-08-13 07:34:10', '2019-08-13 07:34:10', NULL, '1', '0'); +INSERT INTO `sys_dict` VALUES (15, 'style_type', '前端风格', ' ', ' ', '2020-02-07 03:49:28', '2020-02-07 03:50:40', '0-Avue 1-element', '1', '0'); +INSERT INTO `sys_dict` VALUES (16, 'captcha_flag_types', '验证码开关', ' ', ' ', '2020-11-18 06:53:25', '2020-11-18 06:53:25', '是否校验验证码', '1', '0'); +INSERT INTO `sys_dict` VALUES (17, 'enc_flag_types', '前端密码加密', ' ', ' ', '2020-11-18 06:54:44', '2020-11-18 06:54:44', '前端密码是否加密传输', '1', '0'); +INSERT INTO `sys_dict` VALUES (18, 'lock_flag', '用户状态', 'admin', ' ', '2023-02-01 16:55:31', NULL, NULL, '1', '0'); +INSERT INTO `sys_dict` VALUES (19, 'ds_config_type', '数据连接类型', 'admin', ' ', '2023-02-06 18:36:59', NULL, NULL, '1', '0'); +INSERT INTO `sys_dict` VALUES (20, 'common_status', '通用状态', 'admin', ' ', '2023-02-09 11:02:08', NULL, NULL, '1', '0'); +INSERT INTO `sys_dict` VALUES (21, 'app_social_type', 'app社交登录', 'admin', ' ', '2023-02-10 11:11:06', NULL, 'app社交登录', '1', '0'); +INSERT INTO `sys_dict` VALUES (22, 'yes_no_type', '是否', 'admin', ' ', '2023-02-20 23:25:04', NULL, NULL, '1', '0'); +INSERT INTO `sys_dict` VALUES (23, 'repType', '微信消息类型', 'admin', ' ', '2023-02-24 15:08:25', NULL, NULL, '0', '0'); +INSERT INTO `sys_dict` VALUES (24, 'leave_status', '请假状态', 'admin', ' ', '2023-03-02 22:50:15', NULL, NULL, '0', '0'); +INSERT INTO `sys_dict` VALUES (25, 'schedule_type', '日程类型', 'admin', ' ', '2023-03-06 14:49:18', NULL, NULL, '0', '0'); +INSERT INTO `sys_dict` VALUES (26, 'schedule_status', '日程状态', 'admin', ' ', '2023-03-06 14:52:57', NULL, NULL, '0', '0'); +INSERT INTO `sys_dict` VALUES (27, 'ds_type', '代码生成器支持的数据库类型', 'admin', ' ', '2023-03-12 09:57:59', NULL, NULL, '1', '0'); COMMIT; -- ---------------------------- @@ -110,112 +102,134 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_dict_item`; CREATE TABLE `sys_dict_item` ( - `id` bigint NOT NULL, - `dict_id` bigint NOT NULL COMMENT '字典ID', - `dict_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典标识', - `value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '值', - `label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标签', - `type` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典类型', - `description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述', - `sort_order` int NOT NULL DEFAULT '0' COMMENT '排序(升序)', - `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT ' ' COMMENT '备注', - `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', - `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - KEY `sys_dict_value` (`value`) USING BTREE, - KEY `sys_dict_label` (`label`) USING BTREE, - KEY `sys_dict_del_flag` (`del_flag`) USING BTREE + `id` bigint NOT NULL COMMENT '编号', + `dict_id` bigint NOT NULL COMMENT '字典ID', + `item_value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典项值', + `label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典项名称', + `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典类型', + `description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典项描述', + `sort_order` int NOT NULL DEFAULT '0' COMMENT '排序(升序)', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注信息', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志', + PRIMARY KEY (`id`) USING BTREE, + KEY `sys_dict_value` (`item_value`) USING BTREE, + KEY `sys_dict_label` (`label`) USING BTREE, + KEY `sys_dict_item_del_flag` (`del_flag`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='字典项'; -- ---------------------------- -- Records of sys_dict_item -- ---------------------------- BEGIN; -INSERT INTO `sys_dict_item` VALUES (1, 1, 'dict_type', '1', '系统类', NULL, '系统类字典', 0, ' ', '0', '2019-05-16 14:20:40', NULL, NULL, '2019-05-16 14:20:40'); -INSERT INTO `sys_dict_item` VALUES (2, 1, 'dict_type', '0', '业务类', NULL, '业务类字典', 0, ' ', '0', '2019-05-16 14:20:59', NULL, NULL, '2019-05-16 14:20:59'); -INSERT INTO `sys_dict_item` VALUES (3, 2, 'log_type', '0', '正常', NULL, '正常', 0, ' ', '0', '2020-03-13 14:23:22', NULL, NULL, '2020-03-13 14:23:22'); -INSERT INTO `sys_dict_item` VALUES (4, 2, 'log_type', '9', '异常', NULL, '异常', 0, ' ', '0', '2020-03-13 14:23:35', NULL, NULL, '2020-03-13 14:23:35'); -INSERT INTO `sys_dict_item` VALUES (5, 3, 'ds_type', 'com.mysql.cj.jdbc.Driver', 'MYSQL8', NULL, 'MYSQL8', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (6, 3, 'ds_type', 'com.mysql.jdbc.Driver', 'MYSQL5', NULL, 'MYSQL5', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (7, 3, 'ds_type', 'oracle.jdbc.OracleDriver', 'Oracle', NULL, 'Oracle', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (8, 3, 'ds_type', 'org.mariadb.jdbc.Driver', 'mariadb', NULL, 'mariadb', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (9, 3, 'ds_type', 'com.microsoft.sqlserver.jdbc.SQLServerDriver', 'sqlserver2005+', NULL, 'sqlserver2005+', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (10, 3, 'ds_type', 'com.microsoft.jdbc.sqlserver.SQLServerDriver', 'sqlserver2000', NULL, 'sqlserver2000', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (11, 3, 'ds_type', 'com.ibm.db2.jcc.DB2Driver', 'db2', NULL, 'db2', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (12, 3, 'ds_type', 'org.postgresql.Driver', 'postgresql', NULL, 'postgresql', 0, ' ', '0', NULL, NULL, NULL, NULL); -INSERT INTO `sys_dict_item` VALUES (13, 4, 'param_type', '1', '检索', NULL, '检索', 0, '检索', '0', '2022-03-25 20:51:51', 'admin', 'admin', '2022-03-25 20:51:51'); -INSERT INTO `sys_dict_item` VALUES (14, 4, 'param_type', '2', '原文', NULL, '原文', 1, '原文', '0', '2022-03-25 20:52:06', 'admin', 'admin', '2022-03-25 20:52:06'); -INSERT INTO `sys_dict_item` VALUES (15, 4, 'param_type', '3', '报表', NULL, '报表', 2, '报表', '0', '2022-03-25 20:52:16', 'admin', 'admin', '2022-03-25 20:52:16'); -INSERT INTO `sys_dict_item` VALUES (16, 4, 'param_type', '4', '安全', NULL, '安全', 3, '安全', '0', '2022-03-25 20:52:32', 'admin', 'admin', '2022-03-25 20:52:32'); -INSERT INTO `sys_dict_item` VALUES (17, 4, 'param_type', '5', '文档', NULL, '文档', 4, '文档', '0', '2022-03-25 20:52:52', 'admin', 'admin', '2022-03-25 20:52:52'); -INSERT INTO `sys_dict_item` VALUES (18, 4, 'param_type', '6', '消息', NULL, '消息', 5, '消息', '0', '2022-03-25 20:53:07', 'admin', 'admin', '2022-03-25 20:53:07'); -INSERT INTO `sys_dict_item` VALUES (19, 4, 'param_type', '9', '其他', NULL, '其他', 6, '其他', '0', '2022-03-25 20:54:50', 'admin', 'admin', '2022-03-25 20:54:50'); -INSERT INTO `sys_dict_item` VALUES (20, 4, 'param_type', '0', '默认', NULL, '默认', 7, '默认', '0', '2022-03-25 20:55:23', 'admin', 'admin', '2022-03-25 20:55:23'); -INSERT INTO `sys_dict_item` VALUES (21, 5, 'status_type', '0', '正常', NULL, '状态正常', 0, '状态正常', '0', '2022-03-25 20:57:12', 'admin', 'admin', '2022-03-25 20:57:12'); -INSERT INTO `sys_dict_item` VALUES (22, 5, 'status_type', '9', '冻结', NULL, '状态冻结', 1, '状态冻结', '0', '2022-03-25 20:57:34', 'admin', 'admin', '2022-03-25 20:57:34'); -INSERT INTO `sys_dict_item` VALUES (23, 6, 'menu_type_status', '0', '菜单', NULL, '菜单', 0, ' ', '0', '2022-09-18 17:15:52', 'admin', 'admin', '2022-09-18 17:15:52'); -INSERT INTO `sys_dict_item` VALUES (24, 6, 'menu_type_status', '1', '按钮', 'success', '按钮', 1, ' ', '0', '2022-09-18 17:16:06', 'admin', 'admin', '2022-09-18 17:16:06'); -INSERT INTO `sys_dict_item` VALUES (25, 7, 'dict_css_type', 'success', 'success', 'success', 'success', 2, ' ', '0', '2022-09-28 21:41:49', 'admin', 'admin', '2022-09-28 21:41:49'); -INSERT INTO `sys_dict_item` VALUES (26, 7, 'dict_css_type', 'info', 'info', 'info', 'info', 3, ' ', '0', '2022-09-28 21:41:59', 'admin', 'admin', '2022-09-28 21:41:59'); -INSERT INTO `sys_dict_item` VALUES (27, 7, 'dict_css_type', 'warning', 'warning', 'warning', 'warning', 4, ' ', '0', '2022-09-28 21:42:09', 'admin', 'admin', '2022-09-28 21:42:09'); -INSERT INTO `sys_dict_item` VALUES (28, 7, 'dict_css_type', 'danger', 'danger', 'danger', 'danger', 5, ' ', '0', '2022-09-28 21:42:19', 'admin', 'admin', '2022-09-28 21:42:19'); -INSERT INTO `sys_dict_item` VALUES (29, 8, 'keepalive_status', '0', '否', 'info', '不开启缓冲', 0, ' ', '0', '2022-09-28 21:46:32', 'admin', 'admin', '2022-09-28 21:46:32'); -INSERT INTO `sys_dict_item` VALUES (30, 8, 'keepalive_status', '1', '是', NULL, '开启缓冲', 1, ' ', '0', '2022-09-28 21:46:54', 'admin', 'admin', '2022-09-28 21:46:54'); -INSERT INTO `sys_dict_item` VALUES (31, 9, 'user_lock_flag', '0', '正常', NULL, '正常状态', 0, ' ', '0', '2022-09-28 21:51:55', 'admin', 'admin', '2022-09-28 21:51:55'); -INSERT INTO `sys_dict_item` VALUES (32, 9, 'user_lock_flag', '9', '锁定', 'info', '已锁定', 9, ' ', '0', '2022-09-28 21:52:13', 'admin', 'admin', '2022-09-28 21:52:13'); +INSERT INTO `sys_dict_item` VALUES (1, 1, '9', '异常', 'log_type', '日志异常', 1, ' ', ' ', '2019-03-19 11:08:59', '2019-03-25 12:49:13', '', '0'); +INSERT INTO `sys_dict_item` VALUES (2, 1, '0', '正常', 'log_type', '日志正常', 0, ' ', ' ', '2019-03-19 11:09:17', '2019-03-25 12:49:18', '', '0'); +INSERT INTO `sys_dict_item` VALUES (3, 2, 'WX', '微信', 'social_type', '微信登录', 0, ' ', ' ', '2019-03-19 11:10:02', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (4, 2, 'QQ', 'QQ', 'social_type', 'QQ登录', 1, ' ', ' ', '2019-03-19 11:10:14', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (5, 3, '1', 'java类', 'job_type', 'java类', 1, ' ', ' ', '2019-03-19 11:22:37', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (6, 3, '2', 'spring bean', 'job_type', 'spring bean容器实例', 2, ' ', ' ', '2019-03-19 11:23:05', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (7, 3, '9', '其他', 'job_type', '其他类型', 9, ' ', ' ', '2019-03-19 11:23:31', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (8, 3, '3', 'Rest 调用', 'job_type', 'Rest 调用', 3, ' ', ' ', '2019-03-19 11:23:57', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (9, 3, '4', 'jar', 'job_type', 'jar类型', 4, ' ', ' ', '2019-03-19 11:24:20', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (10, 4, '1', '未发布', 'job_status', '未发布', 1, ' ', ' ', '2019-03-19 11:25:18', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (11, 4, '2', '运行中', 'job_status', '运行中', 2, ' ', ' ', '2019-03-19 11:25:31', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (12, 4, '3', '暂停', 'job_status', '暂停', 3, ' ', ' ', '2019-03-19 11:25:42', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (13, 5, '0', '正常', 'job_execute_status', '正常', 0, ' ', ' ', '2019-03-19 11:26:27', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (14, 5, '1', '异常', 'job_execute_status', '异常', 1, ' ', ' ', '2019-03-19 11:26:41', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (15, 6, '1', '错失周期立即执行', 'misfire_policy', '错失周期立即执行', 1, ' ', ' ', '2019-03-19 11:27:45', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (16, 6, '2', '错失周期执行一次', 'misfire_policy', '错失周期执行一次', 2, ' ', ' ', '2019-03-19 11:27:57', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (17, 6, '3', '下周期执行', 'misfire_policy', '下周期执行', 3, ' ', ' ', '2019-03-19 11:28:08', '2019-03-25 12:49:36', '', '0'); +INSERT INTO `sys_dict_item` VALUES (18, 7, '1', '男', 'gender', '微信-男', 0, ' ', ' ', '2019-03-27 13:45:13', '2019-03-27 13:45:13', '微信-男', '0'); +INSERT INTO `sys_dict_item` VALUES (19, 7, '2', '女', 'gender', '女-微信', 1, ' ', ' ', '2019-03-27 13:45:34', '2019-03-27 13:45:34', '女-微信', '0'); +INSERT INTO `sys_dict_item` VALUES (20, 7, '0', '未知', 'gender', 'x性别未知', 3, ' ', ' ', '2019-03-27 13:45:57', '2019-03-27 13:45:57', 'x性别未知', '0'); +INSERT INTO `sys_dict_item` VALUES (21, 8, '0', '未关注', 'subscribe', '公众号-未关注', 0, ' ', ' ', '2019-03-27 13:49:07', '2019-03-27 13:49:07', '公众号-未关注', '0'); +INSERT INTO `sys_dict_item` VALUES (22, 8, '1', '已关注', 'subscribe', '公众号-已关注', 1, ' ', ' ', '2019-03-27 13:49:26', '2019-03-27 13:49:26', '公众号-已关注', '0'); +INSERT INTO `sys_dict_item` VALUES (23, 9, '0', '未回复', 'response_type', '微信消息-未回复', 0, ' ', ' ', '2019-03-28 21:29:47', '2019-03-28 21:29:47', '微信消息-未回复', '0'); +INSERT INTO `sys_dict_item` VALUES (24, 9, '1', '已回复', 'response_type', '微信消息-已回复', 1, ' ', ' ', '2019-03-28 21:30:08', '2019-03-28 21:30:08', '微信消息-已回复', '0'); +INSERT INTO `sys_dict_item` VALUES (25, 10, '1', '检索', 'param_type', '检索', 0, ' ', ' ', '2019-04-29 18:22:17', '2019-04-29 18:22:17', '检索', '0'); +INSERT INTO `sys_dict_item` VALUES (26, 10, '2', '原文', 'param_type', '原文', 0, ' ', ' ', '2019-04-29 18:22:27', '2019-04-29 18:22:27', '原文', '0'); +INSERT INTO `sys_dict_item` VALUES (27, 10, '3', '报表', 'param_type', '报表', 0, ' ', ' ', '2019-04-29 18:22:36', '2019-04-29 18:22:36', '报表', '0'); +INSERT INTO `sys_dict_item` VALUES (28, 10, '4', '安全', 'param_type', '安全', 0, ' ', ' ', '2019-04-29 18:22:46', '2019-04-29 18:22:46', '安全', '0'); +INSERT INTO `sys_dict_item` VALUES (29, 10, '5', '文档', 'param_type', '文档', 0, ' ', ' ', '2019-04-29 18:22:56', '2019-04-29 18:22:56', '文档', '0'); +INSERT INTO `sys_dict_item` VALUES (30, 10, '6', '消息', 'param_type', '消息', 0, ' ', ' ', '2019-04-29 18:23:05', '2019-04-29 18:23:05', '消息', '0'); +INSERT INTO `sys_dict_item` VALUES (31, 10, '9', '其他', 'param_type', '其他', 0, ' ', ' ', '2019-04-29 18:23:16', '2019-04-29 18:23:16', '其他', '0'); +INSERT INTO `sys_dict_item` VALUES (32, 10, '0', '默认', 'param_type', '默认', 0, ' ', ' ', '2019-04-29 18:23:30', '2019-04-29 18:23:30', '默认', '0'); +INSERT INTO `sys_dict_item` VALUES (33, 11, '0', '正常', 'status_type', '状态正常', 0, ' ', ' ', '2019-05-15 16:31:34', '2019-05-16 22:30:46', '状态正常', '0'); +INSERT INTO `sys_dict_item` VALUES (34, 11, '9', '冻结', 'status_type', '状态冻结', 1, ' ', ' ', '2019-05-15 16:31:56', '2019-05-16 22:30:50', '状态冻结', '0'); +INSERT INTO `sys_dict_item` VALUES (35, 12, '1', '系统类', 'dict_type', '系统类字典', 0, ' ', ' ', '2019-05-16 14:20:40', '2019-05-16 14:20:40', '不能修改删除', '0'); +INSERT INTO `sys_dict_item` VALUES (36, 12, '0', '业务类', 'dict_type', '业务类字典', 0, ' ', ' ', '2019-05-16 14:20:59', '2019-05-16 14:20:59', '可以修改', '0'); +INSERT INTO `sys_dict_item` VALUES (37, 2, 'GITEE', '码云', 'social_type', '码云', 2, ' ', ' ', '2019-06-28 09:59:12', '2019-06-28 09:59:12', '码云', '0'); +INSERT INTO `sys_dict_item` VALUES (38, 2, 'OSC', '开源中国', 'social_type', '开源中国登录', 2, ' ', ' ', '2019-06-28 10:04:32', '2019-06-28 10:04:32', '', '0'); +INSERT INTO `sys_dict_item` VALUES (39, 14, 'password', '密码模式', 'grant_types', '支持oauth密码模式', 0, ' ', ' ', '2019-08-13 07:35:28', '2019-08-13 07:35:28', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (40, 14, 'authorization_code', '授权码模式', 'grant_types', 'oauth2 授权码模式', 1, ' ', ' ', '2019-08-13 07:36:07', '2019-08-13 07:36:07', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (41, 14, 'client_credentials', '客户端模式', 'grant_types', 'oauth2 客户端模式', 2, ' ', ' ', '2019-08-13 07:36:30', '2019-08-13 07:36:30', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (42, 14, 'refresh_token', '刷新模式', 'grant_types', 'oauth2 刷新token', 3, ' ', ' ', '2019-08-13 07:36:54', '2019-08-13 07:36:54', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (43, 14, 'implicit', '简化模式', 'grant_types', 'oauth2 简化模式', 4, ' ', ' ', '2019-08-13 07:39:32', '2019-08-13 07:39:32', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (44, 15, '0', 'Avue', 'style_type', 'Avue风格', 0, ' ', ' ', '2020-02-07 03:52:52', '2020-02-07 03:52:52', '', '0'); +INSERT INTO `sys_dict_item` VALUES (45, 15, '1', 'element', 'style_type', 'element-ui', 1, ' ', ' ', '2020-02-07 03:53:12', '2020-02-07 03:53:12', '', '0'); +INSERT INTO `sys_dict_item` VALUES (46, 16, '0', '关', 'captcha_flag_types', '不校验验证码', 0, ' ', ' ', '2020-11-18 06:53:58', '2020-11-18 06:53:58', '不校验验证码 -0', '0'); +INSERT INTO `sys_dict_item` VALUES (47, 16, '1', '开', 'captcha_flag_types', '校验验证码', 1, ' ', ' ', '2020-11-18 06:54:15', '2020-11-18 06:54:15', '不校验验证码-1', '0'); +INSERT INTO `sys_dict_item` VALUES (48, 17, '0', '否', 'enc_flag_types', '不加密', 0, ' ', ' ', '2020-11-18 06:55:31', '2020-11-18 06:55:31', '不加密-0', '0'); +INSERT INTO `sys_dict_item` VALUES (49, 17, '1', '是', 'enc_flag_types', '加密', 1, ' ', ' ', '2020-11-18 06:55:51', '2020-11-18 06:55:51', '加密-1', '0'); +INSERT INTO `sys_dict_item` VALUES (50, 13, 'MERGE_PAY', '聚合支付', 'channel_type', '聚合支付', 1, ' ', ' ', '2019-05-30 19:08:08', '2019-06-18 13:51:53', '聚合支付', '0'); +INSERT INTO `sys_dict_item` VALUES (51, 2, 'CAS', 'CAS登录', 'social_type', 'CAS 单点登录系统', 3, ' ', ' ', '2022-02-18 13:56:25', '2022-02-18 13:56:28', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (52, 2, 'DINGTALK', '钉钉', 'social_type', '钉钉', 3, ' ', ' ', '2022-02-18 13:56:25', '2022-02-18 13:56:28', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (53, 2, 'WEIXIN_CP', '企业微信', 'social_type', '企业微信', 3, ' ', ' ', '2022-02-18 13:56:25', '2022-02-18 13:56:28', NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (54, 15, '2', 'APP', 'style_type', 'uview风格', 1, ' ', ' ', '2020-02-07 03:53:12', '2020-02-07 03:53:12', '', '0'); +INSERT INTO `sys_dict_item` VALUES (55, 13, 'ALIPAY_WAP', '支付宝支付', 'channel_type', '支付宝支付', 1, ' ', ' ', '2019-05-30 19:08:08', '2019-06-18 13:51:53', '聚合支付', '0'); +INSERT INTO `sys_dict_item` VALUES (56, 13, 'WEIXIN_MP', '微信支付', 'channel_type', '微信支付', 1, ' ', ' ', '2019-05-30 19:08:08', '2019-06-18 13:51:53', '聚合支付', '0'); +INSERT INTO `sys_dict_item` VALUES (57, 14, 'mobile', 'mobile', 'grant_types', '移动端登录', 5, 'admin', ' ', '2023-01-29 17:21:42', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (58, 18, '0', '有效', 'lock_flag', '有效', 0, 'admin', ' ', '2023-02-01 16:56:00', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (59, 18, '9', '禁用', 'lock_flag', '禁用', 1, 'admin', ' ', '2023-02-01 16:56:09', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (60, 15, '4', 'vue3', 'style_type', 'element-plus', 4, 'admin', ' ', '2023-02-06 13:52:43', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (61, 19, '0', '主机', 'ds_config_type', '主机', 0, 'admin', ' ', '2023-02-06 18:37:23', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (62, 19, '1', 'JDBC', 'ds_config_type', 'jdbc', 2, 'admin', ' ', '2023-02-06 18:37:34', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (63, 20, 'false', '否', 'common_status', '否', 1, 'admin', ' ', '2023-02-09 11:02:39', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (64, 20, 'true', '是', 'common_status', '是', 2, 'admin', ' ', '2023-02-09 11:02:52', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (65, 21, 'MINI', '小程序', 'app_social_type', '小程序登录', 0, 'admin', ' ', '2023-02-10 11:11:41', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (66, 22, '0', '否', 'yes_no_type', '0', 0, 'admin', ' ', '2023-02-20 23:35:23', NULL, '0', '0'); +INSERT INTO `sys_dict_item` VALUES (67, 22, '1', '是', 'yes_no_type', '1', 0, 'admin', ' ', '2023-02-20 23:35:37', NULL, '1', '0'); +INSERT INTO `sys_dict_item` VALUES (69, 23, 'text', '文本', 'repType', '文本', 0, 'admin', ' ', '2023-02-24 15:08:45', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (70, 23, 'image', '图片', 'repType', '图片', 0, 'admin', ' ', '2023-02-24 15:08:56', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (71, 23, 'voice', '语音', 'repType', '语音', 0, 'admin', ' ', '2023-02-24 15:09:08', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (72, 23, 'video', '视频', 'repType', '视频', 0, 'admin', ' ', '2023-02-24 15:09:18', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (73, 23, 'shortvideo', '小视频', 'repType', '小视频', 0, 'admin', ' ', '2023-02-24 15:09:29', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (74, 23, 'location', '地理位置', 'repType', '地理位置', 0, 'admin', ' ', '2023-02-24 15:09:41', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (75, 23, 'link', '链接消息', 'repType', '链接消息', 0, 'admin', ' ', '2023-02-24 15:09:49', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (76, 23, 'event', '事件推送', 'repType', '事件推送', 0, 'admin', ' ', '2023-02-24 15:09:57', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (77, 24, '0', '未提交', 'leave_status', '未提交', 0, 'admin', ' ', '2023-03-02 22:50:45', NULL, '未提交', '0'); +INSERT INTO `sys_dict_item` VALUES (78, 24, '1', '审批中', 'leave_status', '审批中', 0, 'admin', ' ', '2023-03-02 22:50:57', NULL, '审批中', '0'); +INSERT INTO `sys_dict_item` VALUES (79, 24, '2', '完成', 'leave_status', '完成', 0, 'admin', ' ', '2023-03-02 22:51:06', NULL, '完成', '0'); +INSERT INTO `sys_dict_item` VALUES (80, 24, '9', '驳回', 'leave_status', '驳回', 0, 'admin', ' ', '2023-03-02 22:51:20', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (81, 25, 'record', '日程记录', 'schedule_type', '日程记录', 0, 'admin', ' ', '2023-03-06 14:50:01', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (82, 25, 'plan', '计划', 'schedule_type', '计划类型', 0, 'admin', ' ', '2023-03-06 14:50:29', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (83, 26, '0', '计划中', 'schedule_status', '日程状态', 0, 'admin', ' ', '2023-03-06 14:53:18', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (84, 26, '1', '已开始', 'schedule_status', '已开始', 0, 'admin', ' ', '2023-03-06 14:53:33', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (85, 26, '3', '已结束', 'schedule_status', '已结束', 0, 'admin', ' ', '2023-03-06 14:53:41', NULL, NULL, '0'); +INSERT INTO `sys_dict_item` VALUES (86, 27, 'mysql', 'mysql', 'ds_type', 'mysql', 0, 'admin', ' ', '2023-03-12 09:58:11', NULL, NULL, '0'); COMMIT; - --- ---------------------------- --- Table structure for sys_public_param --- ---------------------------- -DROP TABLE IF EXISTS `sys_public_param`; -CREATE TABLE `sys_public_param` ( - `public_id` bigint(0) NOT NULL COMMENT '编号', - `public_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `public_key` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `public_value` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `status` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0', - `validate_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', - `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间', - `update_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间', - `public_type` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0', - `system_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0', - PRIMARY KEY (`public_id`) USING BTREE -) ENGINE = InnoDB DEFAULT CHARSET=utf8 COLLATE = utf8_general_ci COMMENT = '公共参数配置表'; - --- ---------------------------- --- Records of sys_public_param --- ---------------------------- -BEGIN; -INSERT INTO `sys_public_param` VALUES (1, '接口文档不显示的字段', 'GEN_HIDDEN_COLUMNS', 'tenant_id', '0', '', ' ', ' ', '2020-05-12 04:25:19', NULL, '9', '1'); -INSERT INTO `sys_public_param` VALUES (2, '注册用户默认角色', 'USER_DEFAULT_ROLE', 'GENERAL_USER', '0', '', 'admin', 'admin', '2022-03-30 10:00:57', '2022-03-30 02:05:59', '2', '1'); -COMMIT; - - -- ---------------------------- -- Table structure for sys_file -- ---------------------------- DROP TABLE IF EXISTS `sys_file`; CREATE TABLE `sys_file` ( - `id` bigint NOT NULL, - `file_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, - `bucket_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, - `original` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, - `type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, - `file_size` bigint DEFAULT NULL COMMENT '文件大小', - `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '0-正常,1-删除', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_time` datetime DEFAULT NULL COMMENT '修改时间', - `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建者', - `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='文件管理表'; + `id` bigint NOT NULL COMMENT '编号', + `file_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '文件名', + `bucket_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '文件存储桶名称', + `original` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '原始文件名', + `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '文件类型', + `file_size` bigint DEFAULT NULL COMMENT '文件大小', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT NULL COMMENT '上传时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='文件管理表'; -- ---------------------------- -- Records of sys_file @@ -228,33 +242,36 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_log`; CREATE TABLE `sys_log` ( - `id` bigint NOT NULL, - `type` char(1) COLLATE utf8_general_ci DEFAULT '1' COMMENT '日志类型', - `title` varchar(255) COLLATE utf8_general_ci DEFAULT '' COMMENT '日志标题', - `service_id` varchar(32) COLLATE utf8_general_ci DEFAULT NULL COMMENT '服务ID', - `remote_addr` varchar(255) COLLATE utf8_general_ci DEFAULT NULL COMMENT '操作IP地址', - `user_agent` varchar(1000) COLLATE utf8_general_ci DEFAULT NULL COMMENT '用户代理', - `request_uri` varchar(255) COLLATE utf8_general_ci DEFAULT NULL COMMENT '请求URI', - `method` varchar(10) COLLATE utf8_general_ci DEFAULT NULL COMMENT '操作方式', - `params` text COLLATE utf8_general_ci COMMENT '操作提交的数据', - `time` bigint DEFAULT NULL COMMENT '执行时间', - `del_flag` char(1) COLLATE utf8_general_ci DEFAULT '0' COMMENT '删除标记', - `exception` text COLLATE utf8_general_ci COMMENT '异常信息', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - `create_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建人', - `update_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`id`), - KEY `sys_log_create_by` (`create_by`), - KEY `sys_log_request_uri` (`request_uri`), - KEY `sys_log_type` (`type`), - KEY `sys_log_create_date` (`create_time`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='日志表'; + `id` bigint NOT NULL COMMENT '编号', + `log_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '日志类型', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日志标题', + `service_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '服务ID', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remote_addr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '远程地址', + `user_agent` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户代理', + `request_uri` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '请求URI', + `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '请求方法', + `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '请求参数', + `time` bigint DEFAULT NULL COMMENT '执行时间', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志', + `exception` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '异常信息', + PRIMARY KEY (`id`) USING BTREE, + KEY `sys_log_request_uri` (`request_uri`) USING BTREE, + KEY `sys_log_type` (`log_type`) USING BTREE, + KEY `sys_log_create_date` (`create_time`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='日志表'; -- ---------------------------- -- Records of sys_log -- ---------------------------- BEGIN; +INSERT INTO `sys_log` VALUES (1677218733317345282, '0', '更新角色菜单', NULL, 'anonymousUser', ' ', '2023-07-07 15:31:22', NULL, NULL, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', '/role/menu', 'PUT', '', 46, '0', NULL); +INSERT INTO `sys_log` VALUES (1677218768511750146, '0', '更新角色菜单', NULL, 'anonymousUser', ' ', '2023-07-07 15:31:30', NULL, NULL, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', '/role/menu', 'PUT', '', 59, '0', NULL); +INSERT INTO `sys_log` VALUES (1677218849554092033, '0', '更新角色菜单', NULL, 'anonymousUser', ' ', '2023-07-07 15:31:50', NULL, NULL, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', '/role/menu', 'PUT', '', 45, '0', NULL); +INSERT INTO `sys_log` VALUES (1677218871825846274, '0', '更新角色菜单', NULL, 'anonymousUser', ' ', '2023-07-07 15:31:55', NULL, NULL, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', '/role/menu', 'PUT', '', 9, '0', NULL); COMMIT; -- ---------------------------- @@ -262,85 +279,119 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_menu`; CREATE TABLE `sys_menu` ( - `menu_id` bigint NOT NULL, - `name` varchar(32) COLLATE utf8_general_ci NOT NULL COMMENT '菜单名称', - `permission` varchar(32) COLLATE utf8_general_ci DEFAULT NULL COMMENT '菜单权限标识', - `path` varchar(128) COLLATE utf8_general_ci DEFAULT NULL COMMENT '前端URL', - `parent_id` bigint DEFAULT NULL COMMENT '父菜单ID', - `icon` varchar(32) COLLATE utf8_general_ci DEFAULT NULL COMMENT '图标', - `sort_order` int NOT NULL DEFAULT '0' COMMENT '排序值', - `keep_alive` char(1) COLLATE utf8_general_ci DEFAULT '0' COMMENT '0-开启,1- 关闭', - `type` char(1) COLLATE utf8_general_ci DEFAULT NULL COMMENT '菜单类型 (0菜单 1按钮)', - `del_flag` char(1) COLLATE utf8_general_ci DEFAULT '0' COMMENT '逻辑删除标记(0--正常 1--删除)', - `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建人', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '修改人', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - PRIMARY KEY (`menu_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='菜单权限表'; + `menu_id` bigint NOT NULL COMMENT '菜单ID', + `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '菜单名称', + `en_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '英文名称', + `permission` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '权限标识', + `path` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '路由路径', + `parent_id` bigint DEFAULT NULL COMMENT '父菜单ID', + `icon` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '菜单图标', + `visible` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '1' COMMENT '是否可见,0隐藏,1显示', + `sort_order` int DEFAULT '1' COMMENT '排序值,越小越靠前', + `keep_alive` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '是否缓存,0否,1是', + `embedded` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否内嵌,0否,1是', + `menu_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '菜单类型,0目录,1菜单,2按钮', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志,0未删除,1已删除', + PRIMARY KEY (`menu_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='菜单权限表'; -- ---------------------------- -- Records of sys_menu -- ---------------------------- BEGIN; -INSERT INTO `sys_menu` VALUES ('1000', '权限管理', null, '/admin', '-1', 'icon-quanxianguanli', '1', '0', '0', '0', ' ', '2018-09-28 08:29:53', ' ', '2020-03-11 23:58:18'); -INSERT INTO `sys_menu` VALUES ('1100', '用户管理', null, '/admin/user/index', '1000', 'icon-yonghuguanli', '0', '0', '0', '0', ' ', '2017-11-02 22:24:37', ' ', '2020-03-12 00:12:57'); -INSERT INTO `sys_menu` VALUES ('1101', '用户新增', 'sys_user_add', null, '1100', null, '0', '0', '1', '0', ' ', '2017-11-08 09:52:09', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1102', '用户修改', 'sys_user_edit', null, '1100', null, '0', '0', '1', '0', ' ', '2017-11-08 09:52:48', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1103', '用户删除', 'sys_user_del', null, '1100', null, '0', '0', '1', '0', ' ', '2017-11-08 09:54:01', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1104', '导入导出', 'sys_user_import_export', null, '1100', null, '0', '0', '1', '0', ' ', '2017-11-08 09:54:01', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1200', '菜单管理', null, '/admin/menu/index', '1000', 'icon-caidanguanli', '1', '0', '0', '0', ' ', '2017-11-08 09:57:27', ' ', '2020-03-12 00:13:52'); -INSERT INTO `sys_menu` VALUES ('1201', '菜单新增', 'sys_menu_add', null, '1200', null, '0', '0', '1', '0', ' ', '2017-11-08 10:15:53', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1202', '菜单修改', 'sys_menu_edit', null, '1200', null, '0', '0', '1', '0', ' ', '2017-11-08 10:16:23', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1203', '菜单删除', 'sys_menu_del', null, '1200', null, '0', '0', '1', '0', ' ', '2017-11-08 10:16:43', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1300', '角色管理', null, '/admin/role/index', '1000', 'icon-jiaoseguanli', '2', '0', '0', '0', ' ', '2017-11-08 10:13:37', ' ', '2020-03-12 00:15:40'); -INSERT INTO `sys_menu` VALUES ('1301', '角色新增', 'sys_role_add', null, '1300', null, '0', '0', '1', '0', ' ', '2017-11-08 10:14:18', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1302', '角色修改', 'sys_role_edit', null, '1300', null, '0', '0', '1', '0', ' ', '2017-11-08 10:14:41', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1303', '角色删除', 'sys_role_del', null, '1300', null, '0', '0', '1', '0', ' ', '2017-11-08 10:14:59', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1304', '分配权限', 'sys_role_perm', null, '1300', null, '0', '0', '1', '0', ' ', '2018-04-20 07:22:55', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1305', '导入导出', 'sys_role_import_export', null, '1300', null, '0', '0', '1', '0', 'admin', '2022-03-21 11:14:52', 'admin', '2022-03-21 11:15:07'); -INSERT INTO `sys_menu` VALUES ('1400', '部门管理', null, '/admin/dept/index', '1000', 'icon-web-icon-', '3', '0', '0', '0', ' ', '2018-01-20 13:17:19', ' ', '2020-03-12 00:15:44'); -INSERT INTO `sys_menu` VALUES ('1401', '部门新增', 'sys_dept_add', null, '1400', null, '0', '0', '1', '0', ' ', '2018-01-20 14:56:16', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1402', '部门修改', 'sys_dept_edit', null, '1400', null, '0', '0', '1', '0', ' ', '2018-01-20 14:56:59', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1403', '部门删除', 'sys_dept_del', null, '1400', null, '0', '0', '1', '0', ' ', '2018-01-20 14:57:28', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('1500', '岗位管理', '', '/admin/post/index', '1000', 'icon-gangweiguanli', '4', '0', '0', '0', null, '2018-01-20 13:17:19', 'admin', '2022-11-10 21:35:55'); -INSERT INTO `sys_menu` VALUES ('1501', '岗位查看', 'sys_post_get', null, '1500', '1', '0', '0', '1', '0', null, '2018-05-15 21:35:18', 'admin', '2022-03-15 17:32:54'); -INSERT INTO `sys_menu` VALUES ('1502', '岗位新增', 'sys_post_add', null, '1500', '1', '1', '0', '1', '0', null, '2018-05-15 21:35:18', 'admin', '2022-03-15 17:32:48'); -INSERT INTO `sys_menu` VALUES ('1503', '岗位修改', 'sys_post_edit', null, '1500', '1', '2', '0', '1', '0', null, '2018-05-15 21:35:18', 'admin', '2022-03-15 17:33:10'); -INSERT INTO `sys_menu` VALUES ('1504', '岗位删除', 'sys_post_del', null, '1500', '1', '3', '0', '1', '0', null, '2018-05-15 21:35:18', 'admin', '2022-03-15 17:33:27'); -INSERT INTO `sys_menu` VALUES ('1505', '导入导出', 'sys_post_import_export', null, '1500', null, '4', '0', '1', '0', 'admin', '2022-03-21 12:53:05', 'admin', '2022-03-21 12:53:05'); -INSERT INTO `sys_menu` VALUES ('2000', '系统管理', null, '/setting', '-1', 'icon-wxbgongju1', '2', '0', '0', '0', '', '2017-11-07 20:56:00', 'admin', '2022-11-10 21:42:39'); -INSERT INTO `sys_menu` VALUES ('2100', '日志管理', null, '/admin/log/index', '2000', 'icon-rizhiguanli', '3', '0', '0', '0', ' ', '2017-11-20 14:06:22', ' ', '2020-03-12 00:15:49'); -INSERT INTO `sys_menu` VALUES ('2101', '日志删除', 'sys_log_del', null, '2100', null, '0', '0', '1', '0', ' ', '2017-11-20 20:37:37', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2102', '导入导出', 'sys_log_import_export', null, '2100', null, '0', '0', '1', '0', ' ', '2017-11-08 09:54:01', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2200', '字典管理', null, '/admin/dict/index', '2000', 'icon-tubiaozhizuomoban-27', '2', '0', '0', '0', '', '2017-11-29 11:30:52', 'admin', '2022-11-10 21:38:09'); -INSERT INTO `sys_menu` VALUES ('2201', '字典删除', 'sys_dict_del', null, '2200', null, '0', '0', '1', '0', ' ', '2017-11-29 11:30:11', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2202', '字典新增', 'sys_dict_add', null, '2200', null, '0', '0', '1', '0', ' ', '2018-05-11 22:34:55', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2203', '字典修改', 'sys_dict_edit', null, '2200', null, '0', '0', '1', '0', ' ', '2018-05-11 22:36:03', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2300', '令牌管理', null, '/admin/token/index', '2000', 'icon-lingpaiguanli', '4', '0', '0', '0', '', '2018-09-04 05:58:41', 'admin', '2022-11-10 21:38:33'); -INSERT INTO `sys_menu` VALUES ('2301', '令牌删除', 'sys_token_del', null, '2300', null, '0', '0', '1', '0', ' ', '2018-09-04 05:59:50', ' ', '2020-03-13 12:57:34'); -INSERT INTO `sys_menu` VALUES ('2400', '终端管理', '', '/admin/client/index', '2000', 'icon-shouji', '0', '0', '0', '0', ' ', '2018-01-20 13:17:19', ' ', '2020-03-12 00:15:54'); -INSERT INTO `sys_menu` VALUES ('2401', '客户端新增', 'sys_client_add', null, '2400', '1', '0', '0', '1', '0', ' ', '2018-05-15 21:35:18', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2402', '客户端修改', 'sys_client_edit', null, '2400', null, '0', '0', '1', '0', ' ', '2018-05-15 21:37:06', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2403', '客户端删除', 'sys_client_del', null, '2400', null, '0', '0', '1', '0', ' ', '2018-05-15 21:39:16', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2600', '文件管理', null, '/admin/file/index', '2000', 'icon-wenjianjiawenjianguanli', '1', '0', '0', '0', '', '2018-06-26 10:50:32', 'admin', '2022-11-10 21:35:40'); -INSERT INTO `sys_menu` VALUES ('2601', '文件删除', 'sys_file_del', null, '2600', null, '0', '0', '1', '0', ' ', '2017-11-29 11:30:11', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2602', '文件新增', 'sys_file_add', null, '2600', null, '0', '0', '1', '0', ' ', '2018-05-11 22:34:55', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2603', '文件修改', 'sys_file_edit', null, '2600', null, '0', '0', '1', '0', ' ', '2018-05-11 22:36:03', ' ', '2021-05-25 06:48:34'); -INSERT INTO `sys_menu` VALUES ('2700', '参数管理', null, '/admin/param/index', '2000', 'icon-canshu', '5', '0', '0', '0', 'admin', '2022-03-25 20:40:27', 'admin', '2022-11-10 21:38:50'); -INSERT INTO `sys_menu` VALUES ('2701', '参数新增', 'sys_publicparam_add', null, '2700', null, '0', '0', '1', '0', 'admin', '2022-03-25 20:45:05', 'admin', '2022-03-25 20:45:05'); -INSERT INTO `sys_menu` VALUES ('2702', '参数删除', 'sys_publicparam_del', null, '2700', null, '1', '0', '1', '0', 'admin', '2022-03-25 20:45:43', 'admin', '2022-03-25 20:45:43'); -INSERT INTO `sys_menu` VALUES ('2703', '参数修改', 'sys_publicparam_edit', null, '2700', null, '3', '0', '1', '0', 'admin', '2022-03-25 20:46:04', 'admin', '2022-03-25 20:46:04'); -INSERT INTO `sys_menu` VALUES ('3000', '开发平台', null, '/gen', '-1', 'icon-keshihuapingtaiicon_zujian', '3', '1', '0', '0', '', '2020-03-11 22:15:40', 'admin', '2022-11-10 21:39:25'); -INSERT INTO `sys_menu` VALUES ('3100', '数据源管理', null, '/gen/datasource', '3000', 'icon-shujuyuan', '3', '1', '0', '0', '', '2020-03-11 22:17:05', 'admin', '2022-11-10 21:40:27'); -INSERT INTO `sys_menu` VALUES ('3200', '代码生成', null, '/gen/index', '3000', 'icon-didaima', '0', '0', '0', '0', '', '2020-03-11 22:23:42', 'admin', '2022-11-10 21:39:54'); -INSERT INTO `sys_menu` VALUES ('3300', '表单管理', null, '/gen/form', '3000', 'icon-biaodanguanli', '1', '1', '0', '0', '', '2020-03-11 22:19:32', 'admin', '2022-11-10 21:40:06'); -INSERT INTO `sys_menu` VALUES ('3301', '表单新增', 'gen_form_add', null, '3300', '', '0', '0', '1', '0', ' ', '2018-05-15 21:35:18', ' ', '2020-03-11 22:39:08'); -INSERT INTO `sys_menu` VALUES ('3302', '表单修改', 'gen_form_edit', null, '3300', '', '0', '0', '1', '0', ' ', '2018-05-15 21:35:18', ' ', '2020-03-11 22:39:09'); -INSERT INTO `sys_menu` VALUES ('3303', '表单删除', 'gen_form_del', null, '3300', '', '0', '0', '1', '0', ' ', '2018-05-15 21:35:18', ' ', '2020-03-11 22:39:11'); -INSERT INTO `sys_menu` VALUES ('3400', '表单设计', null, '/gen/design', '3000', 'icon-sheji', '2', '1', '0', '0', '', '2020-03-11 22:18:05', 'admin', '2022-11-10 21:40:16'); -INSERT INTO `sys_menu` VALUES ('4000', '服务监控', null, 'http://localhost:5001/login', '-1', 'icon-iconset0265', '4', '0', '0', '0', 'admin', '2022-03-21 09:44:50', 'admin', '2022-11-10 21:42:17'); -INSERT INTO `sys_menu` VALUES ('9999', '系统官网', null, 'https://pig4cloud.com/#/', '-1', 'icon-web-icon-', '999', '0', '0', '0', '', '2019-01-17 17:05:19', 'admin', '2022-11-10 21:40:53'); +INSERT INTO `sys_menu` VALUES (1000, '权限管理', 'authorization', NULL, '/admin', -1, 'iconfont icon-icon-', '1', 0, '0', '0', '0', '', '2018-09-28 08:29:53', 'admin', '2023-03-12 22:32:52', '0'); +INSERT INTO `sys_menu` VALUES (1100, '用户管理', 'user', NULL, '/admin/user/index', 1000, 'ele-User', '1', 1, '0', '0', '0', '', '2017-11-02 22:24:37', 'admin', '2023-07-05 10:28:22', '0'); +INSERT INTO `sys_menu` VALUES (1101, '用户新增', NULL, 'sys_user_add', NULL, 1100, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 09:52:09', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1102, '用户修改', NULL, 'sys_user_edit', NULL, 1100, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 09:52:48', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1103, '用户删除', NULL, 'sys_user_del', NULL, 1100, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 09:54:01', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1104, '导入导出', NULL, 'sys_user_export', NULL, 1100, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 09:54:01', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1200, '菜单管理', 'menu', NULL, '/admin/menu/index', 1000, 'iconfont icon-caidan', '1', 2, '0', '0', '0', '', '2017-11-08 09:57:27', 'admin', '2023-07-05 10:28:17', '0'); +INSERT INTO `sys_menu` VALUES (1201, '菜单新增', NULL, 'sys_menu_add', NULL, 1200, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 10:15:53', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1202, '菜单修改', NULL, 'sys_menu_edit', NULL, 1200, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 10:16:23', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1203, '菜单删除', NULL, 'sys_menu_del', NULL, 1200, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 10:16:43', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1300, '角色管理', 'role', NULL, '/admin/role/index', 1000, 'iconfont icon-gerenzhongxin', '1', 3, '0', NULL, '0', '', '2017-11-08 10:13:37', 'admin', '2023-07-05 10:28:13', '0'); +INSERT INTO `sys_menu` VALUES (1301, '角色新增', NULL, 'sys_role_add', NULL, 1300, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 10:14:18', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1302, '角色修改', NULL, 'sys_role_edit', NULL, 1300, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 10:14:41', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1303, '角色删除', NULL, 'sys_role_del', NULL, 1300, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 10:14:59', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1304, '分配权限', NULL, 'sys_role_perm', NULL, 1300, NULL, '1', 1, '0', NULL, '1', ' ', '2018-04-20 07:22:55', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1305, '角色导入导出', NULL, 'sys_role_export', NULL, 1300, NULL, '1', 4, '0', NULL, '1', ' ', '2022-03-26 15:54:34', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (1400, '部门管理', 'dept', NULL, '/admin/dept/index', 1000, 'iconfont icon-zidingyibuju', '1', 4, '0', NULL, '0', '', '2018-01-20 13:17:19', 'admin', '2023-07-05 10:28:07', '0'); +INSERT INTO `sys_menu` VALUES (1401, '部门新增', NULL, 'sys_dept_add', NULL, 1400, NULL, '1', 1, '0', NULL, '1', ' ', '2018-01-20 14:56:16', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1402, '部门修改', NULL, 'sys_dept_edit', NULL, 1400, NULL, '1', 1, '0', NULL, '1', ' ', '2018-01-20 14:56:59', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1403, '部门删除', NULL, 'sys_dept_del', NULL, 1400, NULL, '1', 1, '0', NULL, '1', ' ', '2018-01-20 14:57:28', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (1600, '岗位管理', 'post', NULL, '/admin/post/index', 1000, 'iconfont icon--chaifenhang', '1', 5, '1', '0', '0', '', '2022-03-26 13:04:14', 'admin', '2023-07-05 10:28:03', '0'); +INSERT INTO `sys_menu` VALUES (1601, '岗位信息查看', NULL, 'sys_post_view', NULL, 1600, NULL, '1', 0, '0', NULL, '1', ' ', '2022-03-26 13:05:34', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (1602, '岗位信息新增', NULL, 'sys_post_add', NULL, 1600, NULL, '1', 1, '0', NULL, '1', ' ', '2022-03-26 13:06:00', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (1603, '岗位信息修改', NULL, 'sys_post_edit', NULL, 1600, NULL, '1', 2, '0', NULL, '1', ' ', '2022-03-26 13:06:31', ' ', '2022-03-26 13:06:38', '0'); +INSERT INTO `sys_menu` VALUES (1604, '岗位信息删除', NULL, 'sys_post_del', NULL, 1600, NULL, '1', 3, '0', NULL, '1', ' ', '2022-03-26 13:06:31', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (1605, '岗位导入导出', NULL, 'sys_post_export', NULL, 1600, NULL, '1', 4, '0', NULL, '1', ' ', '2022-03-26 13:06:31', ' ', '2022-03-26 06:32:02', '0'); +INSERT INTO `sys_menu` VALUES (2000, '系统管理', 'system', NULL, '/system', -1, 'iconfont icon-quanjushezhi_o', '1', 1, '0', NULL, '0', '', '2017-11-07 20:56:00', 'admin', '2023-07-05 10:27:58', '0'); +INSERT INTO `sys_menu` VALUES (2001, '日志管理', 'log', NULL, '/admin/logs', 2000, 'ele-Cloudy', '1', 0, '0', '0', '0', 'admin', '2023-03-02 12:26:42', 'admin', '2023-07-05 10:27:53', '0'); +INSERT INTO `sys_menu` VALUES (2100, '操作日志', 'operation', NULL, '/admin/log/index', 2001, 'iconfont icon-jinridaiban', '1', 2, '0', '0', '0', '', '2017-11-20 14:06:22', 'admin', '2023-07-05 10:27:49', '0'); +INSERT INTO `sys_menu` VALUES (2101, '日志删除', NULL, 'sys_log_del', NULL, 2100, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-20 20:37:37', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2102, '导入导出', NULL, 'sys_log_export', NULL, 2100, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-08 09:54:01', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2200, '字典管理', 'dict', NULL, '/admin/dict/index', 2000, 'iconfont icon-zhongduancanshuchaxun', '1', 6, '0', NULL, '0', '', '2017-11-29 11:30:52', 'admin', '2023-07-05 10:27:37', '0'); +INSERT INTO `sys_menu` VALUES (2201, '字典删除', NULL, 'sys_dict_del', NULL, 2200, NULL, '1', 1, '0', NULL, '1', ' ', '2017-11-29 11:30:11', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2202, '字典新增', NULL, 'sys_dict_add', NULL, 2200, NULL, '1', 1, '0', NULL, '1', ' ', '2018-05-11 22:34:55', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2203, '字典修改', NULL, 'sys_dict_edit', NULL, 2200, NULL, '1', 1, '0', NULL, '1', ' ', '2018-05-11 22:36:03', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2210, '参数管理', 'parameter', NULL, '/admin/param/index', 2000, 'iconfont icon-wenducanshu-05', '1', 7, '1', NULL, '0', '', '2019-04-29 22:16:50', 'admin', '2023-02-16 15:24:51', '0'); +INSERT INTO `sys_menu` VALUES (2211, '参数新增', NULL, 'sys_syspublicparam_add', NULL, 2210, NULL, '1', 1, '0', NULL, '1', ' ', '2019-04-29 22:17:36', ' ', '2020-03-24 08:57:11', '0'); +INSERT INTO `sys_menu` VALUES (2212, '参数删除', NULL, 'sys_syspublicparam_del', NULL, 2210, NULL, '1', 1, '0', NULL, '1', ' ', '2019-04-29 22:17:55', ' ', '2020-03-24 08:57:12', '0'); +INSERT INTO `sys_menu` VALUES (2213, '参数编辑', NULL, 'sys_syspublicparam_edit', NULL, 2210, NULL, '1', 1, '0', NULL, '1', ' ', '2019-04-29 22:18:14', ' ', '2020-03-24 08:57:13', '0'); +INSERT INTO `sys_menu` VALUES (2300, '代码生成', 'code', NULL, '/gen/table/index', 9000, 'iconfont icon-zhongduancanshu', '1', 1, '0', '0', '0', '', '2018-01-20 13:17:19', 'admin', '2023-02-20 13:54:35', '0'); +INSERT INTO `sys_menu` VALUES (2400, '终端管理', 'client', NULL, '/admin/client/index', 2000, 'iconfont icon-gongju', '1', 9, '1', NULL, '0', '', '2018-01-20 13:17:19', 'admin', '2023-02-16 15:25:28', '0'); +INSERT INTO `sys_menu` VALUES (2401, '客户端新增', NULL, 'sys_client_add', NULL, 2400, '1', '1', 1, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2402, '客户端修改', NULL, 'sys_client_edit', NULL, 2400, NULL, '1', 1, '0', NULL, '1', ' ', '2018-05-15 21:37:06', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2403, '客户端删除', NULL, 'sys_client_del', NULL, 2400, NULL, '1', 1, '0', NULL, '1', ' ', '2018-05-15 21:39:16', ' ', '2021-05-25 03:12:55', '0'); +INSERT INTO `sys_menu` VALUES (2500, '密钥管理', 'key', NULL, '/admin/social/index', 2000, 'iconfont icon-quanxian', '1', 10, '0', NULL, '0', '', '2018-01-20 13:17:19', 'admin', '2023-02-16 15:26:16', '0'); +INSERT INTO `sys_menu` VALUES (2501, '密钥新增', NULL, 'sys_social_details_add', NULL, 2500, '1', '1', 0, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:19', '0'); +INSERT INTO `sys_menu` VALUES (2502, '密钥修改', NULL, 'sys_social_details_edit', NULL, 2500, '1', '1', 1, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:19', '0'); +INSERT INTO `sys_menu` VALUES (2503, '密钥删除', NULL, 'sys_social_details_del', NULL, 2500, '1', '1', 2, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:23', '0'); +INSERT INTO `sys_menu` VALUES (2600, '令牌管理', 'token', NULL, '/admin/token/index', 2000, 'ele-Key', '1', 11, '0', NULL, '0', '', '2018-09-04 05:58:41', 'admin', '2023-02-16 15:28:28', '0'); +INSERT INTO `sys_menu` VALUES (2601, '令牌删除', NULL, 'sys_token_del', NULL, 2600, NULL, '1', 1, '0', NULL, '1', ' ', '2018-09-04 05:59:50', ' ', '2020-03-24 08:57:24', '0'); +INSERT INTO `sys_menu` VALUES (2800, 'Quartz管理', 'quartz', NULL, '/daemon/job-manage/index', 2000, 'ele-AlarmClock', '1', 8, '0', NULL, '0', '', '2018-01-20 13:17:19', 'admin', '2023-02-16 15:25:06', '0'); +INSERT INTO `sys_menu` VALUES (2810, '任务新增', NULL, 'job_sys_job_add', NULL, 2800, '1', '1', 0, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:26', '0'); +INSERT INTO `sys_menu` VALUES (2820, '任务修改', NULL, 'job_sys_job_edit', NULL, 2800, '1', '1', 0, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:27', '0'); +INSERT INTO `sys_menu` VALUES (2830, '任务删除', NULL, 'job_sys_job_del', NULL, 2800, '1', '1', 0, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:28', '0'); +INSERT INTO `sys_menu` VALUES (2840, '任务暂停', NULL, 'job_sys_job_shutdown_job', NULL, 2800, '1', '1', 0, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:28', '0'); +INSERT INTO `sys_menu` VALUES (2850, '任务开始', NULL, 'job_sys_job_start_job', NULL, 2800, '1', '1', 0, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:29', '0'); +INSERT INTO `sys_menu` VALUES (2860, '任务刷新', NULL, 'job_sys_job_refresh_job', NULL, 2800, '1', '1', 0, '0', NULL, '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:57:30', '0'); +INSERT INTO `sys_menu` VALUES (2870, '执行任务', NULL, 'job_sys_job_run_job', NULL, 2800, '1', '1', 0, '0', NULL, '1', ' ', '2019-08-08 15:35:18', ' ', '2020-03-24 08:57:31', '0'); +INSERT INTO `sys_menu` VALUES (2871, '导出', NULL, 'job_sys_job_export', NULL, 2800, NULL, '1', 0, '0', '0', '1', 'admin', '2023-03-06 15:26:13', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (2900, '国际化管理', 'i18n', NULL, '/admin/i18n/index', 2000, 'iconfont icon-zhongyingzhuanhuan', '1', 8, '0', NULL, '0', '', NULL, 'admin', '2023-02-16 15:25:18', '0'); +INSERT INTO `sys_menu` VALUES (2901, '系统表-国际化查看', NULL, 'sys_i18n_view', NULL, 2900, '1', '1', 0, '0', NULL, '1', ' ', NULL, ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (2902, '系统表-国际化新增', NULL, 'sys_i18n_add', NULL, 2900, '1', '1', 1, '0', NULL, '1', ' ', NULL, ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (2903, '系统表-国际化修改', NULL, 'sys_i18n_edit', NULL, 2900, '1', '1', 2, '0', NULL, '1', ' ', NULL, ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (2904, '系统表-国际化删除', NULL, 'sys_i18n_del', NULL, 2900, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (2905, '导入导出', NULL, 'sys_i18n_export', NULL, 2900, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (2906, '文件管理', 'file', NULL, '/admin/file/index', 2000, 'ele-Files', '1', 6, '0', NULL, '0', '', '2019-06-25 12:44:46', 'admin', '2023-02-16 15:24:42', '0'); +INSERT INTO `sys_menu` VALUES (2907, '删除文件', NULL, 'sys_file_del', NULL, 2906, NULL, '1', 1, '0', NULL, '1', ' ', '2019-06-25 13:41:41', ' ', '2020-03-24 08:58:42', '0'); +INSERT INTO `sys_menu` VALUES (4000, '系统监控', 'monitor', NULL, '/daemon', -1, 'iconfont icon-shuju', '1', 3, '0', '0', '0', 'admin', '2023-02-06 20:20:47', 'admin', '2023-02-23 20:01:07', '0'); +INSERT INTO `sys_menu` VALUES (4001, '文档扩展', 'doc', NULL, 'http://pigx-gateway:9999/admin/doc.html', 4000, 'iconfont icon-biaodan', '1', 2, '0', '1', '0', '', '2018-06-26 10:50:32', 'admin', '2023-02-23 20:01:29', '0'); +INSERT INTO `sys_menu` VALUES (4002, '缓存监控', 'cache', NULL, '/ext/cache', 4000, 'iconfont icon-shuju', '1', 1, '0', '0', '0', 'admin', '2023-05-29 15:12:59', 'admin', '2023-06-06 11:58:41', '0'); +INSERT INTO `sys_menu` VALUES (9000, '开发平台', 'develop', NULL, '/gen', -1, 'iconfont icon-shuxingtu', '1', 9, '0', '0', '0', '', '2019-08-12 09:35:16', 'admin', '2023-07-05 10:25:27', '0'); +INSERT INTO `sys_menu` VALUES (9005, '数据源管理', 'datasource', NULL, '/gen/datasource/index', 9000, 'ele-Coin', '1', 0, '0', NULL, '0', '', '2019-08-12 09:42:11', 'admin', '2023-07-05 10:26:56', '0'); +INSERT INTO `sys_menu` VALUES (9006, '表单设计', 'Form Design', NULL, '/gen/design/index', 9000, 'iconfont icon-AIshiyanshi', '0', 2, '0', '0', '0', '', '2019-08-16 10:08:56', 'admin', '2023-02-23 14:06:50', '0'); +INSERT INTO `sys_menu` VALUES (9007, '生成页面', 'generation', NULL, '/gen/gener/index', 9000, 'iconfont icon-tongzhi4', '0', 0, '0', '0', '0', 'admin', '2023-02-20 09:58:23', 'admin', '2023-07-05 10:27:06', '0'); +INSERT INTO `sys_menu` VALUES (9050, '元数据管理', 'metadata', NULL, '/gen/metadata', 9000, 'iconfont icon--chaifenhang', '1', 9, '0', '0', '0', '', '2018-07-27 01:13:21', 'admin', '2023-07-05 10:27:13', '0'); +INSERT INTO `sys_menu` VALUES (9051, '模板管理', 'template', NULL, '/gen/template/index', 9050, 'iconfont icon--chaifenhang', '1', 5, '0', '0', '0', 'admin', '2023-02-21 11:22:54', 'admin', '2023-07-05 10:27:18', '0'); +INSERT INTO `sys_menu` VALUES (9052, '查询', NULL, 'codegen_template_view', NULL, 9051, NULL, '0', 0, '0', '0', '1', 'admin', '2023-02-21 12:33:03', 'admin', '2023-02-21 13:50:54', '0'); +INSERT INTO `sys_menu` VALUES (9053, '增加', NULL, 'codegen_template_add', NULL, 9051, NULL, '1', 0, '0', '0', '1', 'admin', '2023-02-21 13:34:10', 'admin', '2023-02-21 13:39:49', '0'); +INSERT INTO `sys_menu` VALUES (9054, '新增', NULL, 'codegen_template_add', NULL, 9051, NULL, '0', 1, '0', '0', '1', 'admin', '2023-02-21 13:51:32', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9055, '导出', NULL, 'codegen_template_export', NULL, 9051, NULL, '0', 2, '0', '0', '1', 'admin', '2023-02-21 13:51:58', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9056, '删除', NULL, 'codegen_template_del', NULL, 9051, NULL, '0', 3, '0', '0', '1', 'admin', '2023-02-21 13:52:16', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9057, '编辑', NULL, 'codegen_template_edit', NULL, 9051, NULL, '0', 4, '0', '0', '1', 'admin', '2023-02-21 13:52:58', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9059, '模板分组', 'group', NULL, '/gen/group/index', 9050, 'iconfont icon-shuxingtu', '1', 6, '0', '0', '0', 'admin', '2023-02-21 15:06:50', 'admin', '2023-07-05 10:27:22', '0'); +INSERT INTO `sys_menu` VALUES (9060, '查询', NULL, 'codegen_group_view', NULL, 9059, NULL, '0', 0, '0', '0', '1', 'admin', '2023-02-21 15:08:07', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9061, '新增', NULL, 'codegen_group_add', NULL, 9059, NULL, '0', 0, '0', '0', '1', 'admin', '2023-02-21 15:08:28', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9062, '修改', NULL, 'codegen_group_edit', NULL, 9059, NULL, '0', 0, '0', '0', '1', 'admin', '2023-02-21 15:08:43', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9063, '删除', NULL, 'codegen_group_del', NULL, 9059, NULL, '0', 0, '0', '0', '1', 'admin', '2023-02-21 15:09:02', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9064, '导出', NULL, 'codegen_group_export', NULL, 9059, NULL, '0', 0, '0', '0', '1', 'admin', '2023-02-21 15:09:22', ' ', NULL, '0'); +INSERT INTO `sys_menu` VALUES (9065, '字段管理', 'field', NULL, '/gen/field-type/index', 9050, 'iconfont icon-fuwenben', '1', 0, '0', '0', '0', 'admin', '2023-02-23 20:05:09', 'admin', '2023-07-05 10:27:31', '0'); COMMIT; -- ---------------------------- @@ -348,78 +399,98 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_oauth_client_details`; CREATE TABLE `sys_oauth_client_details` ( - `client_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '客户端ID', - `resource_ids` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '资源列表', - `client_secret` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '客户端密钥', - `scope` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '域', - `authorized_grant_types` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '认证类型', - `web_server_redirect_uri` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '重定向地址', - `authorities` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '角色列表', - `access_token_validity` int DEFAULT NULL COMMENT 'token 有效期', - `refresh_token_validity` int DEFAULT NULL COMMENT '刷新令牌有效期', - `additional_information` varchar(4096) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '令牌扩展字段JSON', - `autoapprove` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '是否自动放行', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建人', - `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`client_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='终端信息表'; + `id` bigint NOT NULL COMMENT 'ID', + `client_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '客户端ID', + `resource_ids` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '资源ID集合', + `client_secret` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '客户端秘钥', + `scope` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '授权范围', + `authorized_grant_types` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '授权类型', + `web_server_redirect_uri` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '回调地址', + `authorities` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '权限集合', + `access_token_validity` int DEFAULT NULL COMMENT '访问令牌有效期(秒)', + `refresh_token_validity` int DEFAULT NULL COMMENT '刷新令牌有效期(秒)', + `additional_information` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附加信息', + `autoapprove` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '自动授权', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记,0未删除,1已删除', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='终端信息表'; -- ---------------------------- -- Records of sys_oauth_client_details -- ---------------------------- BEGIN; -INSERT INTO `sys_oauth_client_details` VALUES ('app', NULL, 'app', 'server', 'app,refresh_token', NULL, NULL, NULL, NULL, NULL, 'true', NULL, NULL, NULL, NULL); -INSERT INTO `sys_oauth_client_details` VALUES ('daemon', NULL, 'daemon', 'server', 'password,refresh_token', NULL, NULL, NULL, NULL, NULL, 'true', NULL, NULL, NULL, NULL); -INSERT INTO `sys_oauth_client_details` VALUES ('gen', NULL, 'gen', 'server', 'password,refresh_token', NULL, NULL, NULL, NULL, NULL, 'true', NULL, NULL, NULL, NULL); -INSERT INTO `sys_oauth_client_details` VALUES ('pig', NULL, 'pig', 'server', 'password,app,refresh_token,authorization_code,client_credentials', 'https://pigx.vip', NULL, NULL, NULL, NULL, 'true', NULL, NULL, NULL, NULL); -INSERT INTO `sys_oauth_client_details` VALUES ('test', NULL, 'test', 'server', 'password,app,refresh_token', NULL, NULL, NULL, NULL, NULL, 'true', NULL, NULL, NULL, NULL); -INSERT INTO `sys_oauth_client_details` VALUES ('client', NULL, 'client', 'server', 'client_credentials', NULL, NULL, NULL, NULL, NULL, 'true', NULL, NULL, NULL, NULL); +INSERT INTO `sys_oauth_client_details` VALUES (1, 'app', NULL, 'app', 'server', 'password,refresh_token,authorization_code,client_credentials,mobile', 'http://localhost:4040/sso1/login,http://localhost:4041/sso1/login,http://localhost:8080/renren-admin/sys/oauth2-sso,http://localhost:8090/sys/oauth2-sso', NULL, 43200, 2592001, '{\"enc_flag\":\"1\",\"captcha_flag\":\"1\",\"online_quantity\":\"1\"}', 'true', '0', '', 'admin', NULL, '2023-02-09 13:54:54'); +INSERT INTO `sys_oauth_client_details` VALUES (2, 'daemon', NULL, 'daemon', 'server', 'password,refresh_token', NULL, NULL, 43200, 2592001, '{\"enc_flag\":\"1\",\"captcha_flag\":\"1\"}', 'true', '0', ' ', ' ', NULL, NULL); +INSERT INTO `sys_oauth_client_details` VALUES (3, 'gen', NULL, 'gen', 'server', 'password,refresh_token', NULL, NULL, 43200, 2592001, '{\"enc_flag\":\"1\",\"captcha_flag\":\"1\"}', 'true', '0', ' ', ' ', NULL, NULL); +INSERT INTO `sys_oauth_client_details` VALUES (4, 'mp', NULL, 'mp', 'server', 'password,refresh_token', NULL, NULL, 43200, 2592001, '{\"enc_flag\":\"1\",\"captcha_flag\":\"1\"}', 'true', '0', ' ', ' ', NULL, NULL); +INSERT INTO `sys_oauth_client_details` VALUES (5, 'pig', NULL, 'pig', 'server', 'password,refresh_token,authorization_code,client_credentials,mobile', 'http://localhost:4040/sso1/login,http://localhost:4041/sso1/login,http://localhost:8080/renren-admin/sys/oauth2-sso,http://localhost:8090/sys/oauth2-sso', NULL, 43200, 2592001, '{\"enc_flag\":\"1\",\"captcha_flag\":\"1\",\"online_quantity\":\"1\"}', 'false', '0', '', 'admin', NULL, '2023-03-08 11:32:41'); +INSERT INTO `sys_oauth_client_details` VALUES (6, 'test', NULL, 'test', 'server', 'password,refresh_token', NULL, NULL, 43200, 2592001, '{ \"enc_flag\":\"1\",\"captcha_flag\":\"0\"}', 'true', '0', ' ', ' ', NULL, NULL); +INSERT INTO `sys_oauth_client_details` VALUES (7, 'social', NULL, 'social', 'server', 'password,refresh_token,mobile', NULL, NULL, 43200, 2592001, '{ \"enc_flag\":\"0\",\"captcha_flag\":\"0\"}', 'true', '0', ' ', ' ', NULL, NULL); COMMIT; -- ---------------------------- -- Table structure for sys_post -- ---------------------------- DROP TABLE IF EXISTS `sys_post`; -CREATE TABLE `sys_post` ( - `post_id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '岗位ID', - `post_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '岗位编码', - `post_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '岗位名称', - `post_sort` int(0) NOT NULL COMMENT '岗位排序', - `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '是否删除 -1:已删除 0:正常', - `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', - `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '创建人', - `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '更新人', - `remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注信息', - PRIMARY KEY (`post_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT = '岗位信息表'; +CREATE TABLE `sys_post` ( + `post_id` bigint NOT NULL COMMENT '岗位ID', + `post_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位编码', + `post_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位名称', + `post_sort` int NOT NULL COMMENT '岗位排序', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '岗位描述', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '是否删除 -1:已删除 0:正常', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '创建人', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '更新人', + PRIMARY KEY (`post_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='岗位信息表'; -- ---------------------------- -- Records of sys_post -- ---------------------------- BEGIN; -INSERT INTO `sys_post` VALUES (1, 'user', '员工', 2, '0', '2022-03-19 10:05:15', 'admin', '2022-03-19 10:42:28', 'admin', '打工人'); -INSERT INTO `sys_post` VALUES (2, 'cto', 'cto', 0, '0', '2022-03-19 10:06:20', 'admin', '2022-03-19 10:06:20', 'admin', 'cto666'); -INSERT INTO `sys_post` VALUES (3, 'boss', '董事长', -1, '0', '2022-03-19 10:06:35', 'admin', '2022-03-19 10:42:44', 'admin', '大boss'); +INSERT INTO `sys_post` VALUES (1, 'CTO', 'CTO', 0, 'CTOOO', '0', '2022-03-26 13:48:17', '', '2023-03-08 16:03:35', 'admin'); COMMIT; -- ---------------------------- --- Table structure for sys_user_post +-- Table structure for sys_public_param -- ---------------------------- -DROP TABLE IF EXISTS `sys_user_post`; -CREATE TABLE `sys_user_post` ( - `user_id` bigint(0) NOT NULL COMMENT '用户ID', - `post_id` bigint(0) NOT NULL COMMENT '岗位ID', - PRIMARY KEY (`user_id`, `post_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT = '用户与岗位关联表'; +DROP TABLE IF EXISTS `sys_public_param`; +CREATE TABLE `sys_public_param` ( + `public_id` bigint NOT NULL COMMENT '编号', + `public_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '名称', + `public_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '键', + `public_value` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '值', + `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态,0禁用,1启用', + `validate_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '校验码', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `public_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '类型,0未知,1系统,2业务', + `system_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '系统标识,0非系统,1系统', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记,0未删除,1已删除', + PRIMARY KEY (`public_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='公共参数配置表'; -- ---------------------------- --- Records of sys_user_post +-- Records of sys_public_param -- ---------------------------- BEGIN; -INSERT INTO `sys_user_post` VALUES (1, 1); +INSERT INTO `sys_public_param` VALUES (1, '租户默认来源', 'TENANT_DEFAULT_ID', '1', '0', '', ' ', ' ', '2020-05-12 04:03:46', '2020-06-20 08:56:30', '2', '0', '1'); +INSERT INTO `sys_public_param` VALUES (2, '租户默认部门名称', 'TENANT_DEFAULT_DEPTNAME', '租户默认部门', '0', '', ' ', ' ', '2020-05-12 03:36:32', NULL, '2', '1', '0'); +INSERT INTO `sys_public_param` VALUES (3, '租户默认账户', 'TENANT_DEFAULT_USERNAME', 'admin', '0', '', ' ', ' ', '2020-05-12 04:05:04', NULL, '2', '1', '0'); +INSERT INTO `sys_public_param` VALUES (4, '租户默认密码', 'TENANT_DEFAULT_PASSWORD', '123456', '0', '', ' ', ' ', '2020-05-12 04:05:24', NULL, '2', '1', '0'); +INSERT INTO `sys_public_param` VALUES (5, '租户默认角色编码', 'TENANT_DEFAULT_ROLECODE', 'ROLE_ADMIN', '0', '', ' ', ' ', '2020-05-12 04:05:57', NULL, '2', '1', '0'); +INSERT INTO `sys_public_param` VALUES (6, '租户默认角色名称', 'TENANT_DEFAULT_ROLENAME', '租户默认角色', '0', '', ' ', ' ', '2020-05-12 04:06:19', NULL, '2', '1', '0'); +INSERT INTO `sys_public_param` VALUES (7, '表前缀', 'GEN_TABLE_PREFIX', 'tb_', '0', '', ' ', ' ', '2020-05-12 04:23:04', NULL, '9', '1', '0'); +INSERT INTO `sys_public_param` VALUES (8, '接口文档不显示的字段', 'GEN_HIDDEN_COLUMNS', 'tenant_id', '0', '', ' ', ' ', '2020-05-12 04:25:19', NULL, '9', '1', '0'); +INSERT INTO `sys_public_param` VALUES (9, '注册用户默认角色', 'USER_DEFAULT_ROLE', 'GENERAL_USER', '0', NULL, ' ', ' ', '2022-03-31 16:52:24', NULL, '2', '1', '0'); COMMIT; -- ---------------------------- @@ -427,25 +498,25 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_role`; CREATE TABLE `sys_role` ( - `role_id` bigint NOT NULL, - `role_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `role_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `role_desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, - `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '删除标识(0-正常,1-删除)', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_time` datetime DEFAULT NULL COMMENT '修改时间', - `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '修改人', - `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建人', - PRIMARY KEY (`role_id`), - UNIQUE KEY `role_idx1_role_code` (`role_code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='系统角色表'; + `role_id` bigint NOT NULL COMMENT '角色ID', + `role_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '角色名称', + `role_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '角色编码', + `role_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '角色描述', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记,0未删除,1已删除', + PRIMARY KEY (`role_id`) USING BTREE, + KEY `role_idx1_role_code` (`role_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='系统角色表'; -- ---------------------------- -- Records of sys_role -- ---------------------------- BEGIN; -INSERT INTO `sys_role` VALUES (1, '管理员', 'ROLE_ADMIN', '管理员', '0', '2017-10-29 15:45:51', '2018-12-26 14:09:11', NULL, NULL); -INSERT INTO `sys_role` VALUES (2, '普通用户','GENERAL_USER', '普通用户', '0', '2022-03-30 09:59:24', '2022-03-30 09:59:24', 'admin', 'admin'); +INSERT INTO `sys_role` VALUES (1, '管理员', 'ROLE_ADMIN', '管理员', '', 'admin', '2017-10-29 15:45:51', '2023-07-07 14:55:07', '0'); +INSERT INTO `sys_role` VALUES (2, '普通用户', 'GENERAL_USER', '普通用户', '', 'admin', '2022-03-31 17:03:15', '2023-04-03 02:28:51', '0'); COMMIT; -- ---------------------------- @@ -453,10 +524,10 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_role_menu`; CREATE TABLE `sys_role_menu` ( - `role_id` bigint NOT NULL, - `menu_id` bigint NOT NULL, - PRIMARY KEY (`role_id`,`menu_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='角色菜单表'; + `role_id` bigint NOT NULL COMMENT '角色ID', + `menu_id` bigint NOT NULL COMMENT '菜单ID', + PRIMARY KEY (`role_id`,`menu_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='角色菜单表'; -- ---------------------------- -- Records of sys_role_menu @@ -482,13 +553,14 @@ INSERT INTO `sys_role_menu` VALUES (1, 1400); INSERT INTO `sys_role_menu` VALUES (1, 1401); INSERT INTO `sys_role_menu` VALUES (1, 1402); INSERT INTO `sys_role_menu` VALUES (1, 1403); -INSERT INTO `sys_role_menu` VALUES (1, 1500); -INSERT INTO `sys_role_menu` VALUES (1, 1501); -INSERT INTO `sys_role_menu` VALUES (1, 1502); -INSERT INTO `sys_role_menu` VALUES (1, 1503); -INSERT INTO `sys_role_menu` VALUES (1, 1504); -INSERT INTO `sys_role_menu` VALUES (1, 1505); +INSERT INTO `sys_role_menu` VALUES (1, 1600); +INSERT INTO `sys_role_menu` VALUES (1, 1601); +INSERT INTO `sys_role_menu` VALUES (1, 1602); +INSERT INTO `sys_role_menu` VALUES (1, 1603); +INSERT INTO `sys_role_menu` VALUES (1, 1604); +INSERT INTO `sys_role_menu` VALUES (1, 1605); INSERT INTO `sys_role_menu` VALUES (1, 2000); +INSERT INTO `sys_role_menu` VALUES (1, 2001); INSERT INTO `sys_role_menu` VALUES (1, 2100); INSERT INTO `sys_role_menu` VALUES (1, 2101); INSERT INTO `sys_role_menu` VALUES (1, 2102); @@ -496,32 +568,63 @@ INSERT INTO `sys_role_menu` VALUES (1, 2200); INSERT INTO `sys_role_menu` VALUES (1, 2201); INSERT INTO `sys_role_menu` VALUES (1, 2202); INSERT INTO `sys_role_menu` VALUES (1, 2203); +INSERT INTO `sys_role_menu` VALUES (1, 2210); +INSERT INTO `sys_role_menu` VALUES (1, 2211); +INSERT INTO `sys_role_menu` VALUES (1, 2212); +INSERT INTO `sys_role_menu` VALUES (1, 2213); INSERT INTO `sys_role_menu` VALUES (1, 2300); -INSERT INTO `sys_role_menu` VALUES (1, 2301); INSERT INTO `sys_role_menu` VALUES (1, 2400); INSERT INTO `sys_role_menu` VALUES (1, 2401); INSERT INTO `sys_role_menu` VALUES (1, 2402); INSERT INTO `sys_role_menu` VALUES (1, 2403); +INSERT INTO `sys_role_menu` VALUES (1, 2500); +INSERT INTO `sys_role_menu` VALUES (1, 2501); +INSERT INTO `sys_role_menu` VALUES (1, 2502); +INSERT INTO `sys_role_menu` VALUES (1, 2503); INSERT INTO `sys_role_menu` VALUES (1, 2600); INSERT INTO `sys_role_menu` VALUES (1, 2601); -INSERT INTO `sys_role_menu` VALUES (1, 2602); -INSERT INTO `sys_role_menu` VALUES (1, 2603); -INSERT INTO `sys_role_menu` VALUES (1, 2700); -INSERT INTO `sys_role_menu` VALUES (1, 2701); -INSERT INTO `sys_role_menu` VALUES (1, 2702); -INSERT INTO `sys_role_menu` VALUES (1, 2703); -INSERT INTO `sys_role_menu` VALUES (1, 3000); -INSERT INTO `sys_role_menu` VALUES (1, 3100); -INSERT INTO `sys_role_menu` VALUES (1, 3200); -INSERT INTO `sys_role_menu` VALUES (1, 3300); -INSERT INTO `sys_role_menu` VALUES (1, 3301); -INSERT INTO `sys_role_menu` VALUES (1, 3302); -INSERT INTO `sys_role_menu` VALUES (1, 3303); -INSERT INTO `sys_role_menu` VALUES (1, 3400); +INSERT INTO `sys_role_menu` VALUES (1, 2800); +INSERT INTO `sys_role_menu` VALUES (1, 2810); +INSERT INTO `sys_role_menu` VALUES (1, 2820); +INSERT INTO `sys_role_menu` VALUES (1, 2830); +INSERT INTO `sys_role_menu` VALUES (1, 2840); +INSERT INTO `sys_role_menu` VALUES (1, 2850); +INSERT INTO `sys_role_menu` VALUES (1, 2860); +INSERT INTO `sys_role_menu` VALUES (1, 2870); +INSERT INTO `sys_role_menu` VALUES (1, 2871); +INSERT INTO `sys_role_menu` VALUES (1, 2900); +INSERT INTO `sys_role_menu` VALUES (1, 2901); +INSERT INTO `sys_role_menu` VALUES (1, 2902); +INSERT INTO `sys_role_menu` VALUES (1, 2903); +INSERT INTO `sys_role_menu` VALUES (1, 2904); +INSERT INTO `sys_role_menu` VALUES (1, 2905); +INSERT INTO `sys_role_menu` VALUES (1, 2906); +INSERT INTO `sys_role_menu` VALUES (1, 2907); INSERT INTO `sys_role_menu` VALUES (1, 4000); -INSERT INTO `sys_role_menu` VALUES (1, 9999); +INSERT INTO `sys_role_menu` VALUES (1, 4001); +INSERT INTO `sys_role_menu` VALUES (1, 4002); +INSERT INTO `sys_role_menu` VALUES (1, 9000); +INSERT INTO `sys_role_menu` VALUES (1, 9005); +INSERT INTO `sys_role_menu` VALUES (1, 9006); +INSERT INTO `sys_role_menu` VALUES (1, 9007); +INSERT INTO `sys_role_menu` VALUES (1, 9050); +INSERT INTO `sys_role_menu` VALUES (1, 9051); +INSERT INTO `sys_role_menu` VALUES (1, 9052); +INSERT INTO `sys_role_menu` VALUES (1, 9053); +INSERT INTO `sys_role_menu` VALUES (1, 9054); +INSERT INTO `sys_role_menu` VALUES (1, 9055); +INSERT INTO `sys_role_menu` VALUES (1, 9056); +INSERT INTO `sys_role_menu` VALUES (1, 9057); +INSERT INTO `sys_role_menu` VALUES (1, 9059); +INSERT INTO `sys_role_menu` VALUES (1, 9060); +INSERT INTO `sys_role_menu` VALUES (1, 9061); +INSERT INTO `sys_role_menu` VALUES (1, 9062); +INSERT INTO `sys_role_menu` VALUES (1, 9063); +INSERT INTO `sys_role_menu` VALUES (1, 9064); +INSERT INTO `sys_role_menu` VALUES (1, 9065); INSERT INTO `sys_role_menu` VALUES (2, 4000); -INSERT INTO `sys_role_menu` VALUES (2, 9999); +INSERT INTO `sys_role_menu` VALUES (2, 4001); +INSERT INTO `sys_role_menu` VALUES (2, 4002); COMMIT; -- ---------------------------- @@ -529,28 +632,56 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_user`; CREATE TABLE `sys_user` ( - `user_id` bigint NOT NULL, - `username` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名', - `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码', - `salt` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '随机盐', - `phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '简介', - `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '头像', - `dept_id` bigint DEFAULT NULL COMMENT '部门ID', - `lock_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '0-正常,9-锁定', - `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '0-正常,1-删除', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_time` datetime DEFAULT NULL COMMENT '修改时间', - `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建者', - `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`user_id`), - KEY `user_idx1_username` (`username`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户表'; + `user_id` bigint NOT NULL COMMENT '用户ID', + `username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户名', + `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '密码', + `salt` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '盐值', + `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '电话号码', + `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '头像', + `nickname` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '昵称', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '姓名', + `email` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '邮箱地址', + `dept_id` bigint DEFAULT NULL COMMENT '所属部门ID', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + `lock_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '锁定标记,0未锁定,9已锁定', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记,0未删除,1已删除', + `wx_openid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '微信登录openId', + `mini_openid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '小程序openId', + `qq_openid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'QQ openId', + `gitee_login` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '码云标识', + `osc_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '开源中国标识', + `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '所属租户ID', + PRIMARY KEY (`user_id`) USING BTREE, + KEY `user_wx_openid` (`wx_openid`) USING BTREE, + KEY `user_qq_openid` (`qq_openid`) USING BTREE, + KEY `user_idx1_username` (`username`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户表'; -- ---------------------------- -- Records of sys_user -- ---------------------------- BEGIN; -INSERT INTO `sys_user` VALUES (1, 'admin', '$2a$10$RpFJjxYiXdEsAGnWp/8fsOetMuOON96Ntk/Ym2M/RKRyU0GZseaDC', NULL, '17034642999', '', 1, '0', '0', '2018-04-20 07:15:18', '2019-01-31 14:29:07', NULL, NULL); +INSERT INTO `sys_user` VALUES (1, 'admin', '$2a$10$c/Ae0pRjJtMZg3BnvVpO.eIK6WYWVbKTzqgdy3afR7w.vd.xi3Mgy', '', '17034642999', '/admin/sys-file/s3demo/7ff4ca6b7bf446f3a5a13ac016dc21af.png', '管理员', '管理员', 'pig4cloud@qq.com', 4, ' ', 'admin', '2018-04-20 07:15:18', '2023-07-07 14:55:40', '0', '0', NULL, 'oBxPy5E-v82xWGsfzZVzkD3wEX64', NULL, 'log4j', NULL, 1); +COMMIT; + +-- ---------------------------- +-- Table structure for sys_user_post +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user_post`; +CREATE TABLE `sys_user_post` ( + `user_id` bigint NOT NULL COMMENT '用户ID', + `post_id` bigint NOT NULL COMMENT '岗位ID', + PRIMARY KEY (`user_id`,`post_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户与岗位关联表'; + +-- ---------------------------- +-- Records of sys_user_post +-- ---------------------------- +BEGIN; +INSERT INTO `sys_user_post` VALUES (1, 1); COMMIT; -- ---------------------------- @@ -558,16 +689,17 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `sys_user_role`; CREATE TABLE `sys_user_role` ( - `user_id` bigint NOT NULL, - `role_id` bigint NOT NULL, - PRIMARY KEY (`user_id`,`role_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户角色表'; + `user_id` bigint NOT NULL COMMENT '用户ID', + `role_id` bigint NOT NULL COMMENT '角色ID', + PRIMARY KEY (`user_id`,`role_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户角色表'; -- ---------------------------- -- Records of sys_user_role -- ---------------------------- BEGIN; INSERT INTO `sys_user_role` VALUES (1, 1); +INSERT INTO `sys_user_role` VALUES (1676492190299299842, 2); COMMIT; SET FOREIGN_KEY_CHECKS = 1; diff --git a/db/pig_codegen.sql b/db/pig_codegen.sql index 7f8859f2..df8d6dcf 100644 --- a/db/pig_codegen.sql +++ b/db/pig_codegen.sql @@ -12,18 +12,23 @@ USE `pig_codegen`; -- ---------------------------- DROP TABLE IF EXISTS `gen_datasource_conf`; CREATE TABLE `gen_datasource_conf` ( - `id` bigint NOT NULL, - `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '数据源名称', - `url` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'jdbc-url', - `username` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '用户名', - `password` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '密码', - `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '删除标记', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `create_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建人', - `update_time` datetime DEFAULT NULL COMMENT '修改时间', - `update_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='数据源表'; + `id` bigint NOT NULL COMMENT '主键', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '别名', + `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'jdbcurl', + `username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户名', + `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '密码', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记', + `tenant_id` bigint DEFAULT NULL COMMENT '租户ID', + `ds_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据库类型', + `conf_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '配置类型', + `ds_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据库名称', + `instance` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '实例', + `port` int DEFAULT NULL COMMENT '端口', + `host` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主机', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='数据源表'; -- ---------------------------- -- Records of gen_datasource_conf @@ -32,26 +37,223 @@ BEGIN; COMMIT; -- ---------------------------- --- Table structure for gen_form_conf +-- Table structure for gen_field_type -- ---------------------------- -DROP TABLE IF EXISTS `gen_form_conf`; -CREATE TABLE `gen_form_conf` ( - `id` bigint NOT NULL, - `table_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '表名', - `form_info` json NOT NULL COMMENT '表单信息', - `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '删除标记', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `create_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '创建人', - `update_time` datetime DEFAULT NULL COMMENT '修改时间', - `update_by` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`id`) USING BTREE, - KEY `table_name` (`table_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='表单配置'; +DROP TABLE IF EXISTS `gen_field_type`; +CREATE TABLE `gen_field_type` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `column_type` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字段类型', + `attr_type` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性类型', + `package_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性包名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人', + `del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记', + PRIMARY KEY (`id`), + UNIQUE KEY `column_type` (`column_type`) +) ENGINE=InnoDB AUTO_INCREMENT=1634915190321451010 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='字段类型管理'; -- ---------------------------- --- Records of gen_form_conf +-- Records of gen_field_type +-- ---------------------------- +BEGIN; +INSERT INTO `gen_field_type` VALUES (1, 'datetime', 'LocalDateTime', 'java.time.LocalDateTime', '2023-02-06 08:45:10', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (2, 'date', 'LocalDate', 'java.time.LocalDate', '2023-02-06 08:45:10', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (3, 'tinyint', 'Integer', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (4, 'smallint', 'Integer', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (5, 'mediumint', 'Integer', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (6, 'int', 'Integer', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (7, 'integer', 'Integer', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (8, 'bigint', 'Long', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (9, 'float', 'Float', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (10, 'double', 'Double', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (11, 'decimal', 'BigDecimal', 'java.math.BigDecimal', '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (12, 'bit', 'Boolean', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (13, 'char', 'String', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (14, 'varchar', 'String', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (15, 'tinytext', 'String', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (16, 'text', 'String', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (17, 'mediumtext', 'String', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (18, 'longtext', 'String', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (19, 'timestamp', 'LocalDateTime', 'java.time.LocalDateTime', '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (20, 'NUMBER', 'Integer', NULL, '2023-02-06 08:45:11', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (21, 'BINARY_INTEGER', 'Integer', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (22, 'BINARY_FLOAT', 'Float', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (23, 'BINARY_DOUBLE', 'Double', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (24, 'VARCHAR2', 'String', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (25, 'NVARCHAR', 'String', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (26, 'NVARCHAR2', 'String', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (27, 'CLOB', 'String', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (28, 'int8', 'Long', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (29, 'int4', 'Integer', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (30, 'int2', 'Integer', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (31, 'numeric', 'BigDecimal', 'java.math.BigDecimal', '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +INSERT INTO `gen_field_type` VALUES (32, 'json', 'String', NULL, '2023-02-06 08:45:12', NULL, NULL, NULL, '0'); +COMMIT; + +-- ---------------------------- +-- Table structure for gen_group +-- ---------------------------- +DROP TABLE IF EXISTS `gen_group`; +CREATE TABLE `gen_group` ( + `id` bigint NOT NULL, + `group_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分组名称', + `group_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分组描述', + `tenant_id` bigint NOT NULL COMMENT '租户ID', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + `create_time` datetime DEFAULT NULL COMMENT '创建人', + `update_time` datetime DEFAULT NULL COMMENT '修改人', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='模板分组'; + +-- ---------------------------- +-- Records of gen_group +-- ---------------------------- +BEGIN; +INSERT INTO `gen_group` VALUES (1, '单表增删改查', '单表增删改查', 1, ' ', 'admin', NULL, '2023-07-07 15:47:51', '0'); +COMMIT; + +-- ---------------------------- +-- Table structure for gen_table +-- ---------------------------- +DROP TABLE IF EXISTS `gen_table`; +CREATE TABLE `gen_table` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `table_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表名', + `class_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '类名', + `db_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据库类型', + `table_comment` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '说明', + `author` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '作者', + `email` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '邮箱', + `package_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '项目包名', + `version` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '项目版本号', + `i18n` tinyint DEFAULT '1' COMMENT '是否生成带有i18n 0 不带有 1带有', + `style` bigint DEFAULT '0' COMMENT '代码风格', + `child_table_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '子表名称', + `main_field` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主表关联键', + `child_field` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '子表关联键', + `generator_type` tinyint DEFAULT NULL COMMENT '生成方式 0:zip压缩包 1:自定义目录', + `backend_path` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '后端生成路径', + `frontend_path` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '前端生成路径', + `module_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模块名', + `function_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '功能名', + `form_layout` tinyint DEFAULT NULL COMMENT '表单布局 1:一列 2:两列', + `ds_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据源ID', + `baseclass_id` bigint DEFAULT NULL COMMENT '基类ID', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `table_name` (`table_name`,`ds_name`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1642522692257112067 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='代码生成表'; + +-- ---------------------------- +-- Records of gen_table -- ---------------------------- BEGIN; COMMIT; +-- ---------------------------- +-- Table structure for gen_table_column +-- ---------------------------- +DROP TABLE IF EXISTS `gen_table_column`; +CREATE TABLE `gen_table_column` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `ds_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据源名称', + `table_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表名称', + `field_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字段名称', + `field_type` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字段类型', + `field_comment` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字段说明', + `attr_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性名', + `attr_type` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性类型', + `package_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性包名', + `sort` int DEFAULT NULL COMMENT '排序', + `auto_fill` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '自动填充 DEFAULT、INSERT、UPDATE、INSERT_UPDATE', + `primary_pk` tinyint DEFAULT NULL COMMENT '主键 0:否 1:是', + `base_field` tinyint DEFAULT NULL COMMENT '基类字段 0:否 1:是', + `form_item` tinyint DEFAULT NULL COMMENT '表单项 0:否 1:是', + `form_required` tinyint DEFAULT NULL COMMENT '表单必填 0:否 1:是', + `form_type` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表单类型', + `form_validator` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表单效验', + `grid_item` tinyint DEFAULT NULL COMMENT '列表项 0:否 1:是', + `grid_sort` tinyint DEFAULT NULL COMMENT '列表排序 0:否 1:是', + `query_item` tinyint DEFAULT NULL COMMENT '查询项 0:否 1:是', + `query_type` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '查询方式', + `query_form_type` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '查询表单类型', + `field_dict` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典类型', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='代码生成表字段'; + +-- ---------------------------- +-- Records of gen_table_column +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for gen_template +-- ---------------------------- +DROP TABLE IF EXISTS `gen_template`; +CREATE TABLE `gen_template` ( + `id` bigint NOT NULL COMMENT '主键', + `template_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '模板名称', + `generator_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '模板路径', + `template_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '模板描述', + `template_code` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '模板代码', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新', + `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记', + `tenant_id` bigint NOT NULL COMMENT '租户ID', + `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', + `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='模板'; + +-- ---------------------------- +-- Records of gen_template +-- ---------------------------- +BEGIN; +INSERT INTO `gen_template` VALUES (1, 'i18n英文模板', '${frontendPath}/src/views/${moduleName}/${functionName}/i18n/en.ts', 'i18n英文模板', 'export default {\n ${functionName}: {\n index: \'#\',\n import${className}Tip: \'import ${ClassName}\',\n#foreach($field in $fieldList)\n ${field.attrName}: \'${field.attrName}\',\n#end\n#foreach($field in $fieldList)\n input$str.pascalCase(${field.attrName})Tip: \'input ${field.attrName}\',\n#end\n }\n}', '2023-02-23 01:20:25', '2023-07-07 15:47:06', '0', 1, '', 'admin'); +INSERT INTO `gen_template` VALUES (2, 'i18n中文模板', '${frontendPath}/src/views/${moduleName}/${functionName}/i18n/zh-cn.ts', 'i18n中文模板', 'export default {\n ${functionName}: {\n index: \'#\',\n import${className}Tip: \'导入${tableComment}\',\n#foreach($field in $fieldList)\n ${field.attrName}: \'#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\',\n#end\n#foreach($field in $fieldList)\n input$str.pascalCase(${field.attrName})Tip: \'请输入#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\',\n#end\n }\n}', '2023-02-23 01:20:40', '2023-07-07 15:47:09', '0', 1, '', 'admin'); +INSERT INTO `gen_template` VALUES (3, 'Controller', '${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java', '后台Controller', 'package ${package}.${moduleName}.controller;\n\n#if($queryList)\nimport cn.hutool.core.util.StrUtil;\n#end\nimport cn.hutool.core.collection.CollUtil;\nimport com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport com.pig4cloud.pigx.common.core.util.R;\nimport com.pig4cloud.pigx.common.log.annotation.SysLog;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.security.access.prepost.PreAuthorize;\nimport com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;\nimport io.swagger.v3.oas.annotations.security.SecurityRequirement;\nimport org.springdoc.api.annotations.ParameterObject;\nimport org.springframework.http.HttpHeaders;\nimport io.swagger.v3.oas.annotations.tags.Tag;\nimport io.swagger.v3.oas.annotations.Operation;\nimport lombok.RequiredArgsConstructor;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@RestController\n@RequiredArgsConstructor\n@RequestMapping(\"/${functionName}\" )\n@Tag(description = \"${functionName}\" , name = \"${tableComment}管理\" )\n@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)\npublic class ${ClassName}Controller {\n\n private final ${ClassName}Service ${className}Service;\n\n /**\n * 分页查询\n * @param page 分页对象\n * @param ${className} ${tableComment}\n * @return\n */\n @Operation(summary = \"分页查询\" , description = \"分页查询\" )\n @GetMapping(\"/page\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R get${ClassName}Page(@ParameterObject Page page,@ParameterObject ${ClassName}Entity ${className}) {\n LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();\n#foreach ($field in $queryList)\n#set($getAttrName=$str.getProperty($field.attrName))\n#set($var=\"${className}.$getAttrName()\")\n#if($field.queryType == \'=\')\n wrapper.eq(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'like\' )\n wrapper.like(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'!-\' )\n wrapper.ne(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>\' )\n wrapper.gt(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<\' )\n wrapper.lt(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>=\' )\n wrapper.ge(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<=\' )\n wrapper.le(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'left like\' )\n wrapper.likeLeft(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'right like\' )\n wrapper.likeRight(StrUtil.isNotBlank($var),${ClassName}Entity::$getAttrName,$var);\n#end\n#end\n return R.ok(${className}Service.page(page, wrapper));\n }\n\n\n /**\n * 通过id查询${tableComment}\n * @param ${pk.attrName} id\n * @return R\n */\n @Operation(summary = \"通过id查询\" , description = \"通过id查询\" )\n @GetMapping(\"/{${pk.attrName}}\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R getById(@PathVariable(\"${pk.attrName}\" ) ${pk.attrType} ${pk.attrName}) {\n return R.ok(${className}Service.getById(${pk.attrName}));\n }\n\n /**\n * 新增${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"新增${tableComment}\" , description = \"新增${tableComment}\" )\n @SysLog(\"新增${tableComment}\" )\n @PostMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_add\')\" )\n public R save(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.save(${className}));\n }\n\n /**\n * 修改${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"修改${tableComment}\" , description = \"修改${tableComment}\" )\n @SysLog(\"修改${tableComment}\" )\n @PutMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_edit\')\" )\n public R updateById(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.updateById(${className}));\n }\n\n /**\n * 通过id删除${tableComment}\n * @param ids ${pk.attrName}列表\n * @return R\n */\n @Operation(summary = \"通过id删除${tableComment}\" , description = \"通过id删除${tableComment}\" )\n @SysLog(\"通过id删除${tableComment}\" )\n @DeleteMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_del\')\" )\n public R removeById(@RequestBody ${pk.attrType}[] ids) {\n return R.ok(${className}Service.removeBatchByIds(CollUtil.toList(ids)));\n }\n\n\n /**\n * 导出excel 表格\n * @param ${className} 查询条件\n * @return excel 文件流\n */\n @ResponseExcel\n @GetMapping(\"/export\")\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_export\')\" )\n public List<${ClassName}Entity> export(${ClassName}Entity ${className}) {\n return ${className}Service.list(Wrappers.query(${className}));\n }\n}', '2023-02-23 01:16:17', '2023-06-06 17:20:06', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (4, 'Service', '${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java', 'Service', 'package ${package}.${moduleName}.service;\n\n#if($ChildClassName)\nimport com.github.yulichang.extension.mapping.base.MPJDeepService;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\n#else\nimport com.baomidou.mybatisplus.extension.service.IService;\n#end\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\n\n#if($ChildClassName)\npublic interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity> {\n Boolean saveDeep(${ClassName}Entity ${className});\n\n Boolean updateDeep(${ClassName}Entity ${className});\n\n Boolean removeDeep(Long[] ids);\n\n Boolean removeChild(Long[] ids);\n#else\npublic interface ${ClassName}Service extends IService<${ClassName}Entity> {\n#end\n\n}', '2023-02-23 01:16:53', '2023-06-04 10:35:25', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (5, 'ServiceImpl', '${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java', 'ServiceImpl', 'package ${package}.${moduleName}.service.impl;\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.mapper.${ClassName}Mapper;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.stereotype.Service;\n#if($ChildClassName)\nimport cn.hutool.core.collection.CollUtil;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\nimport ${package}.${moduleName}.mapper.${ChildClassName}Mapper;\nimport org.springframework.transaction.annotation.Transactional;\nimport lombok.RequiredArgsConstructor;\nimport java.util.Objects;\n#end\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Service\n#if($ChildClassName)\n@RequiredArgsConstructor\n#end\npublic class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> implements ${ClassName}Service {\n#if($ChildClassName)\n private final ${ChildClassName}Mapper ${childClassName}Mapper;\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean saveDeep(${ClassName}Entity ${className}) {\n baseMapper.insert(${className});\n for (${ChildClassName}Entity ${childClassName} : ${className}.get${ChildClassName}List()) {\n ${childClassName}.$str.setProperty($childField)(${className}.$str.getProperty($mainField)());\n ${childClassName}Mapper.insert( ${childClassName});\n }\n\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean updateDeep(${ClassName}Entity ${className}) {\n baseMapper.updateById(${className});\n for (${ChildClassName}Entity ${childClassName} : ${className}.get${ChildClassName}List()) {\n#foreach ($field in $childFieldList)\n#if($field.primaryPk)\n#set($getChildPkName=$str.getProperty($field.attrName))\n#end\n#end\n if (Objects.isNull(${childClassName}.$getChildPkName())) {\n ${childClassName}.$str.setProperty($childField)(${className}.getId());\n ${childClassName}Mapper.insert(${childClassName});\n } else {\n ${childClassName}Mapper.updateById(${childClassName});\n }\n }\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean removeDeep(Long[] ids) {\n baseMapper.deleteBatchIds(CollUtil.toList(ids));\n ${childClassName}Mapper.delete(Wrappers.<${ChildClassName}Entity>lambdaQuery().in(${ChildClassName}Entity::$str.getProperty($childField), ids));\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean removeChild(Long[] ids) {\n ${childClassName}Mapper.deleteBatchIds(CollUtil.toList(ids));\n return Boolean.TRUE;\n }\n#end\n}', '2023-02-23 01:17:36', '2023-06-04 10:35:21', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (6, '实体', '${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java', 'Entity', 'package ${package}.${moduleName}.entity;\n\nimport com.baomidou.mybatisplus.annotation.*;\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport io.swagger.v3.oas.annotations.media.Schema;\nimport lombok.Data;\nimport lombok.EqualsAndHashCode;\n#foreach($import in $importList)\nimport $import;\n#end\n#if($ChildClassName)\nimport com.alibaba.excel.annotation.ExcelIgnore;\nimport com.github.yulichang.annotation.EntityMapping;\nimport java.util.List;\n#end\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Data\n@TableName(\"${tableName}\")\n@EqualsAndHashCode(callSuper = true)\n@Schema(description = \"${tableComment}\")\npublic class ${ClassName}Entity extends Model<${ClassName}Entity> {\n\n#foreach ($field in $fieldList)\n#if(${field.fieldComment})#set($comment=${field.fieldComment})#else #set($comment=${field.attrName})#end\n\n /**\n * $comment\n */\n#if($field.primaryPk)\n @TableId(type = IdType.ASSIGN_ID)\n#end\n#if($field.autoFill == \'INSERT\')\n @TableField(fill = FieldFill.INSERT)\n#elseif($field.autoFill == \'INSERT_UPDATE\')\n @TableField(fill = FieldFill.INSERT_UPDATE)\n#elseif($field.autoFill == \'UPDATE\')\n @TableField(fill = FieldFill.UPDATE)\n#end\n#if($field.fieldName == \'del_flag\')\n @TableLogic\n @TableField(fill = FieldFill.INSERT)\n#end\n @Schema(description=\"$comment\"#if($field.hidden),hidden=$field.hidden#end)\n private $field.attrType $field.attrName;\n#end\n#if($ChildClassName)\n @ExcelIgnore\n @TableField(exist = false)\n @EntityMapping(thisField = \"$mainField\", joinField = \"$childField\")\n private List<${ChildClassName}Entity> ${childClassName}List;\n#end\n}', '2023-02-23 01:17:53', '2023-06-04 10:45:15', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (7, 'Mapper', '${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java', 'Mapper', 'package ${package}.${moduleName}.mapper;\n\nimport com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;\n#if($ChildClassName)\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\n#else\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\n#end\nimport org.apache.ibatis.annotations.Mapper;\n\n@Mapper\n#if($ChildClassName)\npublic interface ${ChildClassName}Mapper extends PigxBaseMapper<${ChildClassName}Entity> {\n#else\npublic interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {\n#end\n\n}', '2023-02-23 01:18:18', '2023-06-04 10:41:36', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (8, 'Mapper.xml', '${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml', 'Mapper.xml', '\n\n\n\n\n \n#foreach ($field in $fieldList)\n #if($field.primaryPk)\n \n #end\n #if(!$field.primaryPk)\n \n #end\n#end\n \n', '2023-02-23 01:18:35', '2023-06-04 10:34:56', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (9, '权限菜单', '${backendPath}/menu/${functionName}_menu.sql', 'menu.sql', '-- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点-1 , 默认租户 1\n#set($menuId=${dateTool.getSystemTime()})\n\n -- 菜单SQL\n insert into `sys_menu` ( `menu_id`,`parent_id`, `path`, `permission`, `menu_type`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)\n values (${menuId}, \'-1\', \'/${moduleName}/${functionName}/index\', \'\', \'0\', \'icon-bangzhushouji\', \'0\', null , \'8\', null , \'${tableComment}管理\', 1);\n\n-- 按钮父菜单ID\n set @parentId = @@identity;\n\n-- 菜单对应按钮SQL\n insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)\n values (${math.add($menuId,1)},${menuId}, \'${moduleName}_${functionName}_view\', \'1\', null, \'1\', \'0\', null, \'0\', null, \'${tableComment}查看\', 1);\n\n insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)\n values (${math.add($menuId,2)},${menuId}, \'${moduleName}_${functionName}_add\', \'1\', null, \'1\', \'0\', null, \'1\', null, \'${tableComment}新增\', 1);\n\n insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)\n values (${math.add($menuId,3)},${menuId}, \'${moduleName}_${functionName}_edit\', \'1\', null, \'1\', \'0\', null, \'2\', null, \'${tableComment}修改\', 1);\n\n insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)\n values (${math.add($menuId,4)},${menuId}, \'${moduleName}_${functionName}_del\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'${tableComment}删除\', 1);\n\n insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)\n values (${math.add($menuId,5)},${menuId}, \'${moduleName}_${functionName}_export\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'导入导出\', 1);', '2023-02-23 01:19:08', '2023-06-04 10:34:26', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (10, 'api.ts', '${frontendPath}/src/api/${moduleName}/${functionName}.ts', 'api.ts', 'import request from \"/@/utils/request\"\n\nexport function fetchList(query?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}/page\',\n method: \'get\',\n params: query\n })\n}\n\nexport function addObj(obj?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'post\',\n data: obj\n })\n}\n\nexport function getObj(id?: string) {\n return request({\n url: \'/${moduleName}/${functionName}/\' + id,\n method: \'get\'\n })\n}\n\nexport function delObjs(ids?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'delete\',\n data: ids\n })\n}\n\nexport function putObj(obj?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'put\',\n data: obj\n })\n}\n\n#if($ChildClassName)\nexport function delChildObj(ids?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}/child\',\n method: \'delete\',\n data: ids\n })\n}\n#end', '2023-02-23 01:19:23', '2023-06-04 10:34:17', '0', 1, ' ', ' '); +INSERT INTO `gen_template` VALUES (11, '表格', '${frontendPath}/src/views/${moduleName}/${functionName}/index.vue', '表格不含i18n', '\n\n', '2023-02-23 01:19:35', '2023-06-04 11:24:15', '0', 1, '', 'admin'); +INSERT INTO `gen_template` VALUES (12, '表单', '${frontendPath}/src/views/${moduleName}/${functionName}/form.vue', '表单不含i18n', '\n\n', '2023-02-23 01:19:48', '2023-07-06 10:20:57', '0', 1, '', 'admin'); +COMMIT; + +-- ---------------------------- +-- Table structure for gen_template_group +-- ---------------------------- +DROP TABLE IF EXISTS `gen_template_group`; +CREATE TABLE `gen_template_group` ( + `group_id` bigint NOT NULL COMMENT '分组id', + `template_id` bigint NOT NULL COMMENT '模板id', + PRIMARY KEY (`group_id`,`template_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='模板分组关联表'; + +-- ---------------------------- +-- Records of gen_template_group +-- ---------------------------- +BEGIN; +INSERT INTO `gen_template_group` VALUES (1, 1); +INSERT INTO `gen_template_group` VALUES (1, 2); +INSERT INTO `gen_template_group` VALUES (1, 3); +INSERT INTO `gen_template_group` VALUES (1, 4); +INSERT INTO `gen_template_group` VALUES (1, 5); +INSERT INTO `gen_template_group` VALUES (1, 6); +INSERT INTO `gen_template_group` VALUES (1, 7); +INSERT INTO `gen_template_group` VALUES (1, 8); +INSERT INTO `gen_template_group` VALUES (1, 9); +INSERT INTO `gen_template_group` VALUES (1, 10); +INSERT INTO `gen_template_group` VALUES (1, 11); +INSERT INTO `gen_template_group` VALUES (1, 12); +COMMIT; + SET FOREIGN_KEY_CHECKS = 1; diff --git a/db/pig_config.sql b/db/pig_config.sql index 1ea0caf5..784b769d 100644 --- a/db/pig_config.sql +++ b/db/pig_config.sql @@ -37,13 +37,13 @@ CREATE TABLE `config_info` ( -- Records of config_info -- ---------------------------- BEGIN; -INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', '# 配置文件加密根密码\njasypt:\n encryptor:\n password: pig\n algorithm: PBEWithMD5AndDES\n iv-generator-classname: org.jasypt.iv.NoIvGenerator\n \n# Spring 相关\nspring:\n cache:\n type: redis\n redis:\n host: pig-redis\n cloud:\n sentinel:\n eager: true\n transport:\n dashboard: pig-sentinel:5003\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \"*\" \n endpoint:\n health:\n show-details: ALWAYS\n\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# mybaits-plus配置\nmybatis-plus:\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n table-underline: true\n logic-delete-value: 1\n logic-not-delete-value: 0\n configuration:\n map-underscore-to-camel-case: true\n\n# swagger 配置\nswagger:\n enabled: true\n title: Pig Swagger API\n gateway: http://${GATEWAY_HOST:pig-gateway}:${GATEWAY-PORT:9999}\n token-url: ${swagger.gateway}/auth/oauth2/token\n scope: server', 'c9b41bce3b5ce5802d6592cab001f791', '2022-05-08 12:10:37', '2023-05-26 13:57:59', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', '', ''); +INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', '# 配置文件加密根密码\njasypt:\n encryptor:\n password: pig\n algorithm: PBEWithMD5AndDES\n iv-generator-classname: org.jasypt.iv.NoIvGenerator\n \n# Spring 相关\nspring:\n cache:\n type: redis\n data:\n redis:\n host: pig-redis\n cloud:\n sentinel:\n eager: true\n transport:\n dashboard: pig-sentinel:5003\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \"*\" \n endpoint:\n health:\n show-details: ALWAYS\n\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# mybaits-plus配置\nmybatis-plus:\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n table-underline: true\n logic-delete-value: 1\n logic-not-delete-value: 0\n type-handlers-package: com.pig4cloud.pig.common.mybatis.handler\n configuration:\n map-underscore-to-camel-case: true\n\n# swagger 配置\nswagger:\n enabled: true\n title: Pig Swagger API\n gateway: http://${GATEWAY_HOST:pig-gateway}:${GATEWAY-PORT:9999}\n token-url: ${swagger.gateway}/auth/oauth2/token\n scope: server\n services:\n pig-upms-biz: admin\n pig-codegen: gen', '1a4bfc475f9e6ddfd39e580d6f834180', '2022-05-08 12:10:37', '2023-07-05 07:16:04', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', '', ''); INSERT INTO `config_info` VALUES (2, 'pig-auth-dev.yml', 'DEFAULT_GROUP', '# 数据源\nspring:\n freemarker:\n allow-request-override: false\n allow-session-override: false\n cache: true\n charset: UTF-8\n check-template-location: true\n content-type: text/html\n enabled: true\n expose-request-attributes: false\n expose-session-attributes: false\n expose-spring-macro-helpers: true\n prefer-file-system-access: true\n suffix: .ftl\n template-loader-path: classpath:/templates/', '74f53b71c7799aa754da75662378b93c', '2022-05-08 12:10:37', '2022-06-04 14:15:35', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', '', ''); -INSERT INTO `config_info` VALUES (3, 'pig-codegen-dev.yml', 'DEFAULT_GROUP', '## spring security 配置1\nsecurity:\n oauth2:\n client:\n client-id: ENC(27v1agvAug87ANOVnbKdsw==)\n client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)\n scope: server\n\n# 数据源配置\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n resources:\n static-locations: classpath:/static/,classpath:/views/\n', '6c6e48b793671dc2a0adffe2e2c27fb0', '2022-05-08 12:10:37', '2022-12-15 23:05:35', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', '', ''); -INSERT INTO `config_info` VALUES (4, 'pig-gateway-dev.yml', 'DEFAULT_GROUP', 'spring:\n cloud:\n gateway:\n locator:\n enabled: true\n routes:\n # 认证中心\n - id: pig-auth\n uri: lb://pig-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - ValidateCodeGatewayFilter\n # 前端密码解密\n - PasswordDecoderFilter\n #UPMS 模块\n - id: pig-upms-biz\n uri: lb://pig-upms-biz\n predicates:\n - Path=/admin/**\n filters:\n # 限流配置\n - name: RequestRateLimiter\n args:\n key-resolver: \'#{@remoteAddrKeyResolver}\'\n redis-rate-limiter.replenishRate: 100\n redis-rate-limiter.burstCapacity: 200\n # 代码生成模块\n - id: pig-codegen\n uri: lb://pig-codegen\n predicates:\n - Path=/gen/**\n # 固定路由转发配置 无修改\n - id: openapi\n uri: lb://pig-gateway\n predicates:\n - Path=/v3/api-docs/**\n filters:\n - RewritePath=/v3/api-docs/(?.*), /$\\{path}/$\\{path}/v3/api-docs\n\ngateway:\n encode-key: \'thanks,pig4cloud\'\n ignore-clients:\n - test\n - client', '000988cf0102382d3f23df35027b47fd', '2022-05-08 12:10:37', '2022-06-07 14:00:11', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', '', ''); +INSERT INTO `config_info` VALUES (3, 'pig-codegen-dev.yml', 'DEFAULT_GROUP', '# 数据源配置\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n resources:\n static-locations: classpath:/static/,classpath:/views/\n', 'cf786dbe3b07074fc187bf2eab3266b1', '2022-05-08 12:10:37', '2023-01-28 14:05:36', '', '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', ''); +INSERT INTO `config_info` VALUES (4, 'pig-gateway-dev.yml', 'DEFAULT_GROUP', 'spring:\n cloud:\n gateway:\n locator:\n enabled: true\n routes:\n # 认证中心\n - id: pig-auth\n uri: lb://pig-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - ValidateCodeGatewayFilter\n # 前端密码解密\n - PasswordDecoderFilter\n #UPMS 模块\n - id: pig-upms-biz\n uri: lb://pig-upms-biz\n predicates:\n - Path=/admin/**\n filters:\n # 限流配置\n - name: RequestRateLimiter\n args:\n key-resolver: \'#{@remoteAddrKeyResolver}\'\n redis-rate-limiter.replenishRate: 100\n redis-rate-limiter.burstCapacity: 200\n # 代码生成模块\n - id: pig-codegen\n uri: lb://pig-codegen\n predicates:\n - Path=/gen/**\n # 代码生成模块\n - id: pig-quartz\n uri: lb://pig-quartz\n predicates:\n - Path=/job/**\n # 固定路由转发配置 无修改\n - id: openapi\n uri: lb://pig-gateway\n predicates:\n - Path=/v3/api-docs/**\n filters:\n - RewritePath=/v3/api-docs/(?.*), /$\\{path}/$\\{path}/v3/api-docs\n\ngateway:\n encode-key: \'thanks,pig4cloud\'\n ignore-clients:\n - test\n - client', 'cde041935aeeb2a5f59bf3b56d78f56d', '2022-05-08 12:10:37', '2023-07-05 13:50:59', 'nacos', '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', ''); INSERT INTO `config_info` VALUES (5, 'pig-monitor-dev.yml', 'DEFAULT_GROUP', 'spring:\n autoconfigure:\n exclude: com.pig4cloud.pig.common.core.config.JacksonConfiguration\n # 安全配置\n security:\n user:\n name: ENC(8Hk2ILNJM8UTOuW/Xi75qg==) # pig\n password: ENC(o6cuPFfUevmTbkmBnE67Ow====) # pig\n', '650bdfa15f60f3faa84dfe6e6878b8cf', '2022-05-08 12:10:37', '2022-05-08 12:10:37', NULL, '127.0.0.1', '', '', NULL, NULL, NULL, 'yaml', NULL, ''); -INSERT INTO `config_info` VALUES (6, 'pig-upms-biz-dev.yml', 'DEFAULT_GROUP', 'security:\n oauth2:\n client:\n client-id: ENC(imENTO7M8bLO38LFSIxnzw==)\n client-secret: ENC(i3cDFhs26sa2Ucrfz2hnQw==)\n scope: server\n\n# 数据源\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n\n# 文件上传相关 支持阿里云、华为云、腾讯、minio\noss:\n endpoint: http://minio.pig4cloud.com\n accessKey: lengleng\n secretKey: lengleng\n bucket-name: tmp', '107614b40932e8237787b769e0937ed2', '2022-05-08 12:10:37', '2022-05-08 12:10:37', NULL, '127.0.0.1', '', '', NULL, NULL, NULL, 'yaml', NULL, ''); -INSERT INTO `config_info` VALUES (7, 'pig-xxl-job-admin-dev.yml', 'DEFAULT_GROUP', '# xxl\nxxl:\n job:\n accessToken: default_token\n i18n: zh_CN\n logretentiondays: 30\n triggerpool:\n fast.max: 200\n slow.max: 200\n\n# mybatis\nmybatis:\n mapper-locations: classpath:/mybatis-mapper/*Mapper.xml\n\nspring:\n datasource:\n url: jdbc:mysql://${MYSQL_HOST:pig-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pig_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n mvc:\n static-path-pattern: /static/**\n freemarker:\n suffix: .ftl\n request-context-attribute: request\n settings:\n number_format: 0.##########\n mail:\n host: smtp.mxhichina.com\n port: 465\n from: xxxx@gitee.wang\n username: xxxx@gitee.wang\n password: xxxx\n properties:\n mail:\n smtp:\n auth: true\n ssl.enable: true\n starttls.enable: false\n required: false\n# spring boot admin 配置\n\nmanagement:\n health:\n mail:\n enabled: false\n endpoints:\n web:\n exposure:\n include: \'*\'\n endpoint:\n health:\n show-details: ALWAYS\n\n', 'b67cbbd37c8b42cdc6521780b3ed742a', '2022-11-27 17:23:42', '2022-11-27 17:28:01', 'nacos', '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', ''); +INSERT INTO `config_info` VALUES (6, 'pig-upms-biz-dev.yml', 'DEFAULT_GROUP', '# 数据源\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n\n# 文件上传相关 支持阿里云、华为云、腾讯、minio\nfile:\n bucketName: s3demo \n local:\n enable: true\n base-path: /Users/lengleng/Downloads/img', '48f8db128aeb5debb331bae49ff37908', '2022-05-08 12:10:37', '2023-07-07 14:44:09', 'nacos', '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', ''); +INSERT INTO `config_info` VALUES (7, 'pig-quartz-dev.yml', 'DEFAULT_GROUP', 'spring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n quartz:\n #相关属性配置\n properties:\n org:\n quartz:\n scheduler:\n instanceName: clusteredScheduler\n instanceId: AUTO\n jobStore:\n class: org.springframework.scheduling.quartz.LocalDataSourceJobStore\n driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate\n tablePrefix: QRTZ_\n isClustered: true\n clusterCheckinInterval: 10000\n useProperties: false\n threadPool:\n class: org.quartz.simpl.SimpleThreadPool\n threadCount: 50\n threadPriority: 5\n threadsInheritContextClassLoaderOfInitializingThread: true\n #数据库方式\n job-store-type: jdbc\n #初始化表结构\n #jdbc:\n #initialize-schema: never\n web:\n resources:\n static-locations: classpath:/static/,classpath:/views/\n\n', '3e404971f6f49aa3ff22323b227debe0', '2023-07-02 12:24:33', '2023-07-02 13:46:04', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', '', ''); COMMIT; -- ---------------------------- diff --git a/db/pig_job.sql b/db/pig_job.sql new file mode 100644 index 00000000..d48f2106 --- /dev/null +++ b/db/pig_job.sql @@ -0,0 +1,502 @@ +DROP DATABASE IF EXISTS `pig_job`; + +CREATE DATABASE `pig_job` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; + +USE pig_job; + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for qrtz_blob_triggers +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_blob_triggers`; +CREATE TABLE `qrtz_blob_triggers` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `trigger_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `trigger_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `blob_data` blob, + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`) USING BTREE, + CONSTRAINT `qrtz_blob_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_blob_triggers +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_calendars +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_calendars`; +CREATE TABLE `qrtz_calendars` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `calendar_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `calendar` blob NOT NULL, + PRIMARY KEY (`sched_name`,`calendar_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_calendars +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_cron_triggers +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_cron_triggers`; +CREATE TABLE `qrtz_cron_triggers` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `trigger_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `trigger_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `cron_expression` varchar(200) CHARACTER SET utf8 NOT NULL, + `time_zone_id` varchar(80) CHARACTER SET utf8 DEFAULT NULL, + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`) USING BTREE, + CONSTRAINT `qrtz_cron_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_cron_triggers +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_fired_triggers +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_fired_triggers`; +CREATE TABLE `qrtz_fired_triggers` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `entry_id` varchar(95) CHARACTER SET utf8 NOT NULL, + `trigger_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `trigger_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `instance_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `fired_time` bigint NOT NULL, + `sched_time` bigint NOT NULL, + `priority` int NOT NULL, + `state` varchar(16) CHARACTER SET utf8 NOT NULL, + `job_name` varchar(200) CHARACTER SET utf8 DEFAULT NULL, + `job_group` varchar(200) CHARACTER SET utf8 DEFAULT NULL, + `is_nonconcurrent` varchar(1) CHARACTER SET utf8 DEFAULT NULL, + `requests_recovery` varchar(1) CHARACTER SET utf8 DEFAULT NULL, + PRIMARY KEY (`sched_name`,`entry_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_fired_triggers +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_job_details +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_job_details`; +CREATE TABLE `qrtz_job_details` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `job_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `job_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `description` varchar(250) CHARACTER SET utf8 DEFAULT NULL, + `job_class_name` varchar(250) CHARACTER SET utf8 NOT NULL, + `is_durable` varchar(1) CHARACTER SET utf8 NOT NULL, + `is_nonconcurrent` varchar(1) CHARACTER SET utf8 NOT NULL, + `is_update_data` varchar(1) CHARACTER SET utf8 NOT NULL, + `requests_recovery` varchar(1) CHARACTER SET utf8 NOT NULL, + `job_data` blob, + PRIMARY KEY (`sched_name`,`job_name`,`job_group`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_job_details +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_locks +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_locks`; +CREATE TABLE `qrtz_locks` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `lock_name` varchar(40) CHARACTER SET utf8 NOT NULL, + PRIMARY KEY (`sched_name`,`lock_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_locks +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_paused_trigger_grps +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_paused_trigger_grps`; +CREATE TABLE `qrtz_paused_trigger_grps` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `trigger_group` varchar(200) CHARACTER SET utf8 NOT NULL, + PRIMARY KEY (`sched_name`,`trigger_group`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_paused_trigger_grps +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_scheduler_state +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_scheduler_state`; +CREATE TABLE `qrtz_scheduler_state` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `instance_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `last_checkin_time` bigint NOT NULL, + `checkin_interval` bigint NOT NULL, + PRIMARY KEY (`sched_name`,`instance_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_scheduler_state +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_simple_triggers +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_simple_triggers`; +CREATE TABLE `qrtz_simple_triggers` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `trigger_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `trigger_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `repeat_count` bigint NOT NULL, + `repeat_interval` bigint NOT NULL, + `times_triggered` bigint NOT NULL, + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`) USING BTREE, + CONSTRAINT `QRTZ_SIMPLE_TRIGGERS_IBFK_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_simple_triggers +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_simprop_triggers +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_simprop_triggers`; +CREATE TABLE `qrtz_simprop_triggers` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `trigger_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `trigger_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `str_prop_1` varchar(512) CHARACTER SET utf8 DEFAULT NULL, + `str_prop_2` varchar(512) CHARACTER SET utf8 DEFAULT NULL, + `str_prop_3` varchar(512) CHARACTER SET utf8 DEFAULT NULL, + `int_prop_1` int DEFAULT NULL, + `int_prop_2` int DEFAULT NULL, + `long_prop_1` bigint DEFAULT NULL, + `long_prop_2` bigint DEFAULT NULL, + `dec_prop_1` decimal(13,4) DEFAULT NULL, + `dec_prop_2` decimal(13,4) DEFAULT NULL, + `bool_prop_1` varchar(1) CHARACTER SET utf8 DEFAULT NULL, + `bool_prop_2` varchar(1) CHARACTER SET utf8 DEFAULT NULL, + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`) USING BTREE, + CONSTRAINT `QRTZ_SIMPROP_TRIGGERS_IBFK_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_simprop_triggers +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for qrtz_triggers +-- ---------------------------- +DROP TABLE IF EXISTS `qrtz_triggers`; +CREATE TABLE `qrtz_triggers` ( + `sched_name` varchar(120) CHARACTER SET utf8 NOT NULL, + `trigger_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `trigger_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `job_name` varchar(200) CHARACTER SET utf8 NOT NULL, + `job_group` varchar(200) CHARACTER SET utf8 NOT NULL, + `description` varchar(250) CHARACTER SET utf8 DEFAULT NULL, + `next_fire_time` bigint DEFAULT NULL, + `prev_fire_time` bigint DEFAULT NULL, + `priority` int DEFAULT NULL, + `trigger_state` varchar(16) CHARACTER SET utf8 NOT NULL, + `trigger_type` varchar(8) CHARACTER SET utf8 NOT NULL, + `start_time` bigint NOT NULL, + `end_time` bigint DEFAULT NULL, + `calendar_name` varchar(200) CHARACTER SET utf8 DEFAULT NULL, + `misfire_instr` smallint DEFAULT NULL, + `job_data` blob, + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`) USING BTREE, + KEY `sched_name` (`sched_name`,`job_name`,`job_group`) USING BTREE, + CONSTRAINT `qrtz_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `job_name`, `job_group`) REFERENCES `qrtz_job_details` (`sched_name`, `job_name`, `job_group`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of qrtz_triggers +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for sys_job +-- ---------------------------- +DROP TABLE IF EXISTS `sys_job`; +CREATE TABLE `sys_job` ( + `job_id` bigint NOT NULL COMMENT '任务id', + `job_name` varchar(64) CHARACTER SET utf8mb4 NOT NULL COMMENT '任务名称', + `job_group` varchar(64) CHARACTER SET utf8mb4 NOT NULL COMMENT '任务组名', + `job_order` char(1) CHARACTER SET utf8mb4 DEFAULT '1' COMMENT '组内执行顺利,值越大执行优先级越高,最大值9,最小值1', + `job_type` char(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '1' COMMENT '1、java类;2、spring bean名称;3、rest调用;4、jar调用;9其他', + `execute_path` varchar(500) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'job_type=3时,rest调用地址,仅支持rest get协议,需要增加String返回值,0成功,1失败;job_type=4时,jar路径;其它值为空', + `class_name` varchar(500) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'job_type=1时,类完整路径;job_type=2时,spring bean名称;其它值为空', + `method_name` varchar(500) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '任务方法', + `method_params_value` varchar(2000) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '参数值', + `cron_expression` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'cron执行表达式', + `misfire_policy` varchar(20) CHARACTER SET utf8mb4 DEFAULT '3' COMMENT '错失执行策略(1错失周期立即执行 2错失周期执行一次 3下周期执行)', + `job_tenant_type` char(1) CHARACTER SET utf8mb4 DEFAULT '1' COMMENT '1、多租户任务;2、非多租户任务', + `job_status` char(1) CHARACTER SET utf8mb4 DEFAULT '0' COMMENT '状态(1、未发布;2、运行中;3、暂停;4、删除;)', + `job_execute_status` char(1) CHARACTER SET utf8mb4 DEFAULT '0' COMMENT '状态(0正常 1异常)', + `create_by` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', + `start_time` timestamp NULL DEFAULT NULL COMMENT '初次执行时间', + `previous_time` timestamp NULL DEFAULT NULL COMMENT '上次执行时间', + `next_time` timestamp NULL DEFAULT NULL COMMENT '下次执行时间', + `remark` varchar(500) CHARACTER SET utf8mb4 DEFAULT '' COMMENT '备注信息', + PRIMARY KEY (`job_id`,`job_name`,`job_group`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='定时任务调度表'; + +-- ---------------------------- +-- Records of sys_job +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for sys_job_log +-- ---------------------------- +DROP TABLE IF EXISTS `sys_job_log`; +CREATE TABLE `sys_job_log` ( + `job_log_id` bigint NOT NULL COMMENT '任务日志ID', + `job_id` bigint NOT NULL COMMENT '任务id', + `job_name` varchar(64) CHARACTER SET utf8 DEFAULT NULL COMMENT '任务名称', + `job_group` varchar(64) CHARACTER SET utf8 DEFAULT NULL COMMENT '任务组名', + `job_order` char(1) CHARACTER SET utf8 DEFAULT NULL COMMENT '组内执行顺利,值越大执行优先级越高,最大值9,最小值1', + `job_type` char(1) CHARACTER SET utf8 NOT NULL DEFAULT '1' COMMENT '1、java类;2、spring bean名称;3、rest调用;4、jar调用;9其他', + `execute_path` varchar(500) CHARACTER SET utf8 DEFAULT NULL COMMENT 'job_type=3时,rest调用地址,仅支持post协议;job_type=4时,jar路径;其它值为空', + `class_name` varchar(500) CHARACTER SET utf8 DEFAULT NULL COMMENT 'job_type=1时,类完整路径;job_type=2时,spring bean名称;其它值为空', + `method_name` varchar(500) CHARACTER SET utf8 DEFAULT NULL COMMENT '任务方法', + `method_params_value` varchar(2000) CHARACTER SET utf8 DEFAULT NULL COMMENT '参数值', + `cron_expression` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT 'cron执行表达式', + `job_message` varchar(500) CHARACTER SET utf8 DEFAULT NULL COMMENT '日志信息', + `job_log_status` char(1) CHARACTER SET utf8 DEFAULT '0' COMMENT '执行状态(0正常 1失败)', + `execute_time` varchar(30) CHARACTER SET utf8 DEFAULT NULL COMMENT '执行时间', + `exception_info` varchar(2000) CHARACTER SET utf8 DEFAULT '' COMMENT '异常信息', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`job_log_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='定时任务执行日志表'; + +-- ---------------------------- +-- Records of sys_job_log +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_group +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_group`; +CREATE TABLE `xxl_job_group` ( + `id` int NOT NULL AUTO_INCREMENT, + `app_name` varchar(64) CHARACTER SET utf8mb4 NOT NULL COMMENT '执行器AppName', + `title` varchar(12) CHARACTER SET utf8mb4 NOT NULL COMMENT '执行器名称', + `address_type` tinyint NOT NULL DEFAULT '0' COMMENT '执行器地址类型:0=自动注册、1=手动录入', + `address_list` text CHARACTER SET utf8mb4 COMMENT '执行器地址列表,多地址逗号分隔', + `update_time` datetime DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_group +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_info +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_info`; +CREATE TABLE `xxl_job_info` ( + `id` int NOT NULL AUTO_INCREMENT, + `job_group` int NOT NULL COMMENT '执行器主键ID', + `job_desc` varchar(255) CHARACTER SET utf8mb4 NOT NULL, + `add_time` datetime DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `author` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '作者', + `alarm_email` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '报警邮件', + `schedule_type` varchar(50) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'NONE' COMMENT '调度类型', + `schedule_conf` varchar(128) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '调度配置,值含义取决于调度类型', + `misfire_strategy` varchar(50) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'DO_NOTHING' COMMENT '调度过期策略', + `executor_route_strategy` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '执行器路由策略', + `executor_handler` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '执行器任务handler', + `executor_param` varchar(512) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '执行器任务参数', + `executor_block_strategy` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '阻塞处理策略', + `executor_timeout` int NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒', + `executor_fail_retry_count` int NOT NULL DEFAULT '0' COMMENT '失败重试次数', + `glue_type` varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT 'GLUE类型', + `glue_source` mediumtext CHARACTER SET utf8mb4 COMMENT 'GLUE源代码', + `glue_remark` varchar(128) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'GLUE备注', + `glue_updatetime` datetime DEFAULT NULL COMMENT 'GLUE更新时间', + `child_jobid` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '子任务ID,多个逗号分隔', + `trigger_status` tinyint NOT NULL DEFAULT '0' COMMENT '调度状态:0-停止,1-运行', + `trigger_last_time` bigint NOT NULL DEFAULT '0' COMMENT '上次调度时间', + `trigger_next_time` bigint NOT NULL DEFAULT '0' COMMENT '下次调度时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_info +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_lock +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_lock`; +CREATE TABLE `xxl_job_lock` ( + `lock_name` varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT '锁名称', + PRIMARY KEY (`lock_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_lock +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_log +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_log`; +CREATE TABLE `xxl_job_log` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `job_group` int NOT NULL COMMENT '执行器主键ID', + `job_id` int NOT NULL COMMENT '任务,主键ID', + `executor_address` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '执行器地址,本次执行的地址', + `executor_handler` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '执行器任务handler', + `executor_param` varchar(512) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '执行器任务参数', + `executor_sharding_param` varchar(20) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '执行器任务分片参数,格式如 1/2', + `executor_fail_retry_count` int NOT NULL DEFAULT '0' COMMENT '失败重试次数', + `trigger_time` datetime DEFAULT NULL COMMENT '调度-时间', + `trigger_code` int NOT NULL COMMENT '调度-结果', + `trigger_msg` text CHARACTER SET utf8mb4 COMMENT '调度-日志', + `handle_time` datetime DEFAULT NULL COMMENT '执行-时间', + `handle_code` int NOT NULL COMMENT '执行-状态', + `handle_msg` text CHARACTER SET utf8mb4 COMMENT '执行-日志', + `alarm_status` tinyint NOT NULL DEFAULT '0' COMMENT '告警状态:0-默认、1-无需告警、2-告警成功、3-告警失败', + PRIMARY KEY (`id`) USING BTREE, + KEY `I_trigger_time` (`trigger_time`) USING BTREE, + KEY `I_handle_code` (`handle_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_log +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_log_report +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_log_report`; +CREATE TABLE `xxl_job_log_report` ( + `id` int NOT NULL AUTO_INCREMENT, + `trigger_day` datetime DEFAULT NULL COMMENT '调度-时间', + `running_count` int NOT NULL DEFAULT '0' COMMENT '运行中-日志数量', + `suc_count` int NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量', + `fail_count` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量', + `update_time` datetime DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `i_trigger_day` (`trigger_day`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_log_report +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_logglue +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_logglue`; +CREATE TABLE `xxl_job_logglue` ( + `id` int NOT NULL AUTO_INCREMENT, + `job_id` int NOT NULL COMMENT '任务,主键ID', + `glue_type` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'GLUE类型', + `glue_source` mediumtext CHARACTER SET utf8mb4 COMMENT 'GLUE源代码', + `glue_remark` varchar(128) CHARACTER SET utf8mb4 NOT NULL COMMENT 'GLUE备注', + `add_time` datetime DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_logglue +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_registry +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_registry`; +CREATE TABLE `xxl_job_registry` ( + `id` int NOT NULL AUTO_INCREMENT, + `registry_group` varchar(50) CHARACTER SET utf8mb4 NOT NULL, + `registry_key` varchar(255) CHARACTER SET utf8mb4 NOT NULL, + `registry_value` varchar(255) CHARACTER SET utf8mb4 NOT NULL, + `update_time` datetime DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + KEY `i_g_k_v` (`registry_group`,`registry_key`,`registry_value`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_registry +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for xxl_job_user +-- ---------------------------- +DROP TABLE IF EXISTS `xxl_job_user`; +CREATE TABLE `xxl_job_user` ( + `id` int NOT NULL AUTO_INCREMENT, + `username` varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT '账号', + `password` varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT '密码', + `role` tinyint NOT NULL COMMENT '角色:0-普通用户、1-管理员', + `permission` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '权限:执行器ID列表,多个逗号分割', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `i_username` (`username`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- ---------------------------- +-- Records of xxl_job_user +-- ---------------------------- +BEGIN; +INSERT INTO `xxl_job_user`(`id`, `username`, `password`, `role`, `permission`) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, NULL); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/docker-compose.yml b/docker-compose.yml index 33823c33..caee6cad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,3 +73,10 @@ services: container_name: pig-codegen hostname: pig-codegen image: pig-codegen + + pig-daemon-quartz: + build: + context: ./pig-visual/pig-quartz + restart: always + image: pig-quartz + container_name: pig-quartz diff --git a/pig-auth/pom.xml b/pig-auth/pom.xml index 1e5e2da4..e696df5f 100755 --- a/pig-auth/pom.xml +++ b/pig-auth/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.6.4 + 3.7.0-SNAPSHOT pig-auth diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java index 45ed3892..bf2c2439 100755 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java @@ -74,19 +74,16 @@ public class AuthorizationServerConfiguration { .authorizationEndpoint(authorizationEndpoint -> authorizationEndpoint// 授权码端点个性化confirm页面 .consentPage(SecurityConstants.CUSTOM_CONSENT_PAGE_URI))); - DefaultSecurityFilterChain securityFilterChain = http.authorizeHttpRequests(authorizeRequests -> { + http.authorizeHttpRequests(authorizeRequests -> { // 自定义接口、端点暴露 authorizeRequests.requestMatchers("/token/**", "/actuator/**", "/css/**", "/error").permitAll(); authorizeRequests.anyRequest().authenticated(); }) .apply(authorizationServerConfigurer.authorizationService(authorizationService)// redis存储token的实现 .authorizationServerSettings( - AuthorizationServerSettings.builder().issuer(SecurityConstants.PROJECT_LICENSE).build())) - // 授权码登录的登录页个性化 - .and() - .apply(new FormIdentityLoginConfigurer()) - .and() - .build(); + AuthorizationServerSettings.builder().issuer(SecurityConstants.PROJECT_LICENSE).build())); + http.apply(new FormIdentityLoginConfigurer()); + DefaultSecurityFilterChain securityFilterChain = http.build(); // 注入自定义授权模式实现 addCustomOAuth2GrantAuthenticationProvider(http); diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java index 9f27cb8a..f85acef7 100755 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java @@ -22,6 +22,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.Order; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; +import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer; import org.springframework.security.web.SecurityFilterChain; /** @@ -44,12 +47,8 @@ public class WebSecurityConfiguration { http.authorizeHttpRequests(authorizeRequests -> authorizeRequests.requestMatchers("/token/*") .permitAll()// 开放自定义的部分端点 .anyRequest() - .authenticated()) - .headers() - .frameOptions() - .sameOrigin()// 避免iframe同源无法登录 - .and() - .apply(new FormIdentityLoginConfigurer()); // 表单登录个性化 + .authenticated()).headers(header -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)// 避免iframe同源无法登录许iframe + ).apply(new FormIdentityLoginConfigurer()); // 表单登录个性化 // 处理 UsernamePasswordAuthenticationToken http.authenticationProvider(new PigDaoAuthenticationProvider()); return http.build(); @@ -68,12 +67,9 @@ public class WebSecurityConfiguration { SecurityFilterChain resources(HttpSecurity http) throws Exception { http.securityMatchers((matchers) -> matchers.requestMatchers("/actuator/**", "/css/**", "/error")) .authorizeHttpRequests((authorize) -> authorize.anyRequest().permitAll()) - .requestCache() - .disable() - .securityContext() - .disable() - .sessionManagement() - .disable(); + .requestCache(RequestCacheConfigurer::disable) + .securityContext(AbstractHttpConfigurer::disable) + .sessionManagement(AbstractHttpConfigurer::disable); return http.build(); } diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java index 5f312858..15772aa3 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java @@ -27,6 +27,7 @@ import com.pig4cloud.pig.admin.api.vo.TokenVo; import com.pig4cloud.pig.auth.support.handler.PigAuthenticationFailureEventHandler; import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CommonConstants; +import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.RetOps; import com.pig4cloud.pig.common.core.util.SpringContextHolder; @@ -34,6 +35,8 @@ import com.pig4cloud.pig.common.security.annotation.Inner; import com.pig4cloud.pig.common.security.util.OAuth2EndpointUtils; import com.pig4cloud.pig.common.security.util.OAuth2ErrorCodesExpand; import com.pig4cloud.pig.common.security.util.OAuthClientException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -59,8 +62,6 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import java.security.Principal; import java.util.List; import java.util.Map; @@ -107,7 +108,8 @@ public class PigTokenEndpoint { @RequestParam(OAuth2ParameterNames.CLIENT_ID) String clientId, @RequestParam(OAuth2ParameterNames.SCOPE) String scope, @RequestParam(OAuth2ParameterNames.STATE) String state) { - SysOauthClientDetails clientDetails = RetOps.of(clientDetailsService.getClientDetailsById(clientId)) + SysOauthClientDetails clientDetails = RetOps + .of(clientDetailsService.getClientDetailsById(clientId, SecurityConstants.FROM_IN)) .getData() .orElseThrow(() -> new OAuthClientException("clientId 不合法")); diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/CustomeOAuth2TokenCustomizer.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/CustomeOAuth2TokenCustomizer.java index 1938af92..400bc1db 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/CustomeOAuth2TokenCustomizer.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/CustomeOAuth2TokenCustomizer.java @@ -31,6 +31,8 @@ public class CustomeOAuth2TokenCustomizer implements OAuth2TokenCustomizer logout.logoutSuccessHandler(new SsoLogoutSuccessHandler()) + .deleteCookies("JSESSIONID") + .invalidateHttpSession(true)) // SSO登出成功处理 + + .csrf(AbstractHttpConfigurer::disable); } } diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/PigDaoAuthenticationProvider.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/PigDaoAuthenticationProvider.java index 26ab036c..13b4867d 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/PigDaoAuthenticationProvider.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/PigDaoAuthenticationProvider.java @@ -70,7 +70,7 @@ public class PigDaoAuthenticationProvider extends AbstractUserDetailsAuthenticat // app 模式不用校验密码 String grantType = WebUtils.getRequest().get().getParameter(OAuth2ParameterNames.GRANT_TYPE); - if (StrUtil.equals(SecurityConstants.APP, grantType)) { + if (StrUtil.equals(SecurityConstants.MOBILE, grantType)) { return; } diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationFailureEventHandler.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationFailureEventHandler.java index e8fceef2..e63a66cc 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationFailureEventHandler.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationFailureEventHandler.java @@ -66,7 +66,7 @@ public class PigAuthenticationFailureEventHandler implements AuthenticationFailu log.info("用户:{} 登录失败,异常:{}", username, exception.getLocalizedMessage()); SysLog logVo = SysLogUtils.getSysLog(); logVo.setTitle("登录失败"); - logVo.setType(LogTypeEnum.ERROR.getType()); + logVo.setLogType(LogTypeEnum.ERROR.getType()); logVo.setException(exception.getLocalizedMessage()); // 发送异步日志事件 String startTimeStr = request.getHeader(CommonConstants.REQUEST_START_TIME); @@ -76,7 +76,6 @@ public class PigAuthenticationFailureEventHandler implements AuthenticationFailu logVo.setTime(endTime - startTime); } logVo.setCreateBy(username); - logVo.setUpdateBy(username); SpringContextHolder.publishEvent(new SysLogEvent(logVo)); // 写出错误信息 sendErrorResponse(request, response, exception); @@ -100,7 +99,7 @@ public class PigAuthenticationFailureEventHandler implements AuthenticationFailu // 手机号登录 String grantType = request.getParameter(OAuth2ParameterNames.GRANT_TYPE); - if (SecurityConstants.APP.equals(grantType)) { + if (SecurityConstants.MOBILE.equals(grantType)) { errorMessage = MsgUtils.getSecurityMessage("AbstractUserDetailsAuthenticationProvider.smsBadCredentials"); } diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationSuccessEventHandler.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationSuccessEventHandler.java index 463f1dc6..c91a0270 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationSuccessEventHandler.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationSuccessEventHandler.java @@ -24,7 +24,10 @@ import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.util.SpringContextHolder; import com.pig4cloud.pig.common.log.event.SysLogEvent; import com.pig4cloud.pig.common.log.util.SysLogUtils; +import com.pig4cloud.pig.common.security.component.PigCustomOAuth2AccessTokenResponseHttpMessageConverter; import com.pig4cloud.pig.common.security.service.PigUser; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.http.converter.HttpMessageConverter; @@ -34,13 +37,10 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.oauth2.core.OAuth2AccessToken; import org.springframework.security.oauth2.core.OAuth2RefreshToken; import org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse; -import org.springframework.security.oauth2.core.http.converter.OAuth2AccessTokenResponseHttpMessageConverter; import org.springframework.security.oauth2.server.authorization.authentication.OAuth2AccessTokenAuthenticationToken; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.util.CollectionUtils; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.time.temporal.ChronoUnit; import java.util.Map; @@ -52,7 +52,7 @@ import java.util.Map; @Slf4j public class PigAuthenticationSuccessEventHandler implements AuthenticationSuccessHandler { - private final HttpMessageConverter accessTokenHttpResponseConverter = new OAuth2AccessTokenResponseHttpMessageConverter(); + private final HttpMessageConverter accessTokenHttpResponseConverter = new PigCustomOAuth2AccessTokenResponseHttpMessageConverter(); /** * Called when a user has been successfully authenticated. @@ -81,7 +81,6 @@ public class PigAuthenticationSuccessEventHandler implements AuthenticationSucce logVo.setTime(endTime - startTime); } logVo.setCreateBy(userInfo.getName()); - logVo.setUpdateBy(userInfo.getName()); SpringContextHolder.publishEvent(new SysLogEvent(logVo)); } @@ -115,6 +114,7 @@ public class PigAuthenticationSuccessEventHandler implements AuthenticationSucce // 无状态 注意删除 context 上下文的信息 SecurityContextHolder.clearContext(); + this.accessTokenHttpResponseConverter.write(accessTokenResponse, null, httpResponse); } diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigLogoutSuccessEventHandler.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigLogoutSuccessEventHandler.java index b929345b..cbd10860 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigLogoutSuccessEventHandler.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigLogoutSuccessEventHandler.java @@ -70,7 +70,6 @@ public class PigLogoutSuccessEventHandler implements ApplicationListenercom.pig4cloud pig-common-bom - 3.6.4 + 3.7.0-SNAPSHOT pom pig-common-bom @@ -15,7 +15,7 @@ ${project.version} - 3.0.6 + 3.1.1 UTF-8 2.17.1 1.8 @@ -28,7 +28,7 @@ 3.5.3.1 8.0.33 1.6.1 - 3.0.0 + 3.1.0 7.1 3.0.0 3.0.0 @@ -66,6 +66,11 @@ pig-common-mybatis ${pig.common.version} + + com.pig4cloud + pig-common-oss + ${pig.common.version} + com.pig4cloud pig-common-security diff --git a/pig-common/pig-common-core/pom.xml b/pig-common/pig-common-core/pom.xml index 4b959ac7..b88cb9e7 100755 --- a/pig-common/pig-common-core/pom.xml +++ b/pig-common/pig-common-core/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-core diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/CacheConstants.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/CacheConstants.java index 0de69d68..cc4e6174 100644 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/CacheConstants.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/CacheConstants.java @@ -29,11 +29,6 @@ public interface CacheConstants { */ String PROJECT_OAUTH_ACCESS = "token::access_token"; - /** - * oauth 缓存令牌前缀 - */ - String PROJECT_OAUTH_TOKEN = "pig_oauth:token:"; - /** * 验证码前缀 */ @@ -54,6 +49,11 @@ public interface CacheConstants { */ String DICT_DETAILS = "dict_details"; + /** + * 角色信息缓存 + */ + String ROLE_DETAILS = "role_details"; + /** * oauth 客户端信息 */ diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/SecurityConstants.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/SecurityConstants.java index 15b2a312..acda5fa6 100755 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/SecurityConstants.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/SecurityConstants.java @@ -65,7 +65,7 @@ public interface SecurityConstants { /** * 手机号登录 */ - String APP = "app"; + String MOBILE = "mobile"; /** * {bcrypt} 加密的特征码 @@ -92,6 +92,11 @@ public interface SecurityConstants { */ String DETAILS_USER = "user_info"; + /** + * 用户ID + */ + String DETAILS_USER_ID = "user_id"; + /** * 协议字段 */ @@ -120,7 +125,7 @@ public interface SecurityConstants { /** * 短信登录 参数名称 */ - String SMS_PARAMETER_NAME = "phone"; + String SMS_PARAMETER_NAME = "mobile"; /** * 授权码模式confirm diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/ServiceNameConstants.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/ServiceNameConstants.java index b1b5ac71..cabae2ce 100644 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/ServiceNameConstants.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/constant/ServiceNameConstants.java @@ -28,8 +28,8 @@ public interface ServiceNameConstants { String AUTH_SERVICE = "pig-auth"; /** - * UMPS模块 + * UPMS模块 */ - String UMPS_SERVICE = "pig-upms-biz"; + String UPMS_SERVICE = "pig-upms-biz"; } diff --git a/pig-common/pig-common-datasource/pom.xml b/pig-common/pig-common-datasource/pom.xml index 0af20a6e..a4552f60 100644 --- a/pig-common/pig-common-datasource/pom.xml +++ b/pig-common/pig-common-datasource/pom.xml @@ -16,28 +16,32 @@ --> - - pig-common - com.pig4cloud - 3.6.4 - - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + pig-common + com.pig4cloud + 3.7.0-SNAPSHOT + + 4.0.0 - com.pig4cloud - pig-common-datasource + com.pig4cloud + pig-common-datasource - jar + jar - pig 动态切换数据源 + pig 动态切换数据源 - - - - com.baomidou - dynamic-datasource-spring-boot-starter - ${dynamic-ds.version} - - + + + + com.baomidou + dynamic-datasource-spring-boot3-starter + ${dynamic-ds.version} + + + jakarta.servlet + jakarta.servlet-api + + diff --git a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/DynamicDataSourceAutoConfiguration.java b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/DynamicDataSourceAutoConfiguration.java index 6492235c..48d6989e 100644 --- a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/DynamicDataSourceAutoConfiguration.java +++ b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/DynamicDataSourceAutoConfiguration.java @@ -16,8 +16,12 @@ package com.pig4cloud.pig.common.datasource; +import com.baomidou.dynamic.datasource.creator.DataSourceCreator; +import com.baomidou.dynamic.datasource.creator.DefaultDataSourceCreator; +import com.baomidou.dynamic.datasource.creator.hikaricp.HikariDataSourceCreator; import com.baomidou.dynamic.datasource.processor.DsProcessor; import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; +import com.pig4cloud.pig.common.datasource.config.ClearTtlDataSourceFilter; import com.pig4cloud.pig.common.datasource.config.DataSourceProperties; import com.pig4cloud.pig.common.datasource.config.JdbcDynamicDataSourceProvider; import com.pig4cloud.pig.common.datasource.config.LastParamDsProcessor; @@ -28,6 +32,9 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.ArrayList; +import java.util.List; + /** * @author lengleng * @date 2020-02-06 @@ -40,9 +47,9 @@ import org.springframework.context.annotation.Configuration; public class DynamicDataSourceAutoConfiguration { @Bean - public DynamicDataSourceProvider dynamicDataSourceProvider(StringEncryptor stringEncryptor, - DataSourceProperties properties) { - return new JdbcDynamicDataSourceProvider(stringEncryptor, properties); + public DynamicDataSourceProvider dynamicDataSourceProvider(DefaultDataSourceCreator defaultDataSourceCreator, + StringEncryptor stringEncryptor, DataSourceProperties properties) { + return new JdbcDynamicDataSourceProvider(defaultDataSourceCreator, stringEncryptor, properties); } @Bean @@ -50,4 +57,18 @@ public class DynamicDataSourceAutoConfiguration { return new LastParamDsProcessor(); } + @Bean + public DefaultDataSourceCreator defaultDataSourceCreator(HikariDataSourceCreator hikariDataSourceCreator) { + DefaultDataSourceCreator defaultDataSourceCreator = new DefaultDataSourceCreator(); + List creators = new ArrayList<>(); + creators.add(hikariDataSourceCreator); + defaultDataSourceCreator.setCreators(creators); + return defaultDataSourceCreator; + } + + @Bean + public ClearTtlDataSourceFilter clearTtlDsFilter() { + return new ClearTtlDataSourceFilter(); + } + } diff --git a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/ClearTtlDataSourceFilter.java b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/ClearTtlDataSourceFilter.java new file mode 100644 index 00000000..c4e1b97d --- /dev/null +++ b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/ClearTtlDataSourceFilter.java @@ -0,0 +1,34 @@ +package com.pig4cloud.pig.common.datasource.config; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import org.springframework.core.Ordered; +import org.springframework.web.filter.GenericFilterBean; + +import java.io.IOException; + +/** + * @author lengleng + * @date 2020/12/11 + *

+ * 清空上文的DS 设置避免污染当前线程 + */ +public class ClearTtlDataSourceFilter extends GenericFilterBean implements Ordered { + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + DynamicDataSourceContextHolder.clear(); + filterChain.doFilter(servletRequest, servletResponse); + DynamicDataSourceContextHolder.clear(); + } + + @Override + public int getOrder() { + return Integer.MIN_VALUE; + } + +} diff --git a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/JdbcDynamicDataSourceProvider.java b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/JdbcDynamicDataSourceProvider.java index 9f8e81a8..ca1433da 100644 --- a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/JdbcDynamicDataSourceProvider.java +++ b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/JdbcDynamicDataSourceProvider.java @@ -16,8 +16,9 @@ package com.pig4cloud.pig.common.datasource.config; +import com.baomidou.dynamic.datasource.creator.DataSourceProperty; +import com.baomidou.dynamic.datasource.creator.DefaultDataSourceCreator; import com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; import com.pig4cloud.pig.common.datasource.support.DataSourceConstants; import org.jasypt.encryption.StringEncryptor; @@ -39,8 +40,10 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide private final StringEncryptor stringEncryptor; - public JdbcDynamicDataSourceProvider(StringEncryptor stringEncryptor, DataSourceProperties properties) { - super(properties.getDriverClassName(), properties.getUrl(), properties.getUsername(), properties.getPassword()); + public JdbcDynamicDataSourceProvider(DefaultDataSourceCreator defaultDataSourceCreator, + StringEncryptor stringEncryptor, DataSourceProperties properties) { + super(defaultDataSourceCreator, properties.getDriverClassName(), properties.getUrl(), properties.getUsername(), + properties.getPassword()); this.stringEncryptor = stringEncryptor; this.properties = properties; } diff --git a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/enums/DsConfTypeEnum.java b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/enums/DsConfTypeEnum.java new file mode 100644 index 00000000..2289806f --- /dev/null +++ b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/enums/DsConfTypeEnum.java @@ -0,0 +1,30 @@ +package com.pig4cloud.pig.common.datasource.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author lengleng + * @date 2020/12/11 + *

+ * 数据源配置类型 + */ +@Getter +@AllArgsConstructor +public enum DsConfTypeEnum { + + /** + * 主机链接 + */ + HOST(0, "主机链接"), + + /** + * JDBC链接 + */ + JDBC(1, "JDBC链接"); + + private final Integer type; + + private final String description; + +} diff --git a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/enums/DsJdbcUrlEnum.java b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/enums/DsJdbcUrlEnum.java new file mode 100644 index 00000000..ccdad2e4 --- /dev/null +++ b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/enums/DsJdbcUrlEnum.java @@ -0,0 +1,72 @@ +package com.pig4cloud.pig.common.datasource.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @author lengleng + * @date 2020/12/11 + *

+ * jdbc-url + */ +@Getter +@AllArgsConstructor +public enum DsJdbcUrlEnum { + + /** + * mysql 数据库 + */ + MYSQL("mysql", + "jdbc:mysql://%s:%s/%s?characterEncoding=utf8" + + "&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true" + + "&useLegacyDatetimeCode=false&allowMultiQueries=true&allowPublicKeyRetrieval=true", + "select 1", "mysql8 链接"), + + /** + * pg 数据库 + */ + PG("pg", "jdbc:postgresql://%s:%s/%s", "select 1", "postgresql 链接"), + + /** + * SQL SERVER + */ + MSSQL("mssql", "jdbc:sqlserver://%s:%s;database=%s;characterEncoding=UTF-8", "select 1", "sqlserver 链接"), + + /** + * oracle + */ + ORACLE("oracle", "jdbc:oracle:thin:@%s:%s:%s", "select 1 from dual", "oracle 链接"), + + /** + * db2 + */ + DB2("db2", "jdbc:db2://%s:%s/%s", "select 1 from sysibm.sysdummy1", "DB2 TYPE4 连接"), + + /** + * 达梦 + */ + DM("dm", "jdbc:dm://%s:%s/%s", "select 1 from dual", "达梦连接"), + + /** + * pg 数据库 + */ + HIGHGO("highgo", "jdbc:highgo://%s:%s/%s", "select 1", "highgo 链接"); + + private final String dbName; + + private final String url; + + private final String validationQuery; + + private final String description; + + public static DsJdbcUrlEnum get(String dsType) { + return Arrays.stream(DsJdbcUrlEnum.values()) + .filter(dsJdbcUrlEnum -> dsType.equals(dsJdbcUrlEnum.getDbName())) + .findFirst() + .get(); + } + +} diff --git a/pig-common/pig-common-feign/pom.xml b/pig-common/pig-common-feign/pom.xml index 26451d25..218c2b3d 100755 --- a/pig-common/pig-common-feign/pom.xml +++ b/pig-common/pig-common-feign/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT 4.0.0 diff --git a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java index ed97d11a..7b6e3e7a 100755 --- a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java +++ b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java @@ -17,9 +17,9 @@ package com.pig4cloud.pig.common.feign.annotation; import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClientsConfiguration; import org.springframework.cloud.openfeign.PigFeignClientsRegistrar; import org.springframework.context.annotation.Import; +import org.springframework.core.annotation.AliasFor; import java.lang.annotation.*; @@ -51,32 +51,7 @@ public @interface EnablePigFeignClients { * package names. * @return the array of 'basePackages'. */ + @AliasFor(annotation = EnableFeignClients.class, attribute = "basePackages") String[] basePackages() default { "com.pig4cloud.pig" }; - /** - * Type-safe alternative to {@link #basePackages()} for specifying the packages to - * scan for annotated components. The package of each class specified will be scanned. - *

- * Consider creating a special no-op marker class or interface in each package that - * serves no purpose other than being referenced by this attribute. - * @return the array of 'basePackageClasses'. - */ - Class[] basePackageClasses() default {}; - - /** - * A custom @Configuration for all feign clients. Can contain override - * @Bean definition for the pieces that make up the client, for instance - * {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}. - * - * @see FeignClientsConfiguration for the defaults - */ - Class[] defaultConfiguration() default {}; - - /** - * List of classes annotated with @FeignClient. If not empty, disables classpath - * scanning. - * @return - */ - Class[] clients() default {}; - } diff --git a/pig-common/pig-common-job/pom.xml b/pig-common/pig-common-job/pom.xml index 1a12427d..7f37c96e 100755 --- a/pig-common/pig-common-job/pom.xml +++ b/pig-common/pig-common-job/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-job diff --git a/pig-common/pig-common-log/pom.xml b/pig-common/pig-common-log/pom.xml index 83acf4c3..7e7960fa 100755 --- a/pig-common/pig-common-log/pom.xml +++ b/pig-common/pig-common-log/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-log diff --git a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/aspect/SysLogAspect.java b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/aspect/SysLogAspect.java index 4d984530..87569f09 100755 --- a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/aspect/SysLogAspect.java +++ b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/aspect/SysLogAspect.java @@ -73,7 +73,7 @@ public class SysLogAspect { obj = point.proceed(); } catch (Exception e) { - logVo.setType(LogTypeEnum.ERROR.getType()); + logVo.setLogType(LogTypeEnum.ERROR.getType()); logVo.setException(e.getMessage()); throw e; } diff --git a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/event/SysLogListener.java b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/event/SysLogListener.java index 162ab829..dcdd35f6 100755 --- a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/event/SysLogListener.java +++ b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/event/SysLogListener.java @@ -16,8 +16,10 @@ package com.pig4cloud.pig.common.log.event; +import com.pig4cloud.pig.admin.api.dto.SysLogDTO; import com.pig4cloud.pig.admin.api.entity.SysLog; import com.pig4cloud.pig.admin.api.feign.RemoteLogService; +import com.pig4cloud.pig.common.core.constant.SecurityConstants; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.event.EventListener; @@ -38,7 +40,7 @@ public class SysLogListener { @EventListener(SysLogEvent.class) public void saveSysLog(SysLogEvent event) { SysLog sysLog = (SysLog) event.getSource(); - remoteLogService.saveLog(sysLog); + remoteLogService.saveLog(sysLog, SecurityConstants.FROM_IN); } } diff --git a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java index 3dcead6d..53c0cc65 100755 --- a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java +++ b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java @@ -21,7 +21,7 @@ import cn.hutool.http.HttpUtil; import com.pig4cloud.pig.admin.api.entity.SysLog; import jakarta.servlet.http.HttpServletRequest; import lombok.experimental.UtilityClass; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; +import org.springframework.core.StandardReflectionParameterNameDiscoverer; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; @@ -47,13 +47,12 @@ public class SysLogUtils { HttpServletRequest request = ((ServletRequestAttributes) Objects .requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); SysLog sysLog = new SysLog(); - sysLog.setType(LogTypeEnum.NORMAL.getType()); + sysLog.setLogType(LogTypeEnum.NORMAL.getType()); sysLog.setRequestUri(URLUtil.getPath(request.getRequestURI())); sysLog.setMethod(request.getMethod()); sysLog.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT)); sysLog.setParams(HttpUtil.toParams(request.getParameterMap())); sysLog.setCreateBy(getUsername()); - sysLog.setUpdateBy(getUsername()); return sysLog; } @@ -90,7 +89,7 @@ public class SysLogUtils { * @return 装载参数的容器 */ public EvaluationContext getContext(Object[] arguments, Method signatureMethod) { - String[] parameterNames = new LocalVariableTableParameterNameDiscoverer().getParameterNames(signatureMethod); + String[] parameterNames = new StandardReflectionParameterNameDiscoverer().getParameterNames(signatureMethod); EvaluationContext context = new StandardEvaluationContext(); if (parameterNames == null) { return context; diff --git a/pig-common/pig-common-mybatis/pom.xml b/pig-common/pig-common-mybatis/pom.xml index 37b92c86..29a773ed 100755 --- a/pig-common/pig-common-mybatis/pom.xml +++ b/pig-common/pig-common-mybatis/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-mybatis @@ -67,5 +67,9 @@ spring-security-core true + + com.pig4cloud + pig-common-core + diff --git a/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java index fb84043d..b5c3838d 100644 --- a/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java +++ b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java @@ -2,6 +2,7 @@ package com.pig4cloud.pig.common.mybatis.config; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import com.pig4cloud.pig.common.core.constant.CommonConstants; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.reflection.MetaObject; import org.springframework.security.core.Authentication; @@ -25,10 +26,13 @@ public class MybatisPlusMetaObjectHandler implements MetaObjectHandler { log.debug("mybatis plus start insert fill ...."); LocalDateTime now = LocalDateTime.now(); - fillValIfNullByName("createTime", now, metaObject, false); - fillValIfNullByName("updateTime", now, metaObject, false); - fillValIfNullByName("createBy", getUserName(), metaObject, false); - fillValIfNullByName("updateBy", getUserName(), metaObject, false); + fillValIfNullByName("createTime", now, metaObject, true); + fillValIfNullByName("updateTime", now, metaObject, true); + fillValIfNullByName("createBy", getUserName(), metaObject, true); + fillValIfNullByName("updateBy", getUserName(), metaObject, true); + + // 删除标记自动填充 + fillValIfNullByName("delFlag", CommonConstants.STATUS_NORMAL, metaObject, true); } @Override diff --git a/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/handler/JsonLongArrayTypeHandler.java b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/handler/JsonLongArrayTypeHandler.java new file mode 100644 index 00000000..005c3ea2 --- /dev/null +++ b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/handler/JsonLongArrayTypeHandler.java @@ -0,0 +1,56 @@ +package com.pig4cloud.pig.common.mybatis.handler; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import lombok.SneakyThrows; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Mybatis数组,符串互转 + *

+ * MappedJdbcTypes 数据库中的数据类型 MappedTypes java中的的数据类型 + * + * @author xuzihui + * @date 2019-11-20 + */ +@MappedTypes(value = { Long[].class }) +@MappedJdbcTypes(value = JdbcType.VARCHAR) +public class JsonLongArrayTypeHandler extends BaseTypeHandler { + + @Override + public void setNonNullParameter(PreparedStatement ps, int i, Long[] parameter, JdbcType jdbcType) + throws SQLException { + ps.setString(i, ArrayUtil.join(parameter, StrUtil.COMMA)); + } + + @Override + @SneakyThrows + public Long[] getNullableResult(ResultSet rs, String columnName) { + String reString = rs.getString(columnName); + return Convert.toLongArray(reString); + } + + @Override + @SneakyThrows + public Long[] getNullableResult(ResultSet rs, int columnIndex) { + String reString = rs.getString(columnIndex); + return Convert.toLongArray(reString); + } + + @Override + @SneakyThrows + public Long[] getNullableResult(CallableStatement cs, int columnIndex) { + String reString = cs.getString(columnIndex); + return Convert.toLongArray(reString); + } + +} diff --git a/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/handler/JsonStringArrayTypeHandler.java b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/handler/JsonStringArrayTypeHandler.java new file mode 100644 index 00000000..017ca4d2 --- /dev/null +++ b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/handler/JsonStringArrayTypeHandler.java @@ -0,0 +1,56 @@ +package com.pig4cloud.pig.common.mybatis.handler; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import lombok.SneakyThrows; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Mybatis数组,符串互转 + *

+ * MappedJdbcTypes 数据库中的数据类型 MappedTypes java中的的数据类型 + * + * @author xuzihui + * @date 2019-11-20 + */ +@MappedTypes(value = { String[].class }) +@MappedJdbcTypes(value = JdbcType.VARCHAR) +public class JsonStringArrayTypeHandler extends BaseTypeHandler { + + @Override + public void setNonNullParameter(PreparedStatement ps, int i, String[] parameter, JdbcType jdbcType) + throws SQLException { + ps.setString(i, ArrayUtil.join(parameter, StrUtil.COMMA)); + } + + @Override + @SneakyThrows + public String[] getNullableResult(ResultSet rs, String columnName) { + String reString = rs.getString(columnName); + return Convert.toStrArray(reString); + } + + @Override + @SneakyThrows + public String[] getNullableResult(ResultSet rs, int columnIndex) { + String reString = rs.getString(columnIndex); + return Convert.toStrArray(reString); + } + + @Override + @SneakyThrows + public String[] getNullableResult(CallableStatement cs, int columnIndex) { + String reString = cs.getString(columnIndex); + return Convert.toStrArray(reString); + } + +} diff --git a/pig-common/pig-common-oss/pom.xml b/pig-common/pig-common-oss/pom.xml new file mode 100755 index 00000000..1ec26766 --- /dev/null +++ b/pig-common/pig-common-oss/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + com.pig4cloud + pig-common + 3.7.0-SNAPSHOT + + + pig-common-oss + jar + + pig 文件系统依赖 + + + + com.amazonaws + aws-java-sdk-s3 + ${aws.version} + + + cn.hutool + hutool-core + + + diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/FileAutoConfiguration.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/FileAutoConfiguration.java new file mode 100755 index 00000000..2227b953 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/FileAutoConfiguration.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file; + +import com.pig4cloud.pig.common.file.core.FileProperties; +import com.pig4cloud.pig.common.file.local.LocalFileAutoConfiguration; +import com.pig4cloud.pig.common.file.oss.OssAutoConfiguration; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Import; + +/** + * aws 自动配置类 + * + * @author lengleng + * @author 858695266 + */ +@Import({ LocalFileAutoConfiguration.class, OssAutoConfiguration.class }) +@EnableConfigurationProperties({ FileProperties.class }) +public class FileAutoConfiguration { + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/core/FileProperties.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/core/FileProperties.java new file mode 100755 index 00000000..e225cd95 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/core/FileProperties.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file.core; + +import com.pig4cloud.pig.common.file.local.LocalFileProperties; +import com.pig4cloud.pig.common.file.oss.OssProperties; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 文件 配置信息 + * + * @author lengleng + *

+ * bucket 设置公共读权限 + */ +@Data +@ConfigurationProperties(prefix = "file") +public class FileProperties { + + /** + * 默认的存储桶名称 + */ + private String bucketName = "local"; + + /** + * 本地文件配置信息 + */ + private LocalFileProperties local; + + /** + * oss 文件配置信息 + */ + private OssProperties oss; + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/core/FileTemplate.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/core/FileTemplate.java new file mode 100644 index 00000000..c9e95785 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/core/FileTemplate.java @@ -0,0 +1,87 @@ +package com.pig4cloud.pig.common.file.core; + +import com.amazonaws.services.s3.model.Bucket; +import com.amazonaws.services.s3.model.S3Object; +import com.amazonaws.services.s3.model.S3ObjectSummary; +import org.springframework.beans.factory.InitializingBean; + +import java.io.InputStream; +import java.util.List; + +/** + * 文件操作模板 + * + * @author lengleng + * @date 2022/4/19 + */ +public interface FileTemplate extends InitializingBean { + + /** + * 创建bucket + * @param bucketName bucket名称 + */ + void createBucket(String bucketName); + + /** + * 获取全部bucket + *

+ * + * API Documentation + */ + List getAllBuckets(); + + /** + * @param bucketName bucket名称 + * @see + */ + void removeBucket(String bucketName); + + /** + * 上传文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param stream 文件流 + * @param contextType 文件类型 + * @throws Exception + */ + void putObject(String bucketName, String objectName, InputStream stream, String contextType) throws Exception; + + /** + * 上传文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param stream 文件流 + * @param contextType 文件类型 + * @throws Exception + */ + void putObject(String bucketName, String objectName, InputStream stream) throws Exception; + + /** + * 获取文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @return 二进制流 API Documentation + */ + S3Object getObject(String bucketName, String objectName); + + void removeObject(String bucketName, String objectName) throws Exception; + + /** + * @throws Exception + */ + @Override + default void afterPropertiesSet() throws Exception { + } + + /** + * 根据文件前置查询文件 + * @param bucketName bucket名称 + * @param prefix 前缀 + * @param recursive 是否递归查询 + * @return S3ObjectSummary 列表 + * @see AWS + * API Documentation + */ + List getAllObjectsByPrefix(String bucketName, String prefix, boolean recursive); + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileAutoConfiguration.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileAutoConfiguration.java new file mode 100755 index 00000000..bf34b0c3 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileAutoConfiguration.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file.local; + +import com.pig4cloud.pig.common.file.core.FileProperties; +import com.pig4cloud.pig.common.file.core.FileTemplate; +import lombok.AllArgsConstructor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; + +/** + * aws 自动配置类 + * + * @author lengleng + * @author 858695266 + */ +@AllArgsConstructor +public class LocalFileAutoConfiguration { + + private final FileProperties properties; + + @Bean + @ConditionalOnMissingBean(LocalFileTemplate.class) + @ConditionalOnProperty(name = "file.local.enable", havingValue = "true", matchIfMissing = true) + public FileTemplate localFileTemplate() { + return new LocalFileTemplate(properties); + } + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileProperties.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileProperties.java new file mode 100755 index 00000000..7cf833e9 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileProperties.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file.local; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 本地文件 配置信息 + * + * @author lengleng + *

+ * bucket 设置公共读权限 + */ +@Data +@ConfigurationProperties(prefix = "local") +public class LocalFileProperties { + + /** + * 是否开启 + */ + private boolean enable; + + /** + * 默认路径 + */ + private String basePath; + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileTemplate.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileTemplate.java new file mode 100644 index 00000000..159d3647 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/local/LocalFileTemplate.java @@ -0,0 +1,137 @@ +package com.pig4cloud.pig.common.file.local; + +import cn.hutool.core.io.FileUtil; +import com.amazonaws.services.s3.model.Bucket; +import com.amazonaws.services.s3.model.S3Object; +import com.amazonaws.services.s3.model.S3ObjectSummary; +import com.pig4cloud.pig.common.file.core.FileProperties; +import com.pig4cloud.pig.common.file.core.FileTemplate; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; + +import java.io.File; +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 本地文件读取模式 + * + * @author lengleng + * @date 2022/4/19 + */ +@RequiredArgsConstructor +public class LocalFileTemplate implements FileTemplate { + + private final FileProperties properties; + + /** + * 创建bucket + * @param bucketName bucket名称 + */ + @Override + public void createBucket(String bucketName) { + FileUtil.mkdir(properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName); + } + + /** + * 获取全部bucket + *

+ *

+ * API Documentation + */ + @Override + public List getAllBuckets() { + return Arrays.stream(FileUtil.ls(properties.getLocal().getBasePath())).filter(FileUtil::isDirectory) + .map(dir -> new Bucket(dir.getName())).collect(Collectors.toList()); + } + + /** + * @param bucketName bucket名称 + * @see + */ + @Override + public void removeBucket(String bucketName) { + FileUtil.del(properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName); + } + + /** + * 上传文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param stream 文件流 + * @param contextType 文件类型 + */ + @Override + public void putObject(String bucketName, String objectName, InputStream stream, String contextType) { + // 当 Bucket 不存在时创建 + String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName; + if (!FileUtil.isDirectory(properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName)) { + createBucket(bucketName); + } + + // 写入文件 + File file = FileUtil.file(dir + FileUtil.FILE_SEPARATOR + objectName); + FileUtil.writeFromStream(stream, file); + } + + /** + * 获取文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @return 二进制流 API Documentation + */ + @Override + @SneakyThrows + public S3Object getObject(String bucketName, String objectName) { + String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName; + S3Object s3Object = new S3Object(); + s3Object.setObjectContent(FileUtil.getInputStream(dir + FileUtil.FILE_SEPARATOR + objectName)); + return s3Object; + } + + /** + * @param bucketName + * @param objectName + * @throws Exception + */ + @Override + public void removeObject(String bucketName, String objectName) throws Exception { + String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName; + FileUtil.del(dir + FileUtil.FILE_SEPARATOR + objectName); + } + + /** + * 上传文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param stream 文件流 + * @throws Exception + */ + @Override + public void putObject(String bucketName, String objectName, InputStream stream) throws Exception { + putObject(bucketName, objectName, stream, null); + } + + /** + * 根据文件前置查询文件 + * @param bucketName bucket名称 + * @param prefix 前缀 + * @param recursive 是否递归查询 + * @return S3ObjectSummary 列表 + * @see AWS + * API Documentation + */ + @Override + public List getAllObjectsByPrefix(String bucketName, String prefix, boolean recursive) { + String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName; + + return Arrays.stream(FileUtil.ls(dir)).filter(file -> file.getName().startsWith(prefix)).map(file -> { + S3ObjectSummary summary = new S3ObjectSummary(); + summary.setKey(file.getName()); + return new S3ObjectSummary(); + }).collect(Collectors.toList()); + } + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/OssAutoConfiguration.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/OssAutoConfiguration.java new file mode 100755 index 00000000..e0b31449 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/OssAutoConfiguration.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file.oss; + +import com.pig4cloud.pig.common.file.core.FileProperties; +import com.pig4cloud.pig.common.file.core.FileTemplate; +import com.pig4cloud.pig.common.file.oss.http.OssEndpoint; +import com.pig4cloud.pig.common.file.oss.service.OssTemplate; +import lombok.AllArgsConstructor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; + +/** + * aws 自动配置类 + * + * @author lengleng + * @author 858695266 + */ +@AllArgsConstructor +public class OssAutoConfiguration { + + private final FileProperties properties; + + @Bean + @Primary + @ConditionalOnMissingBean(OssTemplate.class) + @ConditionalOnProperty(name = "file.oss.enable", havingValue = "true") + public FileTemplate ossTemplate() { + return new OssTemplate(properties); + } + + @Bean + @ConditionalOnMissingBean + @ConditionalOnProperty(name = "file.oss.info", havingValue = "true") + public OssEndpoint ossEndpoint(OssTemplate template) { + return new OssEndpoint(template); + } + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/OssProperties.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/OssProperties.java new file mode 100755 index 00000000..a1cad010 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/OssProperties.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file.oss; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * aws 配置信息 + * + * @author lengleng + * @author 858695266 配置文件添加: oss: enable: true endpoint: http://127.0.0.1:9000 # + * pathStyleAccess 采用nginx反向代理或者AWS S3 配置成true,支持第三方云存储配置成false pathStyleAccess: false + * access-key: lengleng secret-key: lengleng bucket-name: lengleng region: custom-domain: + * https://oss.xxx.com/lengleng + *

+ * bucket 设置公共读权限 + */ +@Data +@ConfigurationProperties(prefix = "oss") +public class OssProperties { + + /** + * 对象存储服务的URL + */ + private String endpoint; + + /** + * 自定义域名 + */ + private String customDomain; + + /** + * true path-style nginx 反向代理和S3默认支持 pathStyle {http://endpoint/bucketname} false + * supports virtual-hosted-style 阿里云等需要配置为 virtual-hosted-style + * 模式{http://bucketname.endpoint} + */ + private Boolean pathStyleAccess = true; + + /** + * 应用ID + */ + private String appId; + + /** + * 区域 + */ + private String region; + + /** + * Access key就像用户ID,可以唯一标识你的账户 + */ + private String accessKey; + + /** + * Secret key是你账户的密码 + */ + private String secretKey; + + /** + * 最大线程数,默认: 100 + */ + private Integer maxConnections = 100; + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/http/OssEndpoint.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/http/OssEndpoint.java new file mode 100755 index 00000000..4ab42ca7 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/http/OssEndpoint.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file.oss.http; + +import com.amazonaws.services.s3.model.Bucket; +import com.amazonaws.services.s3.model.S3Object; +import com.amazonaws.services.s3.model.S3ObjectSummary; +import com.pig4cloud.pig.common.file.oss.service.OssTemplate; +import lombok.AllArgsConstructor; +import lombok.Cleanup; +import lombok.SneakyThrows; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * aws 对外提供服务端点 + * + * @author lengleng + * @author 858695266 + *

+ * oss.info + */ +@RestController +@AllArgsConstructor +@RequestMapping("/oss") +@ConditionalOnProperty(name = "file.oss.info", havingValue = "true") +public class OssEndpoint { + + private final OssTemplate template; + + /** + * Bucket Endpoints + */ + @SneakyThrows + @PostMapping("/bucket/{bucketName}") + public Bucket createBucker(@PathVariable String bucketName) { + + template.createBucket(bucketName); + return template.getBucket(bucketName).get(); + + } + + @SneakyThrows + @GetMapping("/bucket") + public List getBuckets() { + return template.getAllBuckets(); + } + + @SneakyThrows + @GetMapping("/bucket/{bucketName}") + public Bucket getBucket(@PathVariable String bucketName) { + return template.getBucket(bucketName).orElseThrow(() -> new IllegalArgumentException("Bucket Name not found!")); + } + + @SneakyThrows + @DeleteMapping("/bucket/{bucketName}") + @ResponseStatus(HttpStatus.ACCEPTED) + public void deleteBucket(@PathVariable String bucketName) { + template.removeBucket(bucketName); + } + + /** + * Object Endpoints + */ + @SneakyThrows + @PostMapping("/object/{bucketName}") + public S3Object createObject(@RequestBody MultipartFile object, @PathVariable String bucketName) { + String name = object.getOriginalFilename(); + @Cleanup + InputStream inputStream = object.getInputStream(); + template.putObject(bucketName, name, inputStream, object.getSize(), object.getContentType()); + return template.getObjectInfo(bucketName, name); + + } + + @SneakyThrows + @PostMapping("/object/{bucketName}/{objectName}") + public S3Object createObject(@RequestBody MultipartFile object, @PathVariable String bucketName, + @PathVariable String objectName) { + @Cleanup + InputStream inputStream = object.getInputStream(); + template.putObject(bucketName, objectName, inputStream, object.getSize(), object.getContentType()); + return template.getObjectInfo(bucketName, objectName); + + } + + @SneakyThrows + @GetMapping("/object/{bucketName}/{objectName}") + public List filterObject(@PathVariable String bucketName, @PathVariable String objectName) { + + return template.getAllObjectsByPrefix(bucketName, objectName, true); + + } + + @SneakyThrows + @GetMapping("/object/{bucketName}/{objectName}/{expires}") + public Map getObject(@PathVariable String bucketName, @PathVariable String objectName, + @PathVariable Integer expires) { + Map responseBody = new HashMap<>(8); + // Put Object info + responseBody.put("bucket", bucketName); + responseBody.put("object", objectName); + responseBody.put("url", template.getObjectURL(bucketName, objectName, expires)); + responseBody.put("expires", expires); + return responseBody; + } + + @SneakyThrows + @ResponseStatus(HttpStatus.ACCEPTED) + @DeleteMapping("/object/{bucketName}/{objectName}/") + public void deleteObject(@PathVariable String bucketName, @PathVariable String objectName) { + + template.removeObject(bucketName, objectName); + } + +} diff --git a/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/service/OssTemplate.java b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/service/OssTemplate.java new file mode 100755 index 00000000..fdc5c884 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/java/com/pig4cloud/pig/common/file/oss/service/OssTemplate.java @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.file.oss.service; + +import com.amazonaws.ClientConfiguration; +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSCredentialsProvider; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.client.builder.AwsClientBuilder; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.model.*; +import com.amazonaws.util.IOUtils; +import com.pig4cloud.pig.common.file.core.FileProperties; +import com.pig4cloud.pig.common.file.core.FileTemplate; +import lombok.Cleanup; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import org.springframework.beans.factory.InitializingBean; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.*; + +/** + * aws-s3 通用存储操作 支持所有兼容s3协议的云存储: {阿里云OSS,腾讯云COS,七牛云,京东云,minio 等} + * + * @author lengleng + * @author 858695266 + * @date 2020/5/23 6:36 上午 + * @since 1.0 + */ +@RequiredArgsConstructor +public class OssTemplate implements InitializingBean, FileTemplate { + + private final FileProperties properties; + + private AmazonS3 amazonS3; + + /** + * 创建bucket + * @param bucketName bucket名称 + */ + @SneakyThrows + public void createBucket(String bucketName) { + if (!amazonS3.doesBucketExistV2(bucketName)) { + amazonS3.createBucket((bucketName)); + } + } + + /** + * 获取全部bucket + *

+ * + * @see AWS + * API Documentation + */ + @SneakyThrows + public List getAllBuckets() { + return amazonS3.listBuckets(); + } + + /** + * @param bucketName bucket名称 + * @see AWS + * API Documentation + */ + @SneakyThrows + public Optional getBucket(String bucketName) { + return amazonS3.listBuckets().stream().filter(b -> b.getName().equals(bucketName)).findFirst(); + } + + /** + * @param bucketName bucket名称 + * @see AWS API + * Documentation + */ + @SneakyThrows + public void removeBucket(String bucketName) { + amazonS3.deleteBucket(bucketName); + } + + /** + * 根据文件前置查询文件 + * @param bucketName bucket名称 + * @param prefix 前缀 + * @param recursive 是否递归查询 + * @return S3ObjectSummary 列表 + * @see AWS + * API Documentation + */ + @SneakyThrows + public List getAllObjectsByPrefix(String bucketName, String prefix, boolean recursive) { + ObjectListing objectListing = amazonS3.listObjects(bucketName, prefix); + return new ArrayList<>(objectListing.getObjectSummaries()); + } + + /** + * 获取文件外链 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param expires 过期时间 <=7 + * @return url + * @see AmazonS3#generatePresignedUrl(String bucketName, String key, Date expiration) + */ + @SneakyThrows + public String getObjectURL(String bucketName, String objectName, Integer expires) { + Date date = new Date(); + Calendar calendar = new GregorianCalendar(); + calendar.setTime(date); + calendar.add(Calendar.DAY_OF_MONTH, expires); + URL url = amazonS3.generatePresignedUrl(bucketName, objectName, calendar.getTime()); + return url.toString(); + } + + /** + * 获取文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @return 二进制流 + * @see AWS + * API Documentation + */ + @SneakyThrows + public S3Object getObject(String bucketName, String objectName) { + return amazonS3.getObject(bucketName, objectName); + } + + /** + * 上传文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param stream 文件流 + * @throws Exception + */ + public void putObject(String bucketName, String objectName, InputStream stream) throws Exception { + putObject(bucketName, objectName, stream, stream.available(), "application/octet-stream"); + } + + /** + * 上传文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param stream 文件流 + * @param contextType 文件类型 + * @throws Exception + */ + public void putObject(String bucketName, String objectName, InputStream stream, String contextType) + throws Exception { + putObject(bucketName, objectName, stream, stream.available(), contextType); + } + + /** + * 上传文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @param stream 文件流 + * @param size 大小 + * @param contextType 类型 + * @throws Exception + * @see AWS + * API Documentation + */ + public PutObjectResult putObject(String bucketName, String objectName, InputStream stream, long size, + String contextType) throws Exception { + // String fileName = getFileName(objectName); + byte[] bytes = IOUtils.toByteArray(stream); + ObjectMetadata objectMetadata = new ObjectMetadata(); + objectMetadata.setContentLength(size); + objectMetadata.setContentType(contextType); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); + // 上传 + return amazonS3.putObject(bucketName, objectName, byteArrayInputStream, objectMetadata); + + } + + /** + * 获取文件信息 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @see AWS + * API Documentation + */ + public S3Object getObjectInfo(String bucketName, String objectName) throws Exception { + @Cleanup + S3Object object = amazonS3.getObject(bucketName, objectName); + return object; + } + + /** + * 删除文件 + * @param bucketName bucket名称 + * @param objectName 文件名称 + * @throws Exception + * @see AWS API + * Documentation + */ + public void removeObject(String bucketName, String objectName) throws Exception { + amazonS3.deleteObject(bucketName, objectName); + } + + @Override + public void afterPropertiesSet() { + ClientConfiguration clientConfiguration = new ClientConfiguration(); + clientConfiguration.setMaxConnections(properties.getOss().getMaxConnections()); + + AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration( + properties.getOss().getEndpoint(), properties.getOss().getRegion()); + AWSCredentials awsCredentials = new BasicAWSCredentials(properties.getOss().getAccessKey(), + properties.getOss().getSecretKey()); + AWSCredentialsProvider awsCredentialsProvider = new AWSStaticCredentialsProvider(awsCredentials); + this.amazonS3 = AmazonS3Client.builder().withEndpointConfiguration(endpointConfiguration) + .withClientConfiguration(clientConfiguration).withCredentials(awsCredentialsProvider) + .disableChunkedEncoding().withPathStyleAccessEnabled(properties.getOss().getPathStyleAccess()).build(); + } + +} diff --git a/pig-common/pig-common-oss/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/pig-common/pig-common-oss/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..ae145c04 --- /dev/null +++ b/pig-common/pig-common-oss/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.pig4cloud.pig.common.file.FileAutoConfiguration diff --git a/pig-common/pig-common-seata/pom.xml b/pig-common/pig-common-seata/pom.xml index 6b80cb4a..fc5832e6 100755 --- a/pig-common/pig-common-seata/pom.xml +++ b/pig-common/pig-common-seata/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-seata diff --git a/pig-common/pig-common-security/pom.xml b/pig-common/pig-common-security/pom.xml index 469aa634..b5d0a9cf 100755 --- a/pig-common/pig-common-security/pom.xml +++ b/pig-common/pig-common-security/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-security diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigCustomOAuth2AccessTokenResponseHttpMessageConverter.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigCustomOAuth2AccessTokenResponseHttpMessageConverter.java new file mode 100644 index 00000000..378240fc --- /dev/null +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigCustomOAuth2AccessTokenResponseHttpMessageConverter.java @@ -0,0 +1,51 @@ +package com.pig4cloud.pig.common.security.component; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.pig4cloud.pig.common.core.util.SpringContextHolder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.convert.converter.Converter; +import org.springframework.http.HttpOutputMessage; +import org.springframework.http.MediaType; +import org.springframework.http.converter.GenericHttpMessageConverter; +import org.springframework.http.converter.HttpMessageNotWritableException; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.security.oauth2.core.endpoint.DefaultOAuth2AccessTokenResponseMapConverter; +import org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse; +import org.springframework.security.oauth2.core.http.converter.OAuth2AccessTokenResponseHttpMessageConverter; + +import java.util.Map; + +/** + * 扩展原生的实现,支持 Long2String + * + * @author lengleng + * @date 2023/6/28 + */ +public class PigCustomOAuth2AccessTokenResponseHttpMessageConverter + extends OAuth2AccessTokenResponseHttpMessageConverter { + + private static final ParameterizedTypeReference> STRING_OBJECT_MAP = new ParameterizedTypeReference>() { + }; + + private Converter> accessTokenResponseParametersConverter = new DefaultOAuth2AccessTokenResponseMapConverter(); + + @Override + protected void writeInternal(OAuth2AccessTokenResponse tokenResponse, HttpOutputMessage outputMessage) + throws HttpMessageNotWritableException { + try { + Map tokenResponseParameters = this.accessTokenResponseParametersConverter + .convert(tokenResponse); + + ObjectMapper objectMapper = SpringContextHolder.getBean(ObjectMapper.class); + GenericHttpMessageConverter jsonMessageConverter = new MappingJackson2HttpMessageConverter( + objectMapper); + jsonMessageConverter.write(tokenResponseParameters, STRING_OBJECT_MAP.getType(), MediaType.APPLICATION_JSON, + outputMessage); + } + catch (Exception ex) { + throw new HttpMessageNotWritableException( + "An error occurred writing the OAuth 2.0 Access Token Response: " + ex.getMessage(), ex); + } + } + +} diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfiguration.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfiguration.java index 7e96317d..c86fd288 100644 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfiguration.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfiguration.java @@ -24,6 +24,8 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector; import org.springframework.security.web.SecurityFilterChain; @@ -59,12 +61,8 @@ public class PigResourceServerConfiguration { oauth2 -> oauth2.opaqueToken(token -> token.introspector(customOpaqueTokenIntrospector)) .authenticationEntryPoint(resourceAuthExceptionEntryPoint) .bearerTokenResolver(pigBearerTokenExtractor)) - .headers() - .frameOptions() - .disable() - .and() - .csrf() - .disable(); + .headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) + .csrf(AbstractHttpConfigurer::disable); return http.build(); } diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigAppUserDetailsServiceImpl.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigAppUserDetailsServiceImpl.java index 2da51253..93a718af 100755 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigAppUserDetailsServiceImpl.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigAppUserDetailsServiceImpl.java @@ -16,6 +16,7 @@ package com.pig4cloud.pig.common.security.service; +import com.pig4cloud.pig.admin.api.dto.UserDTO; import com.pig4cloud.pig.admin.api.dto.UserInfo; import com.pig4cloud.pig.admin.api.feign.RemoteUserService; import com.pig4cloud.pig.common.core.constant.CacheConstants; @@ -54,7 +55,9 @@ public class PigAppUserDetailsServiceImpl implements PigUserDetailsService { return (PigUser) cache.get(phone).get(); } - R result = remoteUserService.infoByMobile(phone); + UserDTO userDTO = new UserDTO(); + userDTO.setPhone(phone); + R result = remoteUserService.info(userDTO, SecurityConstants.FROM_IN); UserDetails userDetails = getUserDetails(result); if (cache != null) { @@ -80,7 +83,7 @@ public class PigAppUserDetailsServiceImpl implements PigUserDetailsService { */ @Override public boolean support(String clientId, String grantType) { - return SecurityConstants.APP.equals(grantType); + return SecurityConstants.MOBILE.equals(grantType); } } diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java index 3edf3ed6..ea0d5200 100644 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java @@ -19,7 +19,6 @@ import org.springframework.security.oauth2.server.authorization.client.Registere import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; import org.springframework.security.oauth2.server.authorization.settings.OAuth2TokenFormat; import org.springframework.security.oauth2.server.authorization.settings.TokenSettings; -import org.springframework.util.StringUtils; import java.time.Duration; import java.util.Arrays; @@ -86,7 +85,8 @@ public class PigRemoteRegisteredClientRepository implements RegisteredClientRepo @Cacheable(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientId", unless = "#result == null") public RegisteredClient findByClientId(String clientId) { - SysOauthClientDetails clientDetails = RetOps.of(clientDetailsService.getClientDetailsById(clientId)) + SysOauthClientDetails clientDetails = RetOps + .of(clientDetailsService.getClientDetailsById(clientId, SecurityConstants.FROM_IN)) .getData() .orElseThrow(() -> new OAuth2AuthorizationCodeRequestAuthenticationException( new OAuth2Error("客户端查询异常,请检查数据库链接"), null)); @@ -96,10 +96,10 @@ public class PigRemoteRegisteredClientRepository implements RegisteredClientRepo .clientSecret(SecurityConstants.NOOP + clientDetails.getClientSecret()) .clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC); - // 授权模式 - Optional.ofNullable(clientDetails.getAuthorizedGrantTypes()) - .ifPresent(grants -> StringUtils.commaDelimitedListToSet(grants) - .forEach(s -> builder.authorizationGrantType(new AuthorizationGrantType(s)))); + for (String authorizedGrantType : clientDetails.getAuthorizedGrantTypes()) { + builder.authorizationGrantType(new AuthorizationGrantType(authorizedGrantType)); + + } // 回调地址 Optional.ofNullable(clientDetails.getWebServerRedirectUri()) .ifPresent(redirectUri -> Arrays.stream(redirectUri.split(StrUtil.COMMA)) diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java index 0eb0b862..9a330a86 100755 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java @@ -16,9 +16,11 @@ package com.pig4cloud.pig.common.security.service; +import com.pig4cloud.pig.admin.api.dto.UserDTO; import com.pig4cloud.pig.admin.api.dto.UserInfo; import com.pig4cloud.pig.admin.api.feign.RemoteUserService; import com.pig4cloud.pig.common.core.constant.CacheConstants; +import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.util.R; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -55,7 +57,9 @@ public class PigUserDetailsServiceImpl implements PigUserDetailsService { return (PigUser) cache.get(username).get(); } - R result = remoteUserService.info(username); + UserDTO userDTO = new UserDTO(); + userDTO.setUsername(username); + R result = remoteUserService.info(userDTO,SecurityConstants.FROM_IN); UserDetails userDetails = getUserDetails(result); if (cache != null) { cache.put(username, userDetails); diff --git a/pig-common/pig-common-swagger/pom.xml b/pig-common/pig-common-swagger/pom.xml index e9eacb17..ea48864e 100644 --- a/pig-common/pig-common-swagger/pom.xml +++ b/pig-common/pig-common-swagger/pom.xml @@ -24,7 +24,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-swagger diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigDoc.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigDoc.java index ac9ce3a6..5f828ee6 100644 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigDoc.java +++ b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigDoc.java @@ -29,7 +29,7 @@ import java.lang.annotation.*; * @author lengleng * @date 2022-03-26 */ -@Target({ElementType.TYPE}) +@Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @@ -37,18 +37,16 @@ import java.lang.annotation.*; @Import(OpenAPIDefinitionImportSelector.class) public @interface EnablePigDoc { - /** - * 网关路由前缀 - * - * @return String - */ - String value(); + /** + * 网关路由前缀 + * @return String + */ + String value(); - /** - * 是否是微服务架构 - * - * @return true - */ - boolean isMicro() default true; + /** + * 是否是微服务架构 + * @return true + */ + boolean isMicro() default true; } diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIDefinitionImportSelector.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIDefinitionImportSelector.java index 0177da08..d90e9f21 100644 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIDefinitionImportSelector.java +++ b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIDefinitionImportSelector.java @@ -17,25 +17,25 @@ import java.util.Objects; */ public class OpenAPIDefinitionImportSelector implements ImportBeanDefinitionRegistrar { - @Override - public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { + @Override + public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { - Map annotationAttributes = metadata.getAnnotationAttributes(EnablePigDoc.class.getName(), true); - Object value = annotationAttributes.get("value"); - if (Objects.isNull(value)) { - return; - } + Map annotationAttributes = metadata.getAnnotationAttributes(EnablePigDoc.class.getName(), true); + Object value = annotationAttributes.get("value"); + if (Objects.isNull(value)) { + return; + } - BeanDefinitionBuilder openAPIMetadataRegister = BeanDefinitionBuilder.genericBeanDefinition(OpenAPIMetadataRegister.class); - openAPIMetadataRegister.addPropertyValue("path", value); + BeanDefinitionBuilder openAPIMetadataRegister = BeanDefinitionBuilder + .genericBeanDefinition(OpenAPIMetadataRegister.class); + openAPIMetadataRegister.addPropertyValue("path", value); - registry.registerBeanDefinition("openAPIMetadataRegister", openAPIMetadataRegister.getBeanDefinition()); + registry.registerBeanDefinition("openAPIMetadataRegister", openAPIMetadataRegister.getBeanDefinition()); + BeanDefinitionBuilder openAPIDefinition = BeanDefinitionBuilder.genericBeanDefinition(OpenAPIDefinition.class); + openAPIDefinition.addPropertyValue("path", value); + registry.registerBeanDefinition("openAPIDefinition", openAPIDefinition.getBeanDefinition()); - BeanDefinitionBuilder openAPIDefinition = BeanDefinitionBuilder.genericBeanDefinition(OpenAPIDefinition.class); - openAPIDefinition.addPropertyValue("path", value); - registry.registerBeanDefinition("openAPIDefinition", openAPIDefinition.getBeanDefinition()); - - } + } } diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIMetadataRegister.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIMetadataRegister.java index 775e7a63..eee84ebb 100644 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIMetadataRegister.java +++ b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/OpenAPIMetadataRegister.java @@ -13,21 +13,20 @@ import org.springframework.context.ApplicationContextAware; */ public class OpenAPIMetadataRegister implements InitializingBean, ApplicationContextAware { - private ApplicationContext applicationContext; + private ApplicationContext applicationContext; - @Setter - private String path; + @Setter + private String path; + @Override + public void afterPropertiesSet() { + ServiceInstance serviceInstance = applicationContext.getBean(ServiceInstance.class); + serviceInstance.getMetadata().put("spring-doc", path); + } - @Override - public void afterPropertiesSet() { - ServiceInstance serviceInstance = applicationContext.getBean(ServiceInstance.class); - serviceInstance.getMetadata().put("spring-doc", path); - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } } diff --git a/pig-common/pig-common-xss/pom.xml b/pig-common/pig-common-xss/pom.xml index 5e3cc1a2..99de40c5 100755 --- a/pig-common/pig-common-xss/pom.xml +++ b/pig-common/pig-common-xss/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pig-common - 3.6.4 + 3.7.0-SNAPSHOT pig-common-xss diff --git a/pig-common/pom.xml b/pig-common/pom.xml index 8c24c931..73e8ab72 100755 --- a/pig-common/pom.xml +++ b/pig-common/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.6.4 + 3.7.0-SNAPSHOT pig-common @@ -36,6 +36,7 @@ pig-common-job pig-common-log pig-common-mybatis + pig-common-oss pig-common-seata pig-common-security pig-common-feign diff --git a/pig-gateway/pom.xml b/pig-gateway/pom.xml index cbace3d8..9649ac27 100755 --- a/pig-gateway/pom.xml +++ b/pig-gateway/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.6.4 + 3.7.0-SNAPSHOT pig-gateway diff --git a/pig-register/pom.xml b/pig-register/pom.xml index 00590933..6f79e57c 100644 --- a/pig-register/pom.xml +++ b/pig-register/pom.xml @@ -18,7 +18,7 @@ com.pig4cloud pig - 3.6.4 + 3.7.0-SNAPSHOT pig-register diff --git a/pig-upms/pig-upms-api/pom.xml b/pig-upms/pig-upms-api/pom.xml index 9b5641da..9e6d05b7 100755 --- a/pig-upms/pig-upms-api/pom.xml +++ b/pig-upms/pig-upms-api/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-upms - 3.6.4 + 3.7.0-SNAPSHOT pig-upms-api diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/AppSmsDTO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/AppSmsDTO.java deleted file mode 100644 index b0c98275..00000000 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/AppSmsDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.pig4cloud.pig.admin.api.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotBlank; - -/** - * 客户端请求验证码 - * - * @author lengleng - * @date 2022/10/13 - */ -@Data -public class AppSmsDTO { - - /** - * 手机号 - */ - @NotBlank(message = "手机号不能为空") - private String phone; - - /** - * 手机号是否存在数据库 - */ - private Boolean exist; - -} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/RoleDTO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/RoleDTO.java deleted file mode 100755 index 5f5f0fdb..00000000 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/RoleDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.api.dto; - -import com.pig4cloud.pig.admin.api.entity.SysRole; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * @author lengleng - * @date 2019/2/1 角色Dto - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class RoleDTO extends SysRole { - - /** - * 角色部门Id - */ - private Long roleDeptId; - - /** - * 部门名称 - */ - private String deptName; - -} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java index fc66c8fe..032c5a52 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java @@ -1,6 +1,7 @@ package com.pig4cloud.pig.admin.api.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import java.time.LocalDateTime; @@ -16,20 +17,75 @@ import java.time.LocalDateTime; public class SysLogDTO { /** - * 查询日志类型 + * 编号 */ - @Schema(description = "日志类型") - private String type; + private Long id; + + /** + * 日志类型 + */ + @NotBlank(message = "日志类型不能为空") + private String logType; + + /** + * 日志标题 + */ + @NotBlank(message = "日志标题不能为空") + private String title; + + /** + * 创建者 + */ + private String createBy; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; + + /** + * 操作IP地址 + */ + private String remoteAddr; + + /** + * 用户代理 + */ + private String userAgent; + + /** + * 请求URI + */ + private String requestUri; + + /** + * 操作方式 + */ + private String method; + + /** + * 操作提交的数据 + */ + private String params; + + /** + * 执行时间 + */ + private Long time; + + /** + * 异常信息 + */ + private String exception; + + /** + * 服务ID + */ + private String serviceId; /** * 创建时间区间 [开始时间,结束时间] */ - @Schema(description = "创建时间区间") private LocalDateTime[] createTime; - /** - * 请求IP - */ - private String remoteAddr; - } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserDTO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserDTO.java index 972b2b46..287bae3f 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserDTO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserDTO.java @@ -1,22 +1,26 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.dto; import com.pig4cloud.pig.admin.api.entity.SysUser; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -24,17 +28,23 @@ import java.util.List; /** * @author lengleng - * @date 2019/2/1 + * @date 2017/11/5 */ @Data +@Schema(description = "系统用户传输对象") @EqualsAndHashCode(callSuper = true) public class UserDTO extends SysUser { /** * 角色ID */ + @Schema(description = "角色id集合") private List role; + /** + * 部门id + */ + @Schema(description = "部门id") private Long deptId; /** @@ -45,11 +55,7 @@ public class UserDTO extends SysUser { /** * 新密码 */ + @Schema(description = "新密码") private String newpassword1; - /** - * 验证码 - */ - private String code; - } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserInfo.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserInfo.java index 789f51e3..d0558648 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserInfo.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/UserInfo.java @@ -1,67 +1,54 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.dto; -import com.pig4cloud.pig.admin.api.entity.SysPost; -import com.pig4cloud.pig.admin.api.entity.SysRole; import com.pig4cloud.pig.admin.api.entity.SysUser; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.io.Serializable; -import java.util.List; /** * @author lengleng - * @date 2019/2/1 - *

- * commit('SET_ROLES', data) commit('SET_NAME', data) commit('SET_AVATAR', data) - * commit('SET_INTRODUCTION', data) commit('SET_PERMISSIONS', data) + * @date 2017/11/11 */ @Data +@Schema(description = "用户信息") public class UserInfo implements Serializable { /** * 用户基本信息 */ + @Schema(description = "用户基本信息") private SysUser sysUser; /** * 权限标识集合 */ + @Schema(description = "权限标识集合") private String[] permissions; /** * 角色集合 */ + @Schema(description = "角色标识集合") private Long[] roles; - /** - * 角色集合 - */ - private List roleList; - - /** - * 岗位集合 - */ - private Long[] posts; - - /** - * 岗位集合 - */ - private List postList; - } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java index a1b40fef..c0d8da1f 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java @@ -1,31 +1,33 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; +import java.time.LocalDateTime; /** *

@@ -33,12 +35,12 @@ import jakarta.validation.constraints.NotNull; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-01-22 */ -@Schema(description = "部门") @Data +@Schema(description = "部门") @EqualsAndHashCode(callSuper = true) -public class SysDept extends BaseEntity { +public class SysDept extends Model { private static final long serialVersionUID = 1L; @@ -50,16 +52,44 @@ public class SysDept extends BaseEntity { * 部门名称 */ @NotBlank(message = "部门名称不能为空") - @Schema(description = "部门名称", required = true) + @Schema(description = "部门名称") private String name; /** * 排序 */ - @NotNull(message = "部门排序值不能为空") - @Schema(description = "排序值", required = true) + @NotNull(message = "排序值不能为空") + @Schema(description = "排序值") private Integer sortOrder; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @Schema(description = "修改时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + /** * 父级部门id */ @@ -67,9 +97,11 @@ public class SysDept extends BaseEntity { private Long parentId; /** - * 是否删除 -1:已删除 0:正常 + * 是否删除 1:已删除 0:正常 */ @TableLogic + @Schema(description = "删除标记,1:已删除,0:正常") + @TableField(fill = FieldFill.INSERT) private String delFlag; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java index 8fbfea7f..133622cc 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; @@ -27,10 +30,10 @@ import lombok.EqualsAndHashCode; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-01-22 */ -@Schema(description = "部门关系") @Data +@Schema(description = "部门关系") @EqualsAndHashCode(callSuper = true) public class SysDeptRelation extends Model { diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java index 28434df2..31b9829a 100755 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java @@ -1,28 +1,29 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; + /** * 字典表 * @@ -32,7 +33,7 @@ import lombok.EqualsAndHashCode; @Data @Schema(description = "字典类型") @EqualsAndHashCode(callSuper = true) -public class SysDict extends BaseEntity { +public class SysDict extends Model { private static final long serialVersionUID = 1L; @@ -46,8 +47,8 @@ public class SysDict extends BaseEntity { /** * 类型 */ - @Schema(description = "字典key") - private String dictKey; + @Schema(description = "字典类型") + private String dictType; /** * 描述 @@ -55,6 +56,20 @@ public class SysDict extends BaseEntity { @Schema(description = "字典描述") private String description; + /** + * 创建时间 + */ + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @Schema(description = "更新时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + /** * 是否是系统内置 */ @@ -65,12 +80,27 @@ public class SysDict extends BaseEntity { * 备注信息 */ @Schema(description = "备注信息") - private String remark; + private String remarks; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; /** * 删除标记 */ @TableLogic + @TableField(fill = FieldFill.INSERT) @Schema(description = "删除标记,1:已删除,0:正常") private String delFlag; diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java index 410edfbd..eed39f70 100755 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java @@ -1,28 +1,30 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; + /** * 字典项 * @@ -32,7 +34,7 @@ import lombok.EqualsAndHashCode; @Data @Schema(description = "字典项") @EqualsAndHashCode(callSuper = true) -public class SysDictItem extends BaseEntity { +public class SysDictItem extends Model { private static final long serialVersionUID = 1L; @@ -49,17 +51,12 @@ public class SysDictItem extends BaseEntity { @Schema(description = "所属字典类id") private Long dictId; - /** - * 所属字典类id - */ - @Schema(description = "所属字典类key") - private String dictKey; - /** * 数据值 */ @Schema(description = "数据值") - private String value; + @JsonProperty(value = "value") + private String itemValue; /** * 标签名 @@ -71,7 +68,7 @@ public class SysDictItem extends BaseEntity { * 类型 */ @Schema(description = "类型") - private String type; + private String dictType; /** * 描述 @@ -85,16 +82,45 @@ public class SysDictItem extends BaseEntity { @Schema(description = "排序值,默认升序") private Integer sortOrder; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; + /** * 备注信息 */ @Schema(description = "备注信息") - private String remark; + private String remarks; /** * 删除标记 */ @TableLogic + @TableField(fill = FieldFill.INSERT) @Schema(description = "删除标记,1:已删除,0:正常") private String delFlag; diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysFile.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysFile.java index 78882a35..c86ec837 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysFile.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysFile.java @@ -17,13 +17,14 @@ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; + /** * 文件管理 * @@ -31,8 +32,9 @@ import lombok.EqualsAndHashCode; * @date 2019-06-18 17:18:42 */ @Data +@Schema(description = "文件") @EqualsAndHashCode(callSuper = true) -public class SysFile extends BaseEntity { +public class SysFile extends Model { private static final long serialVersionUID = 1L; @@ -40,37 +42,73 @@ public class SysFile extends BaseEntity { * 编号 */ @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "文件编号") private Long id; /** * 文件名 */ + @Schema(description = "文件名") private String fileName; /** * 原文件名 */ + @Schema(description = "原始文件名") private String original; /** * 容器名称 */ + @Schema(description = "存储桶名称") private String bucketName; /** * 文件类型 */ + @Schema(description = "文件类型") private String type; /** * 文件大小 */ + @Schema(description = "文件大小") private Long fileSize; + /** + * 上传人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建者") + private String createBy; + + /** + * 上传时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "更新者") + private String updateBy; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; + /** * 删除标识:1-删除,0-正常 */ @TableLogic - private Integer delFlag; + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") + private String delFlag; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java index 08079e92..55072eb5 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java @@ -1,34 +1,33 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; /** *

@@ -36,21 +35,20 @@ import jakarta.validation.constraints.NotBlank; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-11-20 */ @Data -@EqualsAndHashCode(callSuper = true) -public class SysLog extends BaseEntity { +@Schema(description = "日志") +public class SysLog implements Serializable { private static final long serialVersionUID = 1L; /** * 编号 */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(type = IdType.ASSIGN_ID) @ExcelProperty("日志编号") @Schema(description = "日志编号") - @JsonSerialize(using = ToStringSerializer.class) private Long id; /** @@ -59,7 +57,7 @@ public class SysLog extends BaseEntity { @NotBlank(message = "日志类型不能为空") @ExcelProperty("日志类型(0-正常 9-错误)") @Schema(description = "日志类型") - private String type; + private String logType; /** * 日志标题 @@ -69,24 +67,47 @@ public class SysLog extends BaseEntity { @Schema(description = "日志标题") private String title; + /** + * 创建者 + */ + @ExcelProperty("创建人") + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 创建时间 + */ + @ExcelProperty("创建时间") + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @ExcelIgnore + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; + /** * 操作IP地址 */ - @ExcelProperty("IP") + @ExcelProperty("操作ip地址") @Schema(description = "操作ip地址") private String remoteAddr; /** - * 用户浏览器 + * 用户代理 */ - @ExcelProperty("浏览器类型") @Schema(description = "用户代理") private String userAgent; /** * 请求URI */ - @ExcelProperty("请求URI") + @ExcelProperty("浏览器") @Schema(description = "请求uri") private String requestUri; @@ -100,14 +121,14 @@ public class SysLog extends BaseEntity { /** * 操作提交的数据 */ - @ExcelProperty("请求参数") - @Schema(description = "数据") + @ExcelProperty("提交数据") + @Schema(description = "提交数据") private String params; /** * 执行时间 */ - @ExcelProperty("方法执行时间") + @ExcelProperty("执行时间") @Schema(description = "方法执行时间") private Long time; @@ -130,6 +151,8 @@ public class SysLog extends BaseEntity { */ @TableLogic @ExcelIgnore + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") private String delFlag; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java index 57a6de6a..ec8d85dc 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java @@ -1,31 +1,33 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; +import java.time.LocalDateTime; /** *

@@ -33,11 +35,12 @@ import jakarta.validation.constraints.NotNull; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-11-08 */ @Data +@Schema(description = "菜单") @EqualsAndHashCode(callSuper = true) -public class SysMenu extends BaseEntity { +public class SysMenu extends Model { private static final long serialVersionUID = 1L; @@ -55,6 +58,12 @@ public class SysMenu extends BaseEntity { @Schema(description = "菜单名称") private String name; + /** + * 菜单名称 + */ + @Schema(description = "菜单名称") + private String enName; + /** * 菜单权限标识 */ @@ -75,11 +84,17 @@ public class SysMenu extends BaseEntity { private String icon; /** - * 前端URL + * 前端路由标识路径,默认和 comment 保持一致 过期 */ @Schema(description = "前端路由标识路径") private String path; + /** + * 菜单显示隐藏控制 + */ + @Schema(description = "菜单是否显示") + private String visible; + /** * 排序值 */ @@ -90,7 +105,8 @@ public class SysMenu extends BaseEntity { * 菜单类型 (0菜单 1按钮) */ @NotNull(message = "菜单类型不能为空") - private String type; + @Schema(description = "菜单类型,0:菜单 1:按钮") + private String menuType; /** * 路由缓冲 @@ -98,10 +114,43 @@ public class SysMenu extends BaseEntity { @Schema(description = "路由缓冲") private String keepAlive; + @Schema(description = "菜单是否内嵌") + private String embedded; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; + /** * 0--正常 1--删除 */ @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") private String delFlag; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java index a695d7ae..79c8333c 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java @@ -1,29 +1,32 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import jakarta.validation.constraints.NotBlank; +import java.time.LocalDateTime; /** *

@@ -31,19 +34,23 @@ import jakarta.validation.constraints.NotBlank; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-05-15 */ @Data +@Schema(description = "客户端信息") @EqualsAndHashCode(callSuper = true) -public class SysOauthClientDetails extends BaseEntity { +public class SysOauthClientDetails extends Model { private static final long serialVersionUID = 1L; + @TableId(value = "id", type = IdType.ASSIGN_ID) + @Schema(description = "id") + private Long id; + /** * 客户端ID */ @NotBlank(message = "client_id 不能为空") - @TableId(value = "client_id", type = IdType.INPUT) @Schema(description = "客户端id") private String clientId; @@ -68,10 +75,10 @@ public class SysOauthClientDetails extends BaseEntity { private String scope; /** - * 授权方式(A,B,C) + * 授权方式[A,B,C] */ @Schema(description = "授权方式") - private String authorizedGrantTypes; + private String[] authorizedGrantTypes; /** * 回调地址 @@ -109,4 +116,40 @@ public class SysOauthClientDetails extends BaseEntity { @Schema(description = "是否自动放行") private String autoapprove; + /** + * 删除标记 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") + private String delFlag; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; + } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java index 5cd02780..542cb211 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java @@ -14,65 +14,101 @@ * this software without specific prior written permission. * Author: lengleng (wangiegie@gmail.com) */ + package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; + /** - * 岗位管理 + * 岗位信息表 * * @author fxz - * @date 2022-03-15 17:18:40 + * @date 2022-03-26 12:50:43 */ @Data @TableName("sys_post") @EqualsAndHashCode(callSuper = true) @Schema(description = "岗位信息表") -public class SysPost extends BaseEntity { +public class SysPost extends Model { - private static final long serialVersionUID = -8744622014102311894L; + private static final long serialVersionUID = 1L; /** * 岗位ID */ - @TableId(type = IdType.ASSIGN_ID) + @TableId(value = "post_id", type = IdType.ASSIGN_ID) @Schema(description = "岗位ID") private Long postId; /** * 岗位编码 */ + @NotBlank(message = "岗位编码不能为空") @Schema(description = "岗位编码") private String postCode; /** * 岗位名称 */ + @NotBlank(message = "岗位名称不能为空") @Schema(description = "岗位名称") private String postName; /** * 岗位排序 */ + @NotNull(message = "排序值不能为空") @Schema(description = "岗位排序") private Integer postSort; + /** + * 岗位描述 + */ + @Schema(description = "岗位描述") + private String remark; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + /** * 是否删除 -1:已删除 0:正常 */ + @TableLogic + @TableField(fill = FieldFill.INSERT) @Schema(description = "是否删除 -1:已删除 0:正常") private String delFlag; /** - * 备注信息 + * 创建时间 */ - @Schema(description = "备注信息") - private String remark; + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @Schema(description = "更新时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java index 51893a77..a6eb7416 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java @@ -17,13 +17,14 @@ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; + /** * 公共参数配置 * @@ -33,7 +34,7 @@ import lombok.EqualsAndHashCode; @Data @Schema(description = "公共参数") @EqualsAndHashCode(callSuper = true) -public class SysPublicParam extends BaseEntity { +public class SysPublicParam extends Model { private static final long serialVersionUID = 1L; @@ -86,4 +87,40 @@ public class SysPublicParam extends BaseEntity { @Schema(description = "类型[1-检索;2-原文...]", example = "1") private String publicType; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 删除标记 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") + private String delFlag; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; + } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java index 1a51d347..2e49937c 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java @@ -1,30 +1,32 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import jakarta.validation.constraints.NotBlank; +import java.time.LocalDateTime; /** *

@@ -32,11 +34,12 @@ import jakarta.validation.constraints.NotBlank; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Data +@Schema(description = "角色") @EqualsAndHashCode(callSuper = true) -public class SysRole extends BaseEntity { +public class SysRole extends Model { private static final long serialVersionUID = 1L; @@ -44,22 +47,51 @@ public class SysRole extends BaseEntity { @Schema(description = "角色编号") private Long roleId; - @NotBlank(message = "角色名称 不能为空") + @NotBlank(message = "角色名称不能为空") @Schema(description = "角色名称") private String roleName; - @NotBlank(message = "角色标识 不能为空") + @NotBlank(message = "角色标识不能为空") @Schema(description = "角色标识") private String roleCode; - @NotBlank(message = "角色描述 不能为空") @Schema(description = "角色描述") private String roleDesc; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @Schema(description = "修改时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + /** * 删除标识(0-正常,1-删除) */ @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") private String delFlag; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java index 5573bcb7..bdc264f7 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; @@ -27,9 +30,10 @@ import lombok.EqualsAndHashCode; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Data +@Schema(description = "角色菜单") @EqualsAndHashCode(callSuper = true) public class SysRoleMenu extends Model { diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java index 919f1461..0c4c9142 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java @@ -1,29 +1,31 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.*; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.time.LocalDateTime; /** *

@@ -31,11 +33,11 @@ import lombok.EqualsAndHashCode; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Data -@EqualsAndHashCode(callSuper = true) -public class SysUser extends BaseEntity { +@Schema(description = "用户") +public class SysUser implements Serializable { private static final long serialVersionUID = 1L; @@ -49,7 +51,7 @@ public class SysUser extends BaseEntity { /** * 用户名 */ - @Schema(title = "用户名") + @Schema(description = "用户名") private String username; /** @@ -65,6 +67,42 @@ public class SysUser extends BaseEntity { @Schema(description = "随机盐") private String salt; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改时间") + private LocalDateTime updateTime; + + /** + * 0-正常,1-删除 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") + private String delFlag; + /** * 锁定标记 */ @@ -90,9 +128,51 @@ public class SysUser extends BaseEntity { private Long deptId; /** - * 0-正常,1-删除 + * 微信openid */ - @TableLogic - private String delFlag; + @Schema(description = "微信openid") + private String wxOpenid; + + /** + * 微信小程序openId + */ + @Schema(description = "微信小程序openid") + private String miniOpenid; + + /** + * QQ openid + */ + @Schema(description = "QQ openid") + private String qqOpenid; + + /** + * 码云唯一标识 + */ + @Schema(description = "码云唯一标识") + private String giteeLogin; + + /** + * 开源中国唯一标识 + */ + @Schema(description = "开源中国唯一标识") + private String oscId; + + /** + * 昵称 + */ + @Schema(description = "昵称") + private String nickname; + + /** + * 姓名 + */ + @Schema(description = "姓名") + private String name; + + /** + * 邮箱 + */ + @Schema(description = "邮箱") + private String email; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java index 93d4e63c..ffb92d8e 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.entity; @@ -27,9 +30,10 @@ import lombok.EqualsAndHashCode; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Data +@Schema(description = "用户角色") @EqualsAndHashCode(callSuper = true) public class SysUserRole extends Model { diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteClientDetailsService.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteClientDetailsService.java index e130bd89..c5e788b4 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteClientDetailsService.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteClientDetailsService.java @@ -26,6 +26,7 @@ import com.pig4cloud.pig.common.core.util.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; import java.util.List; @@ -33,22 +34,25 @@ import java.util.List; * @author lengleng * @date 2020/12/05 */ -@FeignClient(contextId = "remoteClientDetailsService", value = ServiceNameConstants.UMPS_SERVICE) +@FeignClient(contextId = "remoteClientDetailsService", value = ServiceNameConstants.UPMS_SERVICE) public interface RemoteClientDetailsService { /** * 通过clientId 查询客户端信息 * @param clientId 用户名 + * @param from 调用标志 * @return R */ - @GetMapping(value = "/client/getClientDetailsById/{clientId}", headers = SecurityConstants.HEADER_FROM_IN) - R getClientDetailsById(@PathVariable("clientId") String clientId); + @GetMapping("/client/getClientDetailsById/{clientId}") + R getClientDetailsById(@PathVariable("clientId") String clientId, + @RequestHeader(SecurityConstants.FROM) String from); /** * 查询全部客户端 + * @param from 调用标识 * @return R */ - @GetMapping(value = "/client/list", headers = SecurityConstants.HEADER_FROM_IN) - R> listClientDetails(); + @GetMapping("/client/list") + R> listClientDetails(@RequestHeader(SecurityConstants.FROM) String from); } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteDeptService.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteDeptService.java deleted file mode 100644 index 197b3015..00000000 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteDeptService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.api.feign; - -import com.pig4cloud.pig.common.core.constant.SecurityConstants; -import com.pig4cloud.pig.common.core.constant.ServiceNameConstants; -import com.pig4cloud.pig.common.core.util.R; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; - -import java.util.List; - -/** - * @author hccake - */ -@FeignClient(contextId = "remoteDeptService", value = ServiceNameConstants.UMPS_SERVICE) -public interface RemoteDeptService { - - /** - * 查收子级id列表 - * @return 返回子级id列表 - */ - @GetMapping(value = "/dept/child-id/{deptId}", headers = SecurityConstants.HEADER_FROM_IN) - R> listChildDeptId(@PathVariable("deptId") Long deptId); - -} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteDictService.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteDictService.java index 3ca11474..f17c7611 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteDictService.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteDictService.java @@ -15,7 +15,7 @@ import java.util.List; *

* 查询参数相关 */ -@FeignClient(contextId = "remoteDictService", value = ServiceNameConstants.UMPS_SERVICE) +@FeignClient(contextId = "remoteDictService", value = ServiceNameConstants.UPMS_SERVICE) public interface RemoteDictService { /** diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteLogService.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteLogService.java old mode 100755 new mode 100644 index f4fd260d..e9ad3b3c --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteLogService.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteLogService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.feign; @@ -23,20 +26,22 @@ import com.pig4cloud.pig.common.core.util.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; /** * @author lengleng - * @date 2019/2/1 + * @date 2018/6/28 */ -@FeignClient(contextId = "remoteLogService", value = ServiceNameConstants.UMPS_SERVICE) +@FeignClient(contextId = "remoteLogService", value = ServiceNameConstants.UPMS_SERVICE) public interface RemoteLogService { /** * 保存日志 * @param sysLog 日志实体 + * @param from 是否内部调用 * @return succes、false */ - @PostMapping(value = "/log", headers = SecurityConstants.HEADER_FROM_IN) - R saveLog(@RequestBody SysLog sysLog); + @PostMapping("/log/save") + R saveLog(@RequestBody SysLog sysLog, @RequestHeader(SecurityConstants.FROM) String from); } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteParamService.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteParamService.java index deb214bc..a4738418 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteParamService.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteParamService.java @@ -6,6 +6,7 @@ import com.pig4cloud.pig.common.core.util.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; /** * @author lengleng @@ -13,15 +14,16 @@ import org.springframework.web.bind.annotation.PathVariable; *

* 查询参数相关 */ -@FeignClient(contextId = "remoteParamService", value = ServiceNameConstants.UMPS_SERVICE) +@FeignClient(contextId = "remoteParamService", value = ServiceNameConstants.UPMS_SERVICE) public interface RemoteParamService { /** * 通过key 查询参数配置 * @param key key + * @param from 声明成内部调用,避免MQ 等无法调用 * @return */ - @GetMapping(value = "/param/publicValue/{key}", headers = SecurityConstants.HEADER_FROM_IN) - R getByKey(@PathVariable("key") String key); + @GetMapping("/param/publicValue/{key}") + R getByKey(@PathVariable("key") String key, @RequestHeader(SecurityConstants.FROM) String from); } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteTokenService.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteTokenService.java old mode 100755 new mode 100644 index 7976fef9..85d64872 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteTokenService.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteTokenService.java @@ -1,21 +1,23 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.api.feign; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.constant.ServiceNameConstants; import com.pig4cloud.pig.common.core.util.R; @@ -26,25 +28,39 @@ import java.util.Map; /** * @author lengleng - * @date 2019/2/1 + * @date 2018/9/4 */ @FeignClient(contextId = "remoteTokenService", value = ServiceNameConstants.AUTH_SERVICE) public interface RemoteTokenService { /** * 分页查询token 信息 + * @param from 内部调用标志 * @param params 分页参数 + * @param from 内部调用标志 * @return page */ - @PostMapping(value = "/token/page", headers = SecurityConstants.HEADER_FROM_IN) - R getTokenPage(@RequestBody Map params); + @PostMapping("/token/page") + R getTokenPage(@RequestBody Map params, @RequestHeader(SecurityConstants.FROM) String from); /** * 删除token + * @param from 内部调用标志 * @param token token + * @param from 内部调用标志 * @return */ - @DeleteMapping(value = "/token/{token}", headers = SecurityConstants.HEADER_FROM_IN) - R removeToken(@PathVariable("token") String token); + @DeleteMapping("/token/{token}") + R removeTokenById(@PathVariable("token") String token, @RequestHeader(SecurityConstants.FROM) String from); + + /** + * 校验令牌获取用户信息 + * @param token + * @param from + * @return + */ + @GetMapping("/token/query-token") + R> queryToken(@RequestParam("token") String token, + @RequestHeader(SecurityConstants.FROM) String from); } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteUserService.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteUserService.java old mode 100755 new mode 100644 index 3dfc3f08..39adc1e5 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteUserService.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/feign/RemoteUserService.java @@ -1,64 +1,57 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.feign; +import com.pig4cloud.pig.admin.api.dto.UserDTO; import com.pig4cloud.pig.admin.api.dto.UserInfo; import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.constant.ServiceNameConstants; import com.pig4cloud.pig.common.core.util.R; +import org.apache.ibatis.annotations.Param; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.List; -import java.util.Set; +import org.springframework.cloud.openfeign.SpringQueryMap; +import org.springframework.web.bind.annotation.*; /** * @author lengleng - * @date 2019/2/1 + * @date 2018/6/22 */ -@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.UMPS_SERVICE) +@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.UPMS_SERVICE) public interface RemoteUserService { /** * 通过用户名查询用户、角色信息 + * @param user 用户查询对象 + * @param from 调用标志 + * @return R + */ + @GetMapping("/user/info/query") + R info(@SpringQueryMap UserDTO user, @RequestHeader(SecurityConstants.FROM) String from); + + /** + * 锁定用户 * @param username 用户名 - * @return R + * @param from 调用标识 + * @return */ - @GetMapping(value = "/user/info/{username}", headers = SecurityConstants.HEADER_FROM_IN) - R info(@PathVariable("username") String username); - - /** - * 通过手机号码查询用户、角色信息 - * @param phone 手机号码 - * @param from 调用标志 - * @return R - */ - @GetMapping(value = "/app/info/{phone}", headers = SecurityConstants.HEADER_FROM_IN) - R infoByMobile(@PathVariable("phone") String phone); - - /** - * 根据部门id,查询对应的用户 id 集合 - * @param deptIds 部门id 集合 - * @param from 调用标志 - * @return 用户 id 集合 - */ - @GetMapping(value = "/user/ids", headers = SecurityConstants.HEADER_FROM_IN) - R> listUserIdByDeptIds(@RequestParam("deptIds") Set deptIds); + @PutMapping("/user/lock/{username}") + R lockUser(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM) String from); } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/DictResolver.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/DictResolver.java index 6c7a7193..136b9ea8 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/DictResolver.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/DictResolver.java @@ -57,7 +57,7 @@ public class DictResolver { SysDictItem sysDictItem = getDictItemByItemLabel(type, itemLabel); - return ObjectUtils.isNotEmpty(sysDictItem) ? sysDictItem.getValue() : StringPool.EMPTY; + return ObjectUtils.isNotEmpty(sysDictItem) ? sysDictItem.getItemValue() : StringPool.EMPTY; } /** @@ -72,7 +72,7 @@ public class DictResolver { List dictItemList = getDictItemsByType(type); if (CollectionUtils.isNotEmpty(dictItemList)) { - return dictItemList.stream().filter(item -> itemValue.equals(item.getValue())).findFirst().orElse(null); + return dictItemList.stream().filter(item -> itemValue.equals(item.getItemValue())).findFirst().orElse(null); } return null; diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/ParamResolver.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/ParamResolver.java index 9b4e43a0..51d0337b 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/ParamResolver.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/util/ParamResolver.java @@ -3,6 +3,7 @@ package com.pig4cloud.pig.admin.api.util; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import com.pig4cloud.pig.admin.api.feign.RemoteParamService; +import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.util.SpringContextHolder; import lombok.experimental.UtilityClass; @@ -43,7 +44,7 @@ public class ParamResolver { RemoteParamService remoteParamService = SpringContextHolder.getBean(RemoteParamService.class); - String result = remoteParamService.getByKey(key).getData(); + String result = remoteParamService.getByKey(key, SecurityConstants.FROM_IN).getData(); if (StrUtil.isNotBlank(result)) { return Convert.convert(clazz, result); diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/DeptExcelVo.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/DeptExcelVo.java new file mode 100644 index 00000000..7272f3e0 --- /dev/null +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/DeptExcelVo.java @@ -0,0 +1,44 @@ +package com.pig4cloud.pig.admin.api.vo; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.pig4cloud.plugin.excel.annotation.ExcelLine; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.io.Serializable; + +/** + * 部门导入导出 + */ +@Data +public class DeptExcelVo implements Serializable { + + /** + * 导入时候回显行号 + */ + @ExcelLine + @ExcelIgnore + private Long lineNum; + + /** + * 上级部门 + */ + @NotBlank(message = "上级部门不能为空") + @ExcelProperty("上级部门") + private String parentName; + + /** + * 部门名称 + */ + @NotBlank(message = "部门名称不能为空") + @ExcelProperty("部门名称") + private String name; + + /** + * 排序 + */ + @ExcelProperty(value = "排序值") + private Integer sortOrder; + +} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/ImageCode.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/ImageCode.java deleted file mode 100644 index 1256a5f6..00000000 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/ImageCode.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.api.vo; - -import lombok.Data; - -import java.awt.image.BufferedImage; -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * @author lengleng - * @date 2019/2/1 - */ -@Data -public class ImageCode implements Serializable { - - private String code; - - private LocalDateTime expireTime; - - private BufferedImage image; - - public ImageCode(BufferedImage image, String sRand, int defaultImageExpire) { - this.image = image; - this.code = sRand; - this.expireTime = LocalDateTime.now().plusSeconds(defaultImageExpire); - } - -} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/LogVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/LogVO.java deleted file mode 100644 index a62cf6c5..00000000 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/LogVO.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.api.vo; - -import com.pig4cloud.pig.admin.api.entity.SysLog; -import lombok.Data; - -import java.io.Serializable; - -/** - * @author lengleng - * @date 2019/2/1 - */ -@Data -public class LogVO implements Serializable { - - private static final long serialVersionUID = 1L; - - private SysLog sysLog; - - private String username; - -} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java index 23ce1dbb..83998a42 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java @@ -4,10 +4,10 @@ import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.pig4cloud.plugin.excel.annotation.ExcelLine; -import lombok.Data; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Data; + import java.io.Serializable; import java.time.LocalDateTime; @@ -24,7 +24,7 @@ public class PostExcelVO implements Serializable { private static final long serialVersionUID = 1L; /** - * excel 行号 + * 导入时候回显行号 */ @ExcelLine @ExcelIgnore diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PreLogVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PreLogVO.java new file mode 100644 index 00000000..de46b1a4 --- /dev/null +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PreLogVO.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.admin.api.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * @author lengleng + * @date 2018/8/27 前端日志vo + */ +@Data +@Schema(description = "前端日志展示对象") +public class PreLogVO { + + /** + * 请求url + */ + @Schema(description = "请求url") + private String url; + + /** + * 请求耗时 + */ + @Schema(description = "请求耗时") + private String time; + + /** + * 请求用户 + */ + @Schema(description = "请求用户") + private String user; + + /** + * 请求结果 + */ + @Schema(description = "请求结果0:成功9:失败") + private String type; + + /** + * 请求传递参数 + */ + @Schema(description = "请求传递参数") + private String message; + + /** + * 异常信息 + */ + @Schema(description = "异常信息") + private String stack; + + /** + * 日志标题 + */ + @Schema(description = "日志标题") + private String info; + +} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java index 7ff36849..c06cd6f8 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java @@ -4,9 +4,9 @@ import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.pig4cloud.plugin.excel.annotation.ExcelLine; +import jakarta.validation.constraints.NotBlank; import lombok.Data; -import jakarta.validation.constraints.NotBlank; import java.io.Serializable; import java.time.LocalDateTime; @@ -23,7 +23,7 @@ public class RoleExcelVO implements Serializable { private static final long serialVersionUID = 1L; /** - * excel 行号 + * 导入时候回显行号 */ @ExcelLine @ExcelIgnore diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java index 89691d54..fde0bbec 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.api.vo; @@ -25,7 +26,7 @@ import lombok.Data; */ @Data @Schema(description = "前端角色展示对象") -public class RoleVo { +public class RoleVO { /** * 角色id diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java index e8a86488..eac64877 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java @@ -4,9 +4,9 @@ import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.pig4cloud.plugin.excel.annotation.ExcelLine; +import jakarta.validation.constraints.NotBlank; import lombok.Data; -import jakarta.validation.constraints.NotBlank; import java.io.Serializable; import java.time.LocalDateTime; @@ -23,7 +23,7 @@ public class UserExcelVO implements Serializable { private static final long serialVersionUID = 1L; /** - * excel 行号 + * 导入时候回显行号 */ @ExcelLine @ExcelIgnore @@ -49,6 +49,27 @@ public class UserExcelVO implements Serializable { @ExcelProperty("手机号") private String phone; + /** + * 手机号 + */ + @NotBlank(message = "昵称不能为空") + @ExcelProperty("昵称") + private String nickname; + + /** + * 手机号 + */ + @NotBlank(message = "姓名不能为空") + @ExcelProperty("姓名") + private String name; + + /** + * 手机号 + */ + @NotBlank(message = "邮箱不能为空") + @ExcelProperty("邮箱") + private String email; + /** * 部门名称 */ @@ -64,10 +85,10 @@ public class UserExcelVO implements Serializable { private String roleNameList; /** - * 岗位列表 + * 角色列表 */ @NotBlank(message = "岗位不能为空") - @ExcelProperty("岗位") + @ExcelProperty("岗位名称") private String postNameList; /** diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserInfoVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserInfoVO.java deleted file mode 100644 index 32195cc4..00000000 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserInfoVO.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.api.vo; - -import com.pig4cloud.pig.admin.api.entity.SysUser; -import lombok.Data; - -import java.io.Serializable; - -/** - * @author lengleng - * @date 2019/2/1 - *

- * commit('SET_ROLES', data) commit('SET_NAME', data) commit('SET_AVATAR', data) - * commit('SET_INTRODUCTION', data) commit('SET_PERMISSIONS', data) - */ -@Data -public class UserInfoVO implements Serializable { - - /** - * 用户基本信息 - */ - private SysUser sysUser; - - /** - * 权限标识集合 - */ - private String[] permissions; - - /** - * 角色集合 - */ - private Long[] roles; - -} diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserVO.java index 4692eda5..a42f357a 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserVO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserVO.java @@ -1,23 +1,27 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.api.vo; import com.pig4cloud.pig.admin.api.entity.SysPost; import com.pig4cloud.pig.admin.api.entity.SysRole; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.io.Serializable; @@ -26,9 +30,10 @@ import java.util.List; /** * @author lengleng - * @date 2019/2/1 + * @date 2017/10/29 */ @Data +@Schema(description = "前端用户展示对象") public class UserVO implements Serializable { private static final long serialVersionUID = 1L; @@ -36,66 +41,103 @@ public class UserVO implements Serializable { /** * 主键ID */ + @Schema(description = "主键") private Long userId; /** * 用户名 */ + @Schema(description = "用户名") private String username; /** * 密码 */ + @Schema(description = "密码") private String password; /** * 随机盐 */ + @Schema(description = "随机盐") private String salt; + /** + * 微信openid + */ + @Schema(description = "微信open id") + private String wxOpenid; + + /** + * QQ openid + */ + @Schema(description = "qq open id") + private String qqOpenid; + + /** + * gitee openid + */ + @Schema(description = "gitee open id") + private String giteeOpenId; + + /** + * 开源中国 openid + */ + @Schema(description = "开源中国 open id") + private String oscOpenId; + /** * 创建时间 */ + @Schema(description = "创建时间") private LocalDateTime createTime; /** * 修改时间 */ + @Schema(description = "修改时间") private LocalDateTime updateTime; /** * 0-正常,1-删除 */ + @Schema(description = "删除标记,1:已删除,0:正常") private String delFlag; /** * 锁定标记 */ + @Schema(description = "锁定标记,0:正常,9:已锁定") private String lockFlag; /** - * 简介 + * 手机号 */ + @Schema(description = "手机号") private String phone; /** * 头像 */ + @Schema(description = "头像") private String avatar; /** * 部门ID */ + @Schema(description = "所属部门") private Long deptId; /** * 部门名称 */ + @Schema(description = "所属部门名称") private String deptName; /** * 角色列表 */ + @Schema(description = "拥有的角色列表") private List roleList; /** @@ -103,4 +145,22 @@ public class UserVO implements Serializable { */ private List postList; + /** + * 昵称 + */ + @Schema(description = "昵称") + private String nickname; + + /** + * 姓名 + */ + @Schema(description = "姓名") + private String name; + + /** + * 邮箱 + */ + @Schema(description = "邮箱") + private String email; + } diff --git a/pig-upms/pig-upms-api/src/main/resources/META-INF/spring.factories b/pig-upms/pig-upms-api/src/main/resources/META-INF/spring.factories new file mode 100755 index 00000000..381af7d2 --- /dev/null +++ b/pig-upms/pig-upms-api/src/main/resources/META-INF/spring.factories @@ -0,0 +1,7 @@ +com.pig4cloud.pig.common.feign.PigxFeignAutoConfiguration=\ + com.pig4cloud.pig.admin.api.feign.RemoteClientDetailsService,\ + com.pig4cloud.pig.admin.api.feign.RemoteLogService,\ + com.pig4cloud.pig.admin.api.feign.RemoteParamService,\ + com.pig4cloud.pig.admin.api.feign.RemoteTokenService,\ + com.pig4cloud.pig.admin.api.feign.RemoteUserService,\ + com.pig4cloud.pig.admin.api.feign.RemoteDictService diff --git a/pig-upms/pig-upms-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports b/pig-upms/pig-upms-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports deleted file mode 100644 index 9eca72e4..00000000 --- a/pig-upms/pig-upms-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports +++ /dev/null @@ -1,7 +0,0 @@ -com.pig4cloud.pig.admin.api.feign.RemoteClientDetailsService -com.pig4cloud.pig.admin.api.feign.RemoteDictService -com.pig4cloud.pig.admin.api.feign.RemoteDeptService -com.pig4cloud.pig.admin.api.feign.RemoteLogService -com.pig4cloud.pig.admin.api.feign.RemoteTokenService -com.pig4cloud.pig.admin.api.feign.RemoteUserService -com.pig4cloud.pig.admin.api.feign.RemoteParamService diff --git a/pig-upms/pig-upms-biz/pom.xml b/pig-upms/pig-upms-biz/pom.xml index a3652ff2..4aa61289 100644 --- a/pig-upms/pig-upms-biz/pom.xml +++ b/pig-upms/pig-upms-biz/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-upms - 3.6.4 + 3.7.0-SNAPSHOT pig-upms-biz @@ -37,8 +37,8 @@ - com.pig4cloud.plugin - oss-spring-boot-starter + com.pig4cloud + pig-common-oss diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java index 0706cc15..c17ec051 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin; @@ -25,11 +28,13 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; /** * @author lengleng - * @date 2018年06月21日 用户统一管理系统 + * @date 2018年06月21日 + *

+ * 用户统一管理系统 */ @EnablePigDoc("admin") -@EnablePigResourceServer @EnablePigFeignClients +@EnablePigResourceServer @EnableDiscoveryClient @SpringBootApplication public class PigAdminApplication { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/AppController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/AppController.java deleted file mode 100644 index c540936d..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/AppController.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.pig4cloud.pig.admin.controller; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.pig4cloud.pig.admin.api.dto.AppSmsDTO; -import com.pig4cloud.pig.admin.api.dto.UserInfo; -import com.pig4cloud.pig.admin.api.entity.SysUser; -import com.pig4cloud.pig.admin.service.AppService; -import com.pig4cloud.pig.admin.service.SysUserService; -import com.pig4cloud.pig.common.core.exception.ErrorCodes; -import com.pig4cloud.pig.common.core.util.MsgUtils; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.security.annotation.Inner; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AllArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.*; - -import jakarta.validation.Valid; - -/** - * @author lengleng - * @date 2021/9/16 移动端登录 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/app") -@Tag(name = "移动端登录模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class AppController { - - private final AppService appService; - - private final SysUserService userService; - - /** - * 发送手机验证码 - * @param sms 请求手机对象 - * @return code - */ - @Inner(value = false) - @PostMapping("/sms") - public R sendSmsCode(@Valid @RequestBody AppSmsDTO sms) { - return appService.sendSmsCode(sms); - } - - /** - * 获取指定用户全部信息 - * @param phone 手机号 - * @return 用户信息 - */ - @Inner - @GetMapping("/info/{phone}") - public R infoByMobile(@PathVariable String phone) { - SysUser user = userService.getOne(Wrappers.query().lambda().eq(SysUser::getPhone, phone)); - if (user == null) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, phone)); - } - return R.ok(userService.getUserInfo(user)); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DeptController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DeptController.java deleted file mode 100644 index a028f8b7..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DeptController.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.pig4cloud.pig.admin.controller; - -import cn.hutool.core.lang.tree.Tree; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.pig4cloud.pig.admin.api.entity.SysDept; -import com.pig4cloud.pig.admin.service.SysDeptService; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import com.pig4cloud.pig.common.security.annotation.Inner; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import jakarta.validation.Valid; -import java.util.List; - -/** - *

- * 部门管理 前端控制器 - *

- * - * @author lengleng - * @since 2019/2/1 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/dept") -@Tag(name = "部门管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class DeptController { - - private final SysDeptService sysDeptService; - - /** - * 通过ID查询 - * @param id ID - * @return SysDept - */ - @GetMapping("/{id:\\d+}") - public R getById(@PathVariable Long id) { - return R.ok(sysDeptService.getById(id)); - } - - /** - * 返回树形菜单集合 - * @return 树形菜单 - */ - @GetMapping(value = "/tree") - public R>> listDeptTrees() { - return R.ok(sysDeptService.listDeptTrees()); - } - - /** - * 返回当前用户树形菜单集合 - * @return 树形菜单 - */ - @GetMapping(value = "/user-tree") - public R>> listCurrentUserDeptTrees() { - return R.ok(sysDeptService.listCurrentUserDeptTrees()); - } - - /** - * 添加 - * @param sysDept 实体 - * @return success/false - */ - @SysLog("添加部门") - @PostMapping - @PreAuthorize("@pms.hasPermission('sys_dept_add')") - public R save(@Valid @RequestBody SysDept sysDept) { - return R.ok(sysDeptService.saveDept(sysDept)); - } - - /** - * 删除 - * @param id ID - * @return success/false - */ - @SysLog("删除部门") - @DeleteMapping("/{id:\\d+}") - @PreAuthorize("@pms.hasPermission('sys_dept_del')") - public R removeById(@PathVariable Long id) { - return R.ok(sysDeptService.removeDeptById(id)); - } - - /** - * 编辑 - * @param sysDept 实体 - * @return success/false - */ - @SysLog("编辑部门") - @PutMapping - @PreAuthorize("@pms.hasPermission('sys_dept_edit')") - public R update(@Valid @RequestBody SysDept sysDept) { - return R.ok(sysDeptService.updateDeptById(sysDept)); - } - - /** - * 根据部门名查询部门信息 - * @param deptname 部门名 - * @return - */ - @GetMapping("/details/{deptname}") - public R user(@PathVariable String deptname) { - SysDept condition = new SysDept(); - condition.setName(deptname); - return R.ok(sysDeptService.getOne(new QueryWrapper<>(condition))); - } - - /** - * 查收子级id列表 - * @return 返回子级id列表 - */ - @Inner - @GetMapping(value = "/child-id/{deptId:\\d+}") - public R> listChildDeptId(@PathVariable Long deptId) { - return R.ok(sysDeptService.listChildDeptId(deptId)); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DictController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DictController.java deleted file mode 100644 index 5ba3b295..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DictController.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.controller; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.admin.api.entity.SysDict; -import com.pig4cloud.pig.admin.api.entity.SysDictItem; -import com.pig4cloud.pig.admin.service.SysDictItemService; -import com.pig4cloud.pig.admin.service.SysDictService; -import com.pig4cloud.pig.common.core.constant.CacheConstants; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import jakarta.validation.Valid; -import java.util.List; - -/** - *

- * 字典表 前端控制器 - *

- * - * @author lengleng - * @since 2019-03-19 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/dict") -@Tag(name = "字典管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class DictController { - - private final SysDictItemService sysDictItemService; - - private final SysDictService sysDictService; - - /** - * 通过ID查询字典信息 - * @param id ID - * @return 字典信息 - */ - @GetMapping("/{id:\\d+}") - public R getById(@PathVariable Long id) { - return R.ok(sysDictService.getById(id)); - } - - /** - * 分页查询字典信息 - * @param page 分页对象 - * @return 分页对象 - */ - @GetMapping("/page") - public R> getDictPage(Page page, SysDict sysDict) { - return R.ok(sysDictService.page(page, - Wrappers.lambdaQuery() - .like(StrUtil.isNotBlank(sysDict.getDictKey()), SysDict::getDictKey, sysDict.getDictKey()) - .eq(StrUtil.isNotBlank(sysDict.getSystemFlag()), SysDict::getSystemFlag, sysDict.getSystemFlag()))); - } - - /** - * 通过字典类型查找字典 - * @param type 类型 - * @return 同类型字典 - */ - @GetMapping("/key/{key}") - @Cacheable(value = CacheConstants.DICT_DETAILS, key = "#key") - public R> getDictByKey(@PathVariable String key) { - return R.ok(sysDictItemService.list(Wrappers.query().lambda().eq(SysDictItem::getDictKey, key))); - } - - /** - * 添加字典 - * @param sysDict 字典信息 - * @return success、false - */ - @SysLog("添加字典") - @PostMapping - @PreAuthorize("@pms.hasPermission('sys_dict_add')") - public R save(@Valid @RequestBody SysDict sysDict) { - return R.ok(sysDictService.save(sysDict)); - } - - /** - * 删除字典,并且清除字典缓存 - * @param id ID - * @return R - */ - @SysLog("删除字典") - @DeleteMapping("/{id:\\d+}") - @PreAuthorize("@pms.hasPermission('sys_dict_del')") - public R removeById(@PathVariable Long id) { - sysDictService.removeDict(id); - return R.ok(); - } - - /** - * 修改字典 - * @param sysDict 字典信息 - * @return success/false - */ - @PutMapping - @SysLog("修改字典") - @PreAuthorize("@pms.hasPermission('sys_dict_edit')") - public R updateById(@Valid @RequestBody SysDict sysDict) { - sysDictService.updateDict(sysDict); - return R.ok(); - } - - /** - * 分页查询 - * @param page 分页对象 - * @param sysDictItem 字典项 - * @return - */ - @GetMapping("/item/page") - public R> getSysDictItemPage(Page page, SysDictItem sysDictItem) { - return R.ok(sysDictItemService.page(page, Wrappers.query(sysDictItem))); - } - - /** - * 通过id查询字典项 - * @param id id - * @return R - */ - @GetMapping("/item/{id:\\d+}") - public R getDictItemById(@PathVariable("id") Long id) { - return R.ok(sysDictItemService.getById(id)); - } - - /** - * 新增字典项 - * @param sysDictItem 字典项 - * @return R - */ - @SysLog("新增字典项") - @PostMapping("/item") - @CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true) - public R save(@RequestBody SysDictItem sysDictItem) { - return R.ok(sysDictItemService.save(sysDictItem)); - } - - /** - * 修改字典项 - * @param sysDictItem 字典项 - * @return R - */ - @SysLog("修改字典项") - @PutMapping("/item") - public R updateById(@RequestBody SysDictItem sysDictItem) { - sysDictItemService.updateDictItem(sysDictItem); - return R.ok(); - } - - /** - * 通过id删除字典项 - * @param id id - * @return R - */ - @SysLog("删除字典项") - @DeleteMapping("/item/{id:\\d+}") - public R removeDictItemById(@PathVariable Long id) { - sysDictItemService.removeDictItem(id); - return R.ok(); - } - - @SysLog("清除字典缓存") - @DeleteMapping("/cache") - @PreAuthorize("@pms.hasPermission('sys_dict_del')") - public R clearDictCache() { - sysDictService.clearDictCache(); - return R.ok(); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/LogController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/LogController.java deleted file mode 100644 index 4aae2416..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/LogController.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.pig4cloud.pig.admin.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.admin.api.dto.SysLogDTO; -import com.pig4cloud.pig.admin.api.entity.SysLog; -import com.pig4cloud.pig.admin.service.SysLogService; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.security.annotation.Inner; -import com.pig4cloud.plugin.excel.annotation.ResponseExcel; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import jakarta.validation.Valid; -import java.util.List; - -/** - *

- * 日志表 前端控制器 - *

- * - * @author lengleng - * @since 2019/2/1 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/log") -@Tag(name = "日志管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class LogController { - - private final SysLogService sysLogService; - - /** - * 简单分页查询 - * @param page 分页对象 - * @param sysLog 系统日志 - * @return - */ - @GetMapping("/page") - public R> getLogPage(Page page, SysLogDTO sysLog) { - return R.ok(sysLogService.getLogByPage(page, sysLog)); - } - - /** - * 删除日志 - * @param id ID - * @return success/false - */ - @DeleteMapping("/{id:\\d+}") - @PreAuthorize("@pms.hasPermission('sys_log_del')") - public R removeById(@PathVariable Long id) { - return R.ok(sysLogService.removeById(id)); - } - - /** - * 插入日志 - * @param sysLog 日志实体 - * @return success/false - */ - @Inner - @PostMapping - public R save(@Valid @RequestBody SysLog sysLog) { - return R.ok(sysLogService.save(sysLog)); - } - - /** - * 导出excel 表格 - * @param sysLog 查询条件 - * @return EXCEL - */ - @ResponseExcel - @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('sys_log_import_export')") - public List export(SysLogDTO sysLog) { - return sysLogService.getLogList(sysLog); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/OauthClientDetailsController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/OauthClientDetailsController.java deleted file mode 100644 index ae45b757..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/OauthClientDetailsController.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails; -import com.pig4cloud.pig.admin.service.SysOauthClientDetailsService; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import com.pig4cloud.pig.common.security.annotation.Inner; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import jakarta.validation.Valid; -import java.util.List; - -/** - *

- * 前端控制器 - *

- * - * @author lengleng - * @since 2018-05-15 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/client") -@Tag(name = "客户端管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class OauthClientDetailsController { - - private final SysOauthClientDetailsService sysOauthClientDetailsService; - - /** - * 通过ID查询 - * @param clientId 客户端id - * @return SysOauthClientDetails - */ - @GetMapping("/{clientId}") - public R> getByClientId(@PathVariable String clientId) { - return R.ok(sysOauthClientDetailsService - .list(Wrappers.lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId))); - } - - /** - * 简单分页查询 - * @param page 分页对象 - * @param sysOauthClientDetails 系统终端 - * @return - */ - @GetMapping("/page") - public R> getOauthClientDetailsPage(Page page, - SysOauthClientDetails sysOauthClientDetails) { - return R.ok(sysOauthClientDetailsService.page(page, Wrappers.query(sysOauthClientDetails))); - } - - /** - * 添加 - * @param sysOauthClientDetails 实体 - * @return success/false - */ - @SysLog("添加终端") - @PostMapping - @PreAuthorize("@pms.hasPermission('sys_client_add')") - public R add(@Valid @RequestBody SysOauthClientDetails sysOauthClientDetails) { - return R.ok(sysOauthClientDetailsService.save(sysOauthClientDetails)); - } - - /** - * 删除 - * @param id ID - * @return success/false - */ - @SysLog("删除终端") - @DeleteMapping("/{id}") - @PreAuthorize("@pms.hasPermission('sys_client_del')") - public R removeById(@PathVariable String id) { - return R.ok(sysOauthClientDetailsService.removeClientDetailsById(id)); - } - - /** - * 编辑 - * @param sysOauthClientDetails 实体 - * @return success/false - */ - @SysLog("编辑终端") - @PutMapping - @PreAuthorize("@pms.hasPermission('sys_client_edit')") - public R update(@Valid @RequestBody SysOauthClientDetails sysOauthClientDetails) { - return R.ok(sysOauthClientDetailsService.updateClientDetailsById(sysOauthClientDetails)); - } - - @SysLog("清除终端缓存") - @DeleteMapping("/cache") - @PreAuthorize("@pms.hasPermission('sys_client_del')") - public R clearClientCache() { - sysOauthClientDetailsService.clearClientCache(); - return R.ok(); - } - - @Inner - @GetMapping("/getClientDetailsById/{clientId}") - public R getClientDetailsById(@PathVariable String clientId) { - return R.ok(sysOauthClientDetailsService.getOne( - Wrappers.lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId), false)); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RoleController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RoleController.java deleted file mode 100644 index 923b229e..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RoleController.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.admin.api.entity.SysRole; -import com.pig4cloud.pig.admin.api.vo.RoleExcelVO; -import com.pig4cloud.pig.admin.api.vo.RoleVo; -import com.pig4cloud.pig.admin.service.SysRoleMenuService; -import com.pig4cloud.pig.admin.service.SysRoleService; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import com.pig4cloud.plugin.excel.annotation.RequestExcel; -import com.pig4cloud.plugin.excel.annotation.ResponseExcel; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.*; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * @author lengleng - * @date 2019/2/1 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/role") -@Tag(name = "角色管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class RoleController { - - private final SysRoleService sysRoleService; - - private final SysRoleMenuService sysRoleMenuService; - - /** - * 通过ID查询角色信息 - * @param id ID - * @return 角色信息 - */ - @GetMapping("/{id:\\d+}") - public R getById(@PathVariable Long id) { - return R.ok(sysRoleService.getById(id)); - } - - /** - * 添加角色 - * @param sysRole 角色信息 - * @return success、false - */ - @SysLog("添加角色") - @PostMapping - @PreAuthorize("@pms.hasPermission('sys_role_add')") - public R save(@Valid @RequestBody SysRole sysRole) { - return R.ok(sysRoleService.save(sysRole)); - } - - /** - * 修改角色 - * @param sysRole 角色信息 - * @return success/false - */ - @SysLog("修改角色") - @PutMapping - @PreAuthorize("@pms.hasPermission('sys_role_edit')") - public R update(@Valid @RequestBody SysRole sysRole) { - return R.ok(sysRoleService.updateById(sysRole)); - } - - /** - * 删除角色 - * @param id - * @return - */ - @SysLog("删除角色") - @DeleteMapping("/{id:\\d+}") - @PreAuthorize("@pms.hasPermission('sys_role_del')") - public R removeById(@PathVariable Long id) { - return R.ok(sysRoleService.removeRoleById(id)); - } - - /** - * 获取角色列表 - * @return 角色列表 - */ - @GetMapping("/list") - public R> listRoles() { - return R.ok(sysRoleService.list(Wrappers.emptyWrapper())); - } - - /** - * 分页查询角色信息 - * @param page 分页对象 - * @return 分页对象 - */ - @GetMapping("/page") - public R> getRolePage(Page page) { - return R.ok(sysRoleService.page(page, Wrappers.emptyWrapper())); - } - - /** - * 更新角色菜单 - * @param roleVo 角色对象 - * @return success、false - */ - @SysLog("更新角色菜单") - @PutMapping("/menu") - @PreAuthorize("@pms.hasPermission('sys_role_perm')") - public R saveRoleMenus(@RequestBody RoleVo roleVo) { - return R.ok(sysRoleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds())); - } - - /** - * 导出excel 表格 - * @return - */ - @ResponseExcel - @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('sys_role_import_export')") - public List export() { - return sysRoleService.listRole(); - } - - /** - * 导入角色 - * @param excelVOList 角色列表 - * @param bindingResult 错误信息列表 - * @return ok fail - */ - @PostMapping("/import") - @PreAuthorize("@pms.hasPermission('sys_role_import_export')") - public R importRole(@RequestExcel List excelVOList, BindingResult bindingResult) { - return sysRoleService.importRole(excelVOList, bindingResult); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysClientController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysClientController.java new file mode 100644 index 00000000..7c2d874e --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysClientController.java @@ -0,0 +1,165 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pig.admin.controller; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails; +import com.pig4cloud.pig.admin.service.SysOauthClientDetailsService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.pig.common.security.annotation.Inner; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author lengleng + * @since 2018-05-15 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/client") +@Tag(description = "client", name = "客户端管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysClientController { + + private final SysOauthClientDetailsService clientDetailsService; + + /** + * 通过ID查询 + * @param clientId clientId + * @return SysOauthClientDetails + */ + @GetMapping("/{clientId}") + public R getByClientId(@PathVariable String clientId) { + SysOauthClientDetails details = clientDetailsService + .getOne(Wrappers.lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId)); + return R.ok(details); + } + + /** + * 简单分页查询 + * @param page 分页对象 + * @param sysOauthClientDetails 系统终端 + * @return + */ + @GetMapping("/page") + public R getOauthClientDetailsPage(@ParameterObject Page page, + @ParameterObject SysOauthClientDetails sysOauthClientDetails) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(sysOauthClientDetails.getClientId()), SysOauthClientDetails::getClientId, + sysOauthClientDetails.getClientId()) + .like(StrUtil.isNotBlank(sysOauthClientDetails.getClientSecret()), SysOauthClientDetails::getClientSecret, + sysOauthClientDetails.getClientSecret()); + return R.ok(clientDetailsService.page(page, wrapper)); + } + + /** + * 添加 + * @param clientDetails 实体 + * @return success/false + */ + @SysLog("添加终端") + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_client_add')") + public R add(@Valid @RequestBody SysOauthClientDetails clientDetails) { + return R.ok(clientDetailsService.saveClient(clientDetails)); + } + + /** + * 删除 + * @param ids ID 列表 + * @return success/false + */ + @SysLog("删除终端") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('sys_client_del')") + public R removeById(@RequestBody Long[] ids) { + clientDetailsService.removeBatchByIds(CollUtil.toList(ids)); + return R.ok(); + } + + /** + * 编辑 + * @param clientDetails 实体 + * @return success/false + */ + @SysLog("编辑终端") + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_client_edit')") + public R update(@Valid @RequestBody SysOauthClientDetails clientDetails) { + return R.ok(clientDetailsService.updateClientById(clientDetails)); + } + + @Inner(false) + @GetMapping("/getClientDetailsById/{clientId}") + public R getClientDetailsById(@PathVariable String clientId) { + return R.ok(clientDetailsService.getOne( + Wrappers.lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId), false)); + } + + /** + * 查询全部客户端 + * @return + */ + @Inner(false) + @GetMapping("/list") + public R listClients() { + return R.ok(clientDetailsService.list()); + } + + /** + * 同步缓存字典 + * @return R + */ + @SysLog("同步终端") + @PutMapping("/sync") + public R sync() { + return clientDetailsService.syncClientCache(); + } + + /** + * 导出所有客户端 + * @return excel + */ + @ResponseExcel + @SysLog("导出excel") + @GetMapping("/export") + public List export(SysOauthClientDetails sysOauthClientDetails) { + return clientDetailsService.list(Wrappers.query(sysOauthClientDetails)); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysDeptController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysDeptController.java new file mode 100644 index 00000000..65e94b40 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysDeptController.java @@ -0,0 +1,154 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pig.admin.controller; + +import com.pig4cloud.pig.admin.api.entity.SysDept; +import com.pig4cloud.pig.admin.api.vo.DeptExcelVo; +import com.pig4cloud.pig.admin.service.SysDeptService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.RequestExcel; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.util.List; + +/** + *

+ * 部门管理 前端控制器 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/dept") +@Tag(description = "dept", name = "部门管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysDeptController { + + private final SysDeptService sysDeptService; + + /** + * 通过ID查询 + * @param id ID + * @return SysDept + */ + @GetMapping("/{id}") + public R getById(@PathVariable Long id) { + return R.ok(sysDeptService.getById(id)); + } + + /** + * 查询全部部门 + */ + @GetMapping("/list") + public R list() { + return R.ok(sysDeptService.list()); + } + + /** + * 返回树形菜单集合 + * @param deptName 部门名称 + * @return 树形菜单 + */ + @GetMapping(value = "/tree") + public R getTree(String deptName) { + return R.ok(sysDeptService.selectTree(deptName)); + } + + /** + * 添加 + * @param sysDept 实体 + * @return success/false + */ + @SysLog("添加部门") + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_dept_add')") + public R save(@Valid @RequestBody SysDept sysDept) { + return R.ok(sysDeptService.save(sysDept)); + } + + /** + * 删除 + * @param id ID + * @return success/false + */ + @SysLog("删除部门") + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_dept_del')") + public R removeById(@PathVariable Long id) { + return R.ok(sysDeptService.removeDeptById(id)); + } + + /** + * 编辑 + * @param sysDept 实体 + * @return success/false + */ + @SysLog("编辑部门") + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_dept_edit')") + public R update(@Valid @RequestBody SysDept sysDept) { + sysDept.setUpdateTime(LocalDateTime.now()); + return R.ok(sysDeptService.updateById(sysDept)); + } + + /** + * 查收子级列表 + * @return 返回子级 + */ + @GetMapping(value = "/getDescendantList/{deptId}") + public R getDescendantList(@PathVariable Long deptId) { + return R.ok(sysDeptService.listDescendant(deptId)); + } + + /** + * 导出部门 + * @return + */ + @ResponseExcel + @GetMapping("/export") + public List export() { + return sysDeptService.listExcelVo(); + } + + /** + * 导入部门 + * @param excelVOList + * @param bindingResult + * @return + */ + @PostMapping("import") + public R importDept(@RequestExcel List excelVOList, BindingResult bindingResult) { + + return sysDeptService.importDept(excelVOList, bindingResult); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysDictController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysDictController.java new file mode 100644 index 00000000..ecfafb01 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysDictController.java @@ -0,0 +1,242 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pig.admin.controller; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.admin.api.entity.SysDict; +import com.pig4cloud.pig.admin.api.entity.SysDictItem; +import com.pig4cloud.pig.admin.service.SysDictItemService; +import com.pig4cloud.pig.admin.service.SysDictService; +import com.pig4cloud.pig.common.core.constant.CacheConstants; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + *

+ * 字典表 前端控制器 + *

+ * + * @author lengleng + * @since 2019-03-19 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/dict") +@Tag(description = "dict", name = "字典管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysDictController { + + private final SysDictService sysDictService; + + private final SysDictItemService sysDictItemService; + + /** + * 通过ID查询字典信息 + * @param id ID + * @return 字典信息 + */ + @GetMapping("/details/{id}") + public R getById(@PathVariable Long id) { + return R.ok(sysDictService.getById(id)); + } + + /** + * 查询字典信息 + * @param query 查询信息 + * @return 字典信息 + */ + @GetMapping("/details") + public R getDetails(@ParameterObject SysDict query) { + return R.ok(sysDictService.getOne(Wrappers.query(query), false)); + } + + /** + * 分页查询字典信息 + * @param page 分页对象 + * @return 分页对象 + */ + @GetMapping("/page") + public R getDictPage(@ParameterObject Page page, @ParameterObject SysDict sysDict) { + return R.ok(sysDictService.page(page, + Wrappers.lambdaQuery() + .eq(StrUtil.isNotBlank(sysDict.getSystemFlag()), SysDict::getSystemFlag, sysDict.getSystemFlag()) + .like(StrUtil.isNotBlank(sysDict.getDictType()), SysDict::getDictType, sysDict.getDictType()))); + } + + /** + * 通过字典类型查找字典 + * @param type 类型 + * @return 同类型字典 + */ + @GetMapping("/type/{type}") + @Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result.data.isEmpty()") + public R> getDictByType(@PathVariable String type) { + return R.ok(sysDictItemService.list(Wrappers.query().lambda().eq(SysDictItem::getDictType, type))); + } + + /** + * 添加字典 + * @param sysDict 字典信息 + * @return success、false + */ + @SysLog("添加字典") + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_dict_add')") + public R save(@Valid @RequestBody SysDict sysDict) { + sysDictService.save(sysDict); + return R.ok(sysDict); + } + + /** + * 删除字典,并且清除字典缓存 + * @param ids ID + * @return R + */ + @SysLog("删除字典") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('sys_dict_del')") + @CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true) + public R removeById(@RequestBody Long[] ids) { + return R.ok(sysDictService.removeDictByIds(ids)); + } + + /** + * 修改字典 + * @param sysDict 字典信息 + * @return success/false + */ + @PutMapping + @SysLog("修改字典") + @PreAuthorize("@pms.hasPermission('sys_dict_edit')") + public R updateById(@Valid @RequestBody SysDict sysDict) { + return sysDictService.updateDict(sysDict); + } + + /** + * 分页查询 + * @param name 名称或者字典项 + * @return + */ + @GetMapping("/list") + public R getDictList(String name) { + return R.ok(sysDictService.list(Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(name), SysDict::getDictType, name) + .or() + .like(StrUtil.isNotBlank(name), SysDict::getDescription, name))); + } + + /** + * 分页查询 + * @param page 分页对象 + * @param sysDictItem 字典项 + * @return + */ + @GetMapping("/item/page") + public R getSysDictItemPage(Page page, SysDictItem sysDictItem) { + return R.ok(sysDictItemService.page(page, Wrappers.query(sysDictItem))); + } + + /** + * 通过id查询字典项 + * @param id id + * @return R + */ + @GetMapping("/item/details/{id}") + public R getDictItemById(@PathVariable("id") Long id) { + return R.ok(sysDictItemService.getById(id)); + } + + /** + * 查询字典项详情 + * @param query 查询条件 + * @return R + */ + @GetMapping("/item/details") + public R getDictItemDetails(SysDictItem query) { + return R.ok(sysDictItemService.getOne(Wrappers.query(query), false)); + } + + /** + * 新增字典项 + * @param sysDictItem 字典项 + * @return R + */ + @SysLog("新增字典项") + @PostMapping("/item") + @CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true) + public R save(@RequestBody SysDictItem sysDictItem) { + return R.ok(sysDictItemService.save(sysDictItem)); + } + + /** + * 修改字典项 + * @param sysDictItem 字典项 + * @return R + */ + @SysLog("修改字典项") + @PutMapping("/item") + public R updateById(@RequestBody SysDictItem sysDictItem) { + return sysDictItemService.updateDictItem(sysDictItem); + } + + /** + * 通过id删除字典项 + * @param id id + * @return R + */ + @SysLog("删除字典项") + @DeleteMapping("/item/{id}") + public R removeDictItemById(@PathVariable Long id) { + return sysDictItemService.removeDictItem(id); + } + + /** + * 同步缓存字典 + * @return R + */ + @SysLog("同步字典") + @PutMapping("/sync") + public R sync() { + return sysDictService.syncDictCache(); + } + + @ResponseExcel + @GetMapping("/export") + public List export(SysDictItem sysDictItem) { + return sysDictItemService.list(Wrappers.query(sysDictItem)); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysFileController.java similarity index 79% rename from pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java rename to pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysFileController.java index fa5b90f8..8f139ace 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysFileController.java @@ -19,7 +19,7 @@ package com.pig4cloud.pig.admin.controller; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pig.admin.api.entity.SysFile; @@ -30,28 +30,28 @@ import com.pig4cloud.pig.common.security.annotation.Inner; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; +import jakarta.servlet.http.HttpServletResponse; +import lombok.AllArgsConstructor; import lombok.SneakyThrows; +import org.springdoc.core.annotations.ParameterObject; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import jakarta.servlet.http.HttpServletResponse; - /** * 文件管理 * * @author Luckly - * @date 2021-09-11 + * @date 2019-06-18 17:18:42 */ @RestController -@RequiredArgsConstructor +@AllArgsConstructor @RequestMapping("/sys-file") -@Tag(name = "文件管理模块") +@Tag(description = "sys-file", name = "文件管理") @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class FileController { +public class SysFileController { private final SysFileService sysFileService; @@ -63,22 +63,26 @@ public class FileController { */ @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page") - public R> getSysFilePage(Page page, SysFile sysFile) { - return R.ok(sysFileService.page(page, Wrappers.lambdaQuery() - .like(StrUtil.isNotBlank(sysFile.getFileName()), SysFile::getFileName, sysFile.getFileName()))); + public R getSysFilePage(@ParameterObject Page page, @ParameterObject SysFile sysFile) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(sysFile.getOriginal()), SysFile::getOriginal, sysFile.getOriginal()); + return R.ok(sysFileService.page(page, wrapper)); } /** * 通过id删除文件管理 - * @param id id + * @param ids id 列表 * @return R */ @Operation(summary = "通过id删除文件管理", description = "通过id删除文件管理") @SysLog("删除文件管理") - @DeleteMapping("/{id:\\d+}") + @DeleteMapping @PreAuthorize("@pms.hasPermission('sys_file_del')") - public R removeById(@PathVariable Long id) { - return R.ok(sysFileService.deleteFile(id)); + public R removeById(@RequestBody Long[] ids) { + for (Long id : ids) { + sysFileService.deleteFile(id); + } + return R.ok(); } /** @@ -110,23 +114,11 @@ public class FileController { * @param response 本地文件 */ @SneakyThrows - @GetMapping("/local/{fileName}") + @GetMapping("/local/file/{fileName}") public void localFile(@PathVariable String fileName, HttpServletResponse response) { ClassPathResource resource = new ClassPathResource("file/" + fileName); response.setContentType("application/octet-stream; charset=UTF-8"); IoUtil.copy(resource.getInputStream(), response.getOutputStream()); } - /** - * 获取文件外网的访问地址 - * @param bucket - * @param fileName - * @return - */ - @Inner(false) - @GetMapping("/online/{bucket}/{fileName}") - public R onlineFile(@PathVariable String bucket, @PathVariable String fileName) { - return R.ok(sysFileService.onlineFile(bucket, fileName)); - } - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysLogController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysLogController.java new file mode 100644 index 00000000..49946feb --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysLogController.java @@ -0,0 +1,105 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pig.admin.controller; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.admin.api.dto.SysLogDTO; +import com.pig4cloud.pig.admin.api.entity.SysLog; +import com.pig4cloud.pig.admin.api.vo.PreLogVO; +import com.pig4cloud.pig.admin.service.SysLogService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.security.annotation.Inner; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + *

+ * 日志表 前端控制器 + *

+ * + * @author lengleng + * @since 2017-11-20 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/log") +@Tag(description = "log", name = "日志管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysLogController { + + private final SysLogService sysLogService; + + /** + * 简单分页查询 + * @param page 分页对象 + * @param sysLog 系统日志 + * @return + */ + @GetMapping("/page") + public R getLogPage(@ParameterObject Page page, @ParameterObject SysLogDTO sysLog) { + return R.ok(sysLogService.getLogByPage(page, sysLog)); + } + + /** + * 批量删除日志 + * @param ids ID + * @return success/false + */ + @DeleteMapping + @PreAuthorize("@pms.hasPermission('sys_log_del')") + public R removeByIds(@RequestBody Long[] ids) { + return R.ok(sysLogService.removeBatchByIds(CollUtil.toList(ids))); + } + + /** + * 插入日志 + * @param sysLog 日志实体 + * @return success/false + */ + @Inner + @PostMapping("/save") + public R save(@Valid @RequestBody SysLog sysLog) { + return R.ok(sysLogService.saveLog(sysLog)); + } + + /** + * 导出excel 表格 + * @param sysLog 查询条件 + * @return + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('sys_log_export')") + public List export(SysLog sysLog) { + return sysLogService.list(Wrappers.query(sysLog)); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/MenuController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysMenuController.java similarity index 52% rename from pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/MenuController.java rename to pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysMenuController.java index e6fdd2b5..78aa094b 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/MenuController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysMenuController.java @@ -1,22 +1,24 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.controller; -import cn.hutool.core.lang.tree.Tree; import com.pig4cloud.pig.admin.api.entity.SysMenu; import com.pig4cloud.pig.admin.service.SysMenuService; import com.pig4cloud.pig.common.core.util.R; @@ -24,14 +26,13 @@ import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.pig.common.security.util.SecurityUtils; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; +import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; @@ -40,39 +41,37 @@ import java.util.stream.Collectors; * @date 2017/10/31 */ @RestController -@RequiredArgsConstructor +@AllArgsConstructor @RequestMapping("/menu") -@Tag(name = "菜单管理模块") +@Tag(description = "menu", name = "菜单管理模块") @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class MenuController { +public class SysMenuController { private final SysMenuService sysMenuService; /** * 返回当前用户的树形菜单集合 + * @param type 类型 * @param parentId 父节点ID * @return 当前用户的树形菜单 */ @GetMapping - public R>> getUserMenu(Long parentId) { + public R getUserMenu(String type, Long parentId) { // 获取符合条件的菜单 - Set menuSet = SecurityUtils.getRoles() - .stream() - .map(sysMenuService::findMenuByRoleId) - .flatMap(Collection::stream) - .collect(Collectors.toSet()); - return R.ok(sysMenuService.filterMenu(menuSet, parentId)); + Set all = new HashSet<>(); + SecurityUtils.getRoles().forEach(roleId -> all.addAll(sysMenuService.findMenuByRoleId(roleId))); + return R.ok(sysMenuService.filterMenu(all, type, parentId)); } /** * 返回树形菜单集合 - * @param lazy 是否是懒加载 * @param parentId 父节点ID + * @param menuName 菜单名称 * @return 树形菜单 */ @GetMapping(value = "/tree") - public R>> getTree(boolean lazy, Long parentId) { - return R.ok(sysMenuService.treeMenu(lazy, parentId)); + public R getTree(Long parentId, String menuName, String type) { + return R.ok(sysMenuService.treeMenu(parentId, menuName, type)); } /** @@ -81,7 +80,7 @@ public class MenuController { * @return 属性集合 */ @GetMapping("/tree/{roleId}") - public R> getRoleTree(@PathVariable Long roleId) { + public R getRoleTree(@PathVariable Long roleId) { return R .ok(sysMenuService.findMenuByRoleId(roleId).stream().map(SysMenu::getMenuId).collect(Collectors.toList())); } @@ -91,20 +90,20 @@ public class MenuController { * @param id 菜单ID * @return 菜单详细信息 */ - @GetMapping("/{id:\\d+}") - public R getById(@PathVariable Long id) { + @GetMapping("/{id}") + public R getById(@PathVariable Long id) { return R.ok(sysMenuService.getById(id)); } /** * 新增菜单 * @param sysMenu 菜单信息 - * @return 含ID 菜单信息 + * @return success/false */ @SysLog("新增菜单") @PostMapping @PreAuthorize("@pms.hasPermission('sys_menu_add')") - public R save(@Valid @RequestBody SysMenu sysMenu) { + public R save(@Valid @RequestBody SysMenu sysMenu) { sysMenuService.save(sysMenu); return R.ok(sysMenu); } @@ -115,10 +114,10 @@ public class MenuController { * @return success/false */ @SysLog("删除菜单") - @DeleteMapping("/{id:\\d+}") + @DeleteMapping("/{id}") @PreAuthorize("@pms.hasPermission('sys_menu_del')") - public R removeById(@PathVariable Long id) { - return R.ok(sysMenuService.removeMenuById(id)); + public R removeById(@PathVariable Long id) { + return sysMenuService.removeMenuById(id); } /** @@ -129,19 +128,8 @@ public class MenuController { @SysLog("更新菜单") @PutMapping @PreAuthorize("@pms.hasPermission('sys_menu_edit')") - public R update(@Valid @RequestBody SysMenu sysMenu) { + public R update(@Valid @RequestBody SysMenu sysMenu) { return R.ok(sysMenuService.updateMenuById(sysMenu)); } - /** - * 清除菜单缓存 - */ - @SysLog("清除菜单缓存") - @DeleteMapping("/cache") - @PreAuthorize("@pms.hasPermission('sys_menu_del')") - public R clearMenuCache() { - sysMenuService.clearMenuCache(); - return R.ok(); - } - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysMobileController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysMobileController.java new file mode 100644 index 00000000..31f5d084 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysMobileController.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.admin.controller; + +import com.pig4cloud.pig.admin.service.SysMobileService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.security.annotation.Inner; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author lengleng + * @date 2018/11/14 + *

+ * 手机验证码 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/mobile") +@Tag(description = "mobile", name = "手机管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysMobileController { + + private final SysMobileService mobileService; + + @Inner(value = false) + @GetMapping("/{mobile}") + public R sendSmsCode(@PathVariable String mobile) { + return mobileService.sendSmsCode(mobile); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PostController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysPostController.java similarity index 69% rename from pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PostController.java rename to pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysPostController.java index e2ed6c0e..7ec119ba 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PostController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysPostController.java @@ -17,6 +17,8 @@ package com.pig4cloud.pig.admin.controller; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pig.admin.api.entity.SysPost; @@ -30,6 +32,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springdoc.core.annotations.ParameterObject; import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; @@ -38,15 +41,17 @@ import org.springframework.web.bind.annotation.*; import java.util.List; /** + * 岗位信息表 + * * @author fxz - * @date 2022-03-15 17:18:40 + * @date 2022-03-26 12:50:43 */ @RestController @RequiredArgsConstructor @RequestMapping("/post") -@Tag(name = "岗位管理模块") +@Tag(description = "post", name = "岗位信息表管理") @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class PostController { +public class SysPostController { private final SysPostService sysPostService; @@ -62,13 +67,15 @@ public class PostController { /** * 分页查询 * @param page 分页对象 + * @param sysPost 岗位信息表 * @return */ - @Operation(summary = "分页查询", description = "分页查询") + @Operation(description = "分页查询", summary = "分页查询") @GetMapping("/page") - @PreAuthorize("@pms.hasPermission('sys_post_get')") - public R getSysPostPage(Page page) { - return R.ok(sysPostService.page(page, Wrappers.lambdaQuery().orderByAsc(SysPost::getPostSort))); + @PreAuthorize("@pms.hasPermission('sys_post_view')") + public R getSysPostPage(@ParameterObject Page page, @ParameterObject SysPost sysPost) { + return R.ok(sysPostService.page(page, Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(sysPost.getPostName()), SysPost::getPostName, sysPost.getPostName()))); } /** @@ -76,19 +83,31 @@ public class PostController { * @param postId id * @return R */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/{postId}") - @PreAuthorize("@pms.hasPermission('sys_post_get')") + @Operation(description = "通过id查询", summary = "通过id查询") + @GetMapping("/details/{postId}") + @PreAuthorize("@pms.hasPermission('sys_post_view')") public R getById(@PathVariable("postId") Long postId) { return R.ok(sysPostService.getById(postId)); } + /** + * 查询岗位信息信息 + * @param query 查询条件 + * @return R + */ + @Operation(description = "查询角色信息", summary = "查询角色信息") + @GetMapping("/details") + @PreAuthorize("@pms.hasPermission('sys_post_view')") + public R getDetails(SysPost query) { + return R.ok(sysPostService.getOne(Wrappers.query(query), false)); + } + /** * 新增岗位信息表 * @param sysPost 岗位信息表 * @return R */ - @Operation(summary = "新增岗位信息表", description = "新增岗位信息表") + @Operation(description = "新增岗位信息表", summary = "新增岗位信息表") @SysLog("新增岗位信息表") @PostMapping @PreAuthorize("@pms.hasPermission('sys_post_add')") @@ -101,7 +120,7 @@ public class PostController { * @param sysPost 岗位信息表 * @return R */ - @Operation(summary = "修改岗位信息表", description = "修改岗位信息表") + @Operation(description = "修改岗位信息表", summary = "修改岗位信息表") @SysLog("修改岗位信息表") @PutMapping @PreAuthorize("@pms.hasPermission('sys_post_edit')") @@ -111,24 +130,24 @@ public class PostController { /** * 通过id删除岗位信息表 - * @param postId id + * @param ids id 列表 * @return R */ - @Operation(summary = "通过id删除岗位信息表", description = "通过id删除岗位信息表") + @Operation(description = "通过id删除岗位信息表", summary = "通过id删除岗位信息表") @SysLog("通过id删除岗位信息表") - @DeleteMapping("/{postId}") + @DeleteMapping @PreAuthorize("@pms.hasPermission('sys_post_del')") - public R removeById(@PathVariable Long postId) { - return R.ok(sysPostService.removeById(postId)); + public R removeById(@RequestBody Long[] ids) { + return R.ok(sysPostService.removeBatchByIds(CollUtil.toList(ids))); } /** * 导出excel 表格 - * @return + * @return excel 文件流 */ @ResponseExcel @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('sys_post_import_export')") + @PreAuthorize("@pms.hasPermission('sys_post_export')") public List export() { return sysPostService.listPost(); } @@ -140,7 +159,7 @@ public class PostController { * @return ok fail */ @PostMapping("/import") - @PreAuthorize("@pms.hasPermission('sys_post_import_export')") + @PreAuthorize("@pms.hasPermission('sys_post_export')") public R importRole(@RequestExcel List excelVOList, BindingResult bindingResult) { return sysPostService.importPost(excelVOList, bindingResult); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PublicParamController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysPublicParamController.java similarity index 60% rename from pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PublicParamController.java rename to pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysPublicParamController.java index d6be5790..2712d336 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PublicParamController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysPublicParamController.java @@ -18,6 +18,7 @@ package com.pig4cloud.pig.admin.controller; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pig.admin.api.entity.SysPublicParam; @@ -25,14 +26,18 @@ import com.pig4cloud.pig.admin.service.SysPublicParamService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.pig.common.security.annotation.Inner; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; +import lombok.AllArgsConstructor; +import org.springdoc.core.annotations.ParameterObject; import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * 公共参数 * @@ -40,11 +45,11 @@ import org.springframework.web.bind.annotation.*; * @date 2019-04-29 */ @RestController -@RequiredArgsConstructor +@AllArgsConstructor @RequestMapping("/param") -@Tag(name = "公共参数配置") +@Tag(description = "param", name = "公共参数配置") @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class PublicParamController { +public class SysPublicParamController { private final SysPublicParamService sysPublicParamService; @@ -54,7 +59,7 @@ public class PublicParamController { * @return */ @Inner(value = false) - @Operation(summary = "查询公共参数值", description = "根据key查询公共参数值") + @Operation(description = "查询公共参数值", summary = "根据key查询公共参数值") @GetMapping("/publicValue/{publicKey}") public R publicKey(@PathVariable("publicKey") String publicKey) { return R.ok(sysPublicParamService.getSysPublicParamKeyToValue(publicKey)); @@ -66,15 +71,18 @@ public class PublicParamController { * @param sysPublicParam 公共参数 * @return */ - @Operation(summary = "分页查询", description = "分页查询") + @Operation(description = "分页查询", summary = "分页查询") @GetMapping("/page") - public R getSysPublicParamPage(Page page, SysPublicParam sysPublicParam) { - return R.ok(sysPublicParamService.page(page, - Wrappers.lambdaQuery() - .like(StrUtil.isNotBlank(sysPublicParam.getPublicName()), SysPublicParam::getPublicName, - sysPublicParam.getPublicName()) - .like(StrUtil.isNotBlank(sysPublicParam.getPublicKey()), SysPublicParam::getPublicKey, - sysPublicParam.getPublicKey()))); + public R getSysPublicParamPage(@ParameterObject Page page, @ParameterObject SysPublicParam sysPublicParam) { + LambdaUpdateWrapper wrapper = Wrappers.lambdaUpdate() + .like(StrUtil.isNotBlank(sysPublicParam.getPublicName()), SysPublicParam::getPublicName, + sysPublicParam.getPublicName()) + .like(StrUtil.isNotBlank(sysPublicParam.getPublicKey()), SysPublicParam::getPublicKey, + sysPublicParam.getPublicKey()) + .eq(StrUtil.isNotBlank(sysPublicParam.getSystemFlag()), SysPublicParam::getSystemFlag, + sysPublicParam.getSystemFlag()); + + return R.ok(sysPublicParamService.page(page, wrapper)); } /** @@ -82,21 +90,26 @@ public class PublicParamController { * @param publicId id * @return R */ - @Operation(summary = "通过id查询公共参数", description = "通过id查询公共参数") - @GetMapping("/{publicId}") + @Operation(description = "通过id查询公共参数", summary = "通过id查询公共参数") + @GetMapping("/details/{publicId}") public R getById(@PathVariable("publicId") Long publicId) { return R.ok(sysPublicParamService.getById(publicId)); } + @GetMapping("/details") + public R getDetail(@ParameterObject SysPublicParam param) { + return R.ok(sysPublicParamService.getOne(Wrappers.query(param), false)); + } + /** * 新增公共参数 * @param sysPublicParam 公共参数 * @return R */ - @Operation(summary = "新增公共参数", description = "新增公共参数") + @Operation(description = "新增公共参数", summary = "新增公共参数") @SysLog("新增公共参数") @PostMapping - @PreAuthorize("@pms.hasPermission('sys_publicparam_add')") + @PreAuthorize("@pms.hasPermission('sys_syspublicparam_add')") public R save(@RequestBody SysPublicParam sysPublicParam) { return R.ok(sysPublicParamService.save(sysPublicParam)); } @@ -106,25 +119,36 @@ public class PublicParamController { * @param sysPublicParam 公共参数 * @return R */ - @Operation(summary = "修改公共参数", description = "修改公共参数") + @Operation(description = "修改公共参数", summary = "修改公共参数") @SysLog("修改公共参数") @PutMapping - @PreAuthorize("@pms.hasPermission('sys_publicparam_edit')") + @PreAuthorize("@pms.hasPermission('sys_syspublicparam_edit')") public R updateById(@RequestBody SysPublicParam sysPublicParam) { return sysPublicParamService.updateParam(sysPublicParam); } /** * 通过id删除公共参数 - * @param publicId id + * @param ids ids * @return R */ - @Operation(summary = "删除公共参数", description = "删除公共参数") + @Operation(description = "删除公共参数", summary = "删除公共参数") @SysLog("删除公共参数") - @DeleteMapping("/{publicId}") - @PreAuthorize("@pms.hasPermission('sys_publicparam_del')") - public R removeById(@PathVariable Long publicId) { - return sysPublicParamService.removeParam(publicId); + @DeleteMapping + @PreAuthorize("@pms.hasPermission('sys_syspublicparam_del')") + public R removeById(@RequestBody Long[] ids) { + return R.ok(sysPublicParamService.removeParamByIds(ids)); + } + + /** + * 导出excel 表格 + * @return + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('sys_syspublicparam_edit')") + public List export() { + return sysPublicParamService.list(); } /** @@ -133,6 +157,7 @@ public class PublicParamController { */ @SysLog("同步参数") @PutMapping("/sync") + @PreAuthorize("@pms.hasPermission('sys_syspublicparam_edit')") public R sync() { return sysPublicParamService.syncParamCache(); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RegisterController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysRegisterController.java similarity index 96% rename from pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RegisterController.java rename to pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysRegisterController.java index a5a0ab49..a73d66be 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RegisterController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysRegisterController.java @@ -15,14 +15,14 @@ import org.springframework.web.bind.annotation.RestController; /** * @author lengleng * @date 2022/3/30 - * + *

* 客户端注册功能 register.user = false */ @RestController @RequestMapping("/register") @RequiredArgsConstructor @ConditionalOnProperty(name = "register.user", matchIfMissing = true) -public class RegisterController { +public class SysRegisterController { private final SysUserService userService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysRoleController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysRoleController.java new file mode 100644 index 00000000..3066d024 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysRoleController.java @@ -0,0 +1,186 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pig.admin.controller; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.admin.api.entity.SysRole; +import com.pig4cloud.pig.admin.api.vo.RoleExcelVO; +import com.pig4cloud.pig.admin.api.vo.RoleVO; +import com.pig4cloud.pig.admin.service.SysRoleService; +import com.pig4cloud.pig.common.core.constant.CacheConstants; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.RequestExcel; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author lengleng + * @date 2020-02-10 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/role") +@Tag(description = "role", name = "角色管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysRoleController { + + private final SysRoleService sysRoleService; + + /** + * 通过ID查询角色信息 + * @param id ID + * @return 角色信息 + */ + @GetMapping("/details/{id}") + public R getById(@PathVariable Long id) { + return R.ok(sysRoleService.getById(id)); + } + + /** + * 查询角色信息 + * @param query 查询条件 + * @return 角色信息 + */ + @GetMapping("/details") + public R getDetails(@ParameterObject SysRole query) { + return R.ok(sysRoleService.getOne(Wrappers.query(query), false)); + } + + /** + * 添加角色 + * @param sysRole 角色信息 + * @return success、false + */ + @SysLog("添加角色") + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_role_add')") + @CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true) + public R save(@Valid @RequestBody SysRole sysRole) { + return R.ok(sysRoleService.save(sysRole)); + } + + /** + * 修改角色 + * @param sysRole 角色信息 + * @return success/false + */ + @SysLog("修改角色") + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_role_edit')") + @CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true) + public R update(@Valid @RequestBody SysRole sysRole) { + return R.ok(sysRoleService.updateById(sysRole)); + } + + /** + * 删除角色 + * @param ids + * @return + */ + @SysLog("删除角色") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('sys_role_del')") + @CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true) + public R removeById(@RequestBody Long[] ids) { + return R.ok(sysRoleService.removeRoleByIds(ids)); + } + + /** + * 获取角色列表 + * @return 角色列表 + */ + @GetMapping("/list") + public R listRoles() { + return R.ok(sysRoleService.list(Wrappers.emptyWrapper())); + } + + /** + * 分页查询角色信息 + * @param page 分页对象 + * @param role 查询条件 + * @return 分页对象 + */ + @GetMapping("/page") + public R getRolePage(Page page, SysRole role) { + return R.ok(sysRoleService.page(page, Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName()))); + } + + /** + * 更新角色菜单 + * @param roleVo 角色对象 + * @return success、false + */ + @SysLog("更新角色菜单") + @PutMapping("/menu") + @PreAuthorize("@pms.hasPermission('sys_role_perm')") + public R saveRoleMenus(@RequestBody RoleVO roleVo) { + return R.ok(sysRoleService.updateRoleMenus(roleVo)); + } + + /** + * 通过角色ID 查询角色列表 + * @param roleIdList 角色ID + * @return + */ + @PostMapping("/getRoleList") + public R getRoleList(@RequestBody List roleIdList) { + return R.ok(sysRoleService.findRolesByRoleIds(roleIdList, CollUtil.join(roleIdList, StrUtil.UNDERLINE))); + } + + /** + * 导出excel 表格 + * @return + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('sys_role_export')") + public List export() { + return sysRoleService.listRole(); + } + + /** + * 导入角色 + * @param excelVOList 角色列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + @PostMapping("/import") + @PreAuthorize("@pms.hasPermission('sys_role_export')") + public R importRole(@RequestExcel List excelVOList, BindingResult bindingResult) { + return sysRoleService.importRole(excelVOList, bindingResult); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysSystemInfoController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysSystemInfoController.java new file mode 100644 index 00000000..4318abc7 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysSystemInfoController.java @@ -0,0 +1,59 @@ +package com.pig4cloud.pig.admin.controller; + +import com.pig4cloud.pig.common.core.util.R; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.*; + +@RestController +@RequestMapping("/system") +@RequiredArgsConstructor +@Tag(description = "system", name = "系统监控") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysSystemInfoController { + + private final RedisTemplate redisTemplate; + + /** + * 缓存监控 + * @return R + */ + @GetMapping("/cache") + public R cache() { + Properties info = (Properties) redisTemplate.execute((RedisCallback) RedisServerCommands::info); + Properties commandStats = (Properties) redisTemplate + .execute((RedisCallback) connection -> connection.info("commandstats")); + Object dbSize = redisTemplate.execute((RedisCallback) RedisServerCommands::dbSize); + + if (commandStats == null) { + return R.failed("获取异常"); + } + + Map result = new HashMap<>(3); + result.put("info", info); + result.put("dbSize", dbSize); + + List> pieList = new ArrayList<>(); + commandStats.stringPropertyNames().forEach(key -> { + Map data = new HashMap<>(2); + String property = commandStats.getProperty(key); + data.put("name", StringUtils.removeStart(key, "cmdstat_")); + data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); + pieList.add(data); + }); + + result.put("commandStats", pieList); + return R.ok(result); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysTokenController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysTokenController.java new file mode 100644 index 00000000..77c31f03 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysTokenController.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.admin.controller; + +import com.pig4cloud.pig.admin.api.feign.RemoteTokenService; +import com.pig4cloud.pig.common.core.constant.SecurityConstants; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * @author lengleng + * @date 2018/9/4 getTokenPage 管理 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/token") +@Tag(description = "token", name = "令牌管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysTokenController { + + private final RemoteTokenService remoteTokenService; + + /** + * 分页token 信息 + * @param params 参数集 + * @return token集合 + */ + @RequestMapping("/page") + public R getTokenPage(@RequestBody Map params) { + return remoteTokenService.getTokenPage(params, SecurityConstants.FROM_IN); + } + + /** + * 删除 + * @param tokens tokens + * @return success/false + */ + @SysLog("删除用户token") + @DeleteMapping("/delete") + @PreAuthorize("@pms.hasPermission('sys_token_del')") + public R removeById(@RequestBody String[] tokens) { + for (String token : tokens) { + remoteTokenService.removeTokenById(token, SecurityConstants.FROM_IN); + } + return R.ok(); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysUserController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysUserController.java new file mode 100644 index 00000000..7ba9f4e1 --- /dev/null +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysUserController.java @@ -0,0 +1,223 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pig.admin.controller; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.admin.api.dto.UserDTO; +import com.pig4cloud.pig.admin.api.entity.SysUser; +import com.pig4cloud.pig.admin.api.vo.UserExcelVO; +import com.pig4cloud.pig.admin.service.SysUserService; +import com.pig4cloud.pig.common.core.constant.CommonConstants; +import com.pig4cloud.pig.common.core.exception.ErrorCodes; +import com.pig4cloud.pig.common.core.util.MsgUtils; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.pig.common.security.annotation.Inner; +import com.pig4cloud.pig.common.security.util.SecurityUtils; +import com.pig4cloud.plugin.excel.annotation.RequestExcel; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author lengleng + * @date 2018/12/16 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/user") +@Tag(description = "user", name = "用户管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysUserController { + + private final SysUserService userService; + + /** + * 获取指定用户全部信息 + * @return 用户信息 + */ + @Inner + @GetMapping(value = { "/info/query" }) + public R info(@RequestParam(required = false) String username, @RequestParam(required = false) String phone) { + SysUser user = userService.getOne(Wrappers.query() + .lambda() + .eq(StrUtil.isNotBlank(username), SysUser::getUsername, username) + .eq(StrUtil.isNotBlank(phone), SysUser::getPhone, phone)); + if (user == null) { + return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username)); + } + return R.ok(userService.findUserInfo(user)); + } + + /** + * 获取当前用户全部信息 + * @return 用户信息 + */ + @GetMapping(value = { "/info" }) + public R info() { + String username = SecurityUtils.getUser().getUsername(); + SysUser user = userService.getOne(Wrappers.query().lambda().eq(SysUser::getUsername, username)); + if (user == null) { + return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_QUERY_ERROR)); + } + return R.ok(userService.findUserInfo(user)); + } + + /** + * 通过ID查询用户信息 + * @param id ID + * @return 用户信息 + */ + @GetMapping("/details/{id}") + public R user(@PathVariable Long id) { + return R.ok(userService.selectUserVoById(id)); + } + + /** + * 查询用户信息 + * @param query 查询条件 + * @return 不为空返回用户名 + */ + @Inner(value = false) + @GetMapping("/details") + public R getDetails(@ParameterObject SysUser query) { + SysUser sysUser = userService.getOne(Wrappers.query(query), false); + return R.ok(sysUser == null ? null : CommonConstants.SUCCESS); + } + + /** + * 删除用户信息 + * @param ids ID + * @return R + */ + @SysLog("删除用户信息") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('sys_user_del')") + @Operation(summary = "删除用户", description = "根据ID删除用户") + public R userDel(@RequestBody Long[] ids) { + return R.ok(userService.deleteUserByIds(ids)); + } + + /** + * 添加用户 + * @param userDto 用户信息 + * @return success/false + */ + @SysLog("添加用户") + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_user_add')") + public R user(@RequestBody UserDTO userDto) { + return R.ok(userService.saveUser(userDto)); + } + + /** + * 更新用户信息 + * @param userDto 用户信息 + * @return R + */ + @SysLog("更新用户信息") + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_user_edit')") + public R updateUser(@Valid @RequestBody UserDTO userDto) { + return R.ok(userService.updateUser(userDto)); + } + + /** + * 分页查询用户 + * @param page 参数集 + * @param userDTO 查询参数列表 + * @return 用户集合 + */ + @GetMapping("/page") + public R getUserPage(@ParameterObject Page page, @ParameterObject UserDTO userDTO) { + return R.ok(userService.getUsersWithRolePage(page, userDTO)); + } + + /** + * 修改个人信息 + * @param userDto userDto + * @return success/false + */ + @SysLog("修改个人信息") + @PutMapping("/edit") + public R updateUserInfo(@Valid @RequestBody UserDTO userDto) { + return userService.updateUserInfo(userDto); + } + + /** + * 导出excel 表格 + * @param userDTO 查询条件 + * @return + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('sys_user_export')") + public List export(UserDTO userDTO) { + return userService.listUser(userDTO); + } + + /** + * 导入用户 + * @param excelVOList 用户列表 + * @param bindingResult 错误信息列表 + * @return R + */ + @PostMapping("/import") + @PreAuthorize("@pms.hasPermission('sys_user_export')") + public R importUser(@RequestExcel List excelVOList, BindingResult bindingResult) { + return userService.importUser(excelVOList, bindingResult); + } + + /** + * 锁定指定用户 + * @param username 用户名 + * @return R + */ + @Inner + @PutMapping("/lock/{username}") + public R lockUser(@PathVariable String username) { + return userService.lockUser(username); + } + + @PutMapping("/password") + public R password(@RequestBody UserDTO userDto) { + String username = SecurityUtils.getUser().getUsername(); + userDto.setUsername(username); + return userService.changePassword(userDto); + } + + @PostMapping("/check") + public R check(String password) { + return userService.checkPassword(password); + } + +} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/TokenController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/TokenController.java deleted file mode 100644 index 3d53f91f..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/TokenController.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.controller; - -import com.pig4cloud.pig.admin.api.feign.RemoteTokenService; -import com.pig4cloud.pig.common.core.util.R; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import java.util.Map; - -/** - * @author lengleng - * @date 2018/9/4 getTokenPage 管理 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/token") -@Tag(name = "令牌管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class TokenController { - - private final RemoteTokenService remoteTokenService; - - /** - * 分页token 信息 - * @param params 参数集 - * @return token集合 - */ - @GetMapping("/page") - public R token(@RequestParam Map params) { - return remoteTokenService.getTokenPage(params); - } - - /** - * 删除 - * @param id ID - * @return success/false - */ - @DeleteMapping("/{id}") - @PreAuthorize("@pms.hasPermission('sys_token_del')") - public R delete(@PathVariable String id) { - return remoteTokenService.removeToken(id); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java deleted file mode 100644 index 3582c7e9..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.controller; - -import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.admin.api.dto.UserDTO; -import com.pig4cloud.pig.admin.api.dto.UserInfo; -import com.pig4cloud.pig.admin.api.entity.SysUser; -import com.pig4cloud.pig.admin.api.vo.UserExcelVO; -import com.pig4cloud.pig.admin.api.vo.UserInfoVO; -import com.pig4cloud.pig.admin.api.vo.UserVO; -import com.pig4cloud.pig.admin.service.SysUserService; -import com.pig4cloud.pig.common.core.exception.ErrorCodes; -import com.pig4cloud.pig.common.core.util.MsgUtils; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import com.pig4cloud.pig.common.security.annotation.Inner; -import com.pig4cloud.pig.common.security.util.SecurityUtils; -import com.pig4cloud.pig.common.xss.core.XssCleanIgnore; -import com.pig4cloud.plugin.excel.annotation.RequestExcel; -import com.pig4cloud.plugin.excel.annotation.ResponseExcel; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.*; - -import jakarta.validation.Valid; -import java.util.List; -import java.util.Set; - -/** - * @author lengleng - * @date 2019/2/1 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/user") -@Tag(name = "用户管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class UserController { - - private final SysUserService userService; - - /** - * 获取当前用户全部信息 - * @return 用户信息 - */ - @GetMapping(value = { "/info" }) - public R info() { - String username = SecurityUtils.getUser().getUsername(); - SysUser user = userService.getOne(Wrappers.query().lambda().eq(SysUser::getUsername, username)); - if (user == null) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_QUERY_ERROR)); - } - UserInfo userInfo = userService.getUserInfo(user); - UserInfoVO vo = new UserInfoVO(); - vo.setSysUser(userInfo.getSysUser()); - vo.setRoles(userInfo.getRoles()); - vo.setPermissions(userInfo.getPermissions()); - return R.ok(vo); - } - - /** - * 获取指定用户全部信息 - * @return 用户信息 - */ - @Inner - @GetMapping("/info/{username}") - public R info(@PathVariable String username) { - SysUser user = userService.getOne(Wrappers.query().lambda().eq(SysUser::getUsername, username)); - if (user == null) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username)); - } - return R.ok(userService.getUserInfo(user)); - } - - /** - * 根据部门id,查询对应的用户 id 集合 - * @param deptIds 部门id 集合 - * @return 用户 id 集合 - */ - @Inner - @GetMapping("/ids") - public R> listUserIdByDeptIds(@RequestParam("deptIds") Set deptIds) { - return R.ok(userService.listUserIdByDeptIds(deptIds)); - } - - /** - * 通过ID查询用户信息 - * @param id ID - * @return 用户信息 - */ - @GetMapping("/{id:\\d+}") - public R user(@PathVariable Long id) { - return R.ok(userService.getUserVoById(id)); - } - - /** - * 判断用户是否存在 - * @param userDTO 查询条件 - * @return - */ - @Inner(false) - @GetMapping("/check/exsit") - public R isExsit(UserDTO userDTO) { - List sysUserList = userService.list(new QueryWrapper<>(userDTO)); - if (CollUtil.isNotEmpty(sysUserList)) { - return R.ok(Boolean.TRUE, MsgUtils.getMessage(ErrorCodes.SYS_USER_EXISTING)); - } - return R.ok(Boolean.FALSE); - } - - /** - * 删除用户信息 - * @param id ID - * @return R - */ - @SysLog("删除用户信息") - @DeleteMapping("/{id:\\d+}") - @PreAuthorize("@pms.hasPermission('sys_user_del')") - public R userDel(@PathVariable Long id) { - SysUser sysUser = userService.getById(id); - return R.ok(userService.removeUserById(sysUser)); - } - - /** - * 添加用户 - * @param userDto 用户信息 - * @return success/false - */ - @SysLog("添加用户") - @PostMapping - @XssCleanIgnore({ "password" }) - @PreAuthorize("@pms.hasPermission('sys_user_add')") - public R user(@RequestBody UserDTO userDto) { - return R.ok(userService.saveUser(userDto)); - } - - /** - * 管理员更新用户信息 - * @param userDto 用户信息 - * @return R - */ - @SysLog("更新用户信息") - @PutMapping - @XssCleanIgnore({ "password" }) - @PreAuthorize("@pms.hasPermission('sys_user_edit')") - public R updateUser(@Valid @RequestBody UserDTO userDto) { - return userService.updateUser(userDto); - } - - /** - * 分页查询用户 - * @param page 参数集 - * @param userDTO 查询参数列表 - * @return 用户集合 - */ - @GetMapping("/page") - public R> getUserPage(Page page, UserDTO userDTO) { - return R.ok(userService.getUserWithRolePage(page, userDTO)); - } - - /** - * 个人修改个人信息 - * @param userDto userDto - * @return success/false - */ - @SysLog("修改个人信息") - @PutMapping("/edit") - @XssCleanIgnore({ "password", "newpassword1" }) - public R updateUserInfo(@Valid @RequestBody UserDTO userDto) { - userDto.setUsername(SecurityUtils.getUser().getUsername()); - return userService.updateUserInfo(userDto); - } - - /** - * @param username 用户名称 - * @return 上级部门用户列表 - */ - @GetMapping("/ancestor/{username}") - public R> listAncestorUsers(@PathVariable String username) { - return R.ok(userService.listAncestorUsersByUsername(username)); - } - - /** - * 导出excel 表格 - * @param userDTO 查询条件 - * @return - */ - @ResponseExcel - @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('sys_user_import_export')") - public List export(UserDTO userDTO) { - return userService.listUser(userDTO); - } - - /** - * 导入用户 - * @param excelVOList 用户列表 - * @param bindingResult 错误信息列表 - * @return R - */ - @PostMapping("/import") - @PreAuthorize("@pms.hasPermission('sys_user_import_export')") - public R importUser(@RequestExcel List excelVOList, BindingResult bindingResult) { - return userService.importUser(excelVOList, bindingResult); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDeptMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDeptMapper.java index fe8c985a..b949bdd8 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDeptMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDeptMapper.java @@ -1,42 +1,37 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysDept; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import java.util.List; - /** *

* 部门管理 Mapper 接口 *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-01-20 */ @Mapper public interface SysDeptMapper extends BaseMapper { - /** - * 关联dept——relation - * @return 数据列表 - */ - List listDepts(); - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDeptRelationMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDeptRelationMapper.java deleted file mode 100644 index ed1dd96d..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDeptRelationMapper.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.pig4cloud.pig.admin.api.entity.SysDeptRelation; -import org.apache.ibatis.annotations.Mapper; - -/** - *

- * Mapper 接口 - *

- * - * @author lengleng - * @since 2019/2/1 - */ -@Mapper -public interface SysDeptRelationMapper extends BaseMapper { - - /** - * 删除部门节点关系 - * @param deptRelation 待删除的某一个部门节点 - */ - void deleteDeptRelations(SysDeptRelation deptRelation); - - /** - * 删除部门节点关系,同时删除所有关联此部门子节点的部门关系 - * @param id 待删除的部门节点ID - */ - void deleteDeptRelationsById(Long id); - - /** - * 新增部门节点关系 - * @param deptRelation 待新增的部门节点关系 - */ - void insertDeptRelations(SysDeptRelation deptRelation); - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictItemMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictItemMapper.java index 14b7d1db..7dac9ba6 100755 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictItemMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictItemMapper.java @@ -1,22 +1,23 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysDictItem; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictMapper.java index 4993e29e..394e9ab0 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysDictMapper.java @@ -1,23 +1,26 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysDict; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysFileMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysFileMapper.java index 0c80a771..4f7fbaff 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysFileMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysFileMapper.java @@ -17,8 +17,8 @@ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysFile; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysLogMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysLogMapper.java index 140accba..f0d7a992 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysLogMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysLogMapper.java @@ -1,23 +1,26 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** @@ -26,7 +29,7 @@ import org.apache.ibatis.annotations.Mapper; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-11-20 */ @Mapper public interface SysLogMapper extends BaseMapper { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysMenuMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysMenuMapper.java index 9622ba7f..c7acc70c 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysMenuMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysMenuMapper.java @@ -1,26 +1,29 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysMenu; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import java.util.Set; +import java.util.List; /** *

@@ -28,7 +31,7 @@ import java.util.Set; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Mapper public interface SysMenuMapper extends BaseMapper { @@ -38,6 +41,6 @@ public interface SysMenuMapper extends BaseMapper { * @param roleId 角色ID * @return */ - Set listMenusByRoleId(Long roleId); + List listMenusByRoleId(Long roleId); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysOauthClientDetailsMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysOauthClientDetailsMapper.java index 124097e7..39a47d6a 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysOauthClientDetailsMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysOauthClientDetailsMapper.java @@ -1,23 +1,26 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** @@ -26,7 +29,7 @@ import org.apache.ibatis.annotations.Mapper; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-05-15 */ @Mapper public interface SysOauthClientDetailsMapper extends BaseMapper { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPostMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPostMapper.java index 46078d6b..9118e41b 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPostMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPostMapper.java @@ -17,17 +17,17 @@ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysPost; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** - * 岗位管理表 mapper接口 + * 岗位信息表 * * @author fxz - * @date 2022-03-15 17:18:40 + * @date 2022-03-26 12:50:43 */ @Mapper public interface SysPostMapper extends BaseMapper { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPublicParamMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPublicParamMapper.java index 55a8659a..b10662e7 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPublicParamMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysPublicParamMapper.java @@ -16,8 +16,8 @@ */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysPublicParam; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMapper.java index 6779e35a..dc6f847d 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMapper.java @@ -1,23 +1,26 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -28,7 +31,7 @@ import java.util.List; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Mapper public interface SysRoleMapper extends BaseMapper { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMenuMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMenuMapper.java index b6196ab4..2facf53e 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMenuMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysRoleMenuMapper.java @@ -1,23 +1,26 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysRoleMenu; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** @@ -26,7 +29,7 @@ import org.apache.ibatis.annotations.Mapper; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Mapper public interface SysRoleMenuMapper extends BaseMapper { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserMapper.java index 58fdaf1d..99b20667 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserMapper.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; @@ -33,7 +36,7 @@ import java.util.List; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Mapper public interface SysUserMapper extends BaseMapper { @@ -49,6 +52,7 @@ public interface SysUserMapper extends BaseMapper { * 分页查询用户信息(含角色) * @param page 分页 * @param userDTO 查询参数 + * @param dataScope * @return list */ IPage getUserVosPage(Page page, @Param("query") UserDTO userDTO); @@ -63,6 +67,7 @@ public interface SysUserMapper extends BaseMapper { /** * 查询用户列表 * @param userDTO 查询条件 + * @param dataScope 数据权限声明 * @return */ List selectVoList(@Param("query") UserDTO userDTO); diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserRoleMapper.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserRoleMapper.java index e0de4b70..890b85e5 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserRoleMapper.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/mapper/SysUserRoleMapper.java @@ -1,25 +1,27 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pig4cloud.pig.admin.api.entity.SysUserRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; /** *

@@ -27,18 +29,9 @@ import org.apache.ibatis.annotations.Param; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Mapper public interface SysUserRoleMapper extends BaseMapper { - /** - * 根据用户Id删除该用户的角色关系 - * @param userId 用户ID - * @return boolean - * @author 寻欢·李 - * @date 2017年12月7日 16:31:38 - */ - Boolean deleteByUserId(@Param("userId") Long userId); - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDeptRelationService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDeptRelationService.java deleted file mode 100644 index 72cbb950..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDeptRelationService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.pig4cloud.pig.admin.api.entity.SysDept; -import com.pig4cloud.pig.admin.api.entity.SysDeptRelation; - -/** - *

- * 服务类 - *

- * - * @author lengleng - * @since 2019/2/1 - */ -public interface SysDeptRelationService extends IService { - - /** - * 新建部门关系 - * @param sysDept 部门 - */ - void saveDeptRelation(SysDept sysDept); - - /** - * 通过ID删除部门关系 - * @param id - */ - void removeDeptRelationById(Long id); - - /** - * 更新部门关系 - * @param relation - */ - void updateDeptRelation(SysDeptRelation relation); - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDeptService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDeptService.java index 2005be34..4153e6ea 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDeptService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDeptService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; @@ -19,6 +22,9 @@ package com.pig4cloud.pig.admin.service; import cn.hutool.core.lang.tree.Tree; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.entity.SysDept; +import com.pig4cloud.pig.admin.api.vo.DeptExcelVo; +import com.pig4cloud.pig.common.core.util.R; +import org.springframework.validation.BindingResult; import java.util.List; @@ -28,28 +34,16 @@ import java.util.List; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-01-20 */ public interface SysDeptService extends IService { /** * 查询部门树菜单 + * @param deptName 部门名称 * @return 树 */ - List> listDeptTrees(); - - /** - * 查询用户部门树 - * @return - */ - List> listCurrentUserDeptTrees(); - - /** - * 添加信息部门 - * @param sysDept - * @return - */ - Boolean saveDept(SysDept sysDept); + List> selectTree(String deptName); /** * 删除部门 @@ -58,18 +52,15 @@ public interface SysDeptService extends IService { */ Boolean removeDeptById(Long id); - /** - * 更新部门 - * @param sysDept 部门信息 - * @return 成功、失败 - */ - Boolean updateDeptById(SysDept sysDept); + List listExcelVo(); + + R importDept(List excelVOList, BindingResult bindingResult); /** - * 查找指定部门的子部门id列表 - * @param deptId 部门id - * @return List + * 获取部门的所有后代部门列表 + * @param deptId 部门ID + * @return 后代部门列表 */ - List listChildDeptId(Long deptId); + List listDescendant(Long deptId); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictItemService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictItemService.java index d9af4afe..8963eb3c 100755 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictItemService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictItemService.java @@ -1,22 +1,24 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.service; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.entity.SysDictItem; +import com.pig4cloud.pig.common.core.util.R; /** * 字典项 @@ -31,13 +33,13 @@ public interface SysDictItemService extends IService { * @param id 字典项ID * @return */ - void removeDictItem(Long id); + R removeDictItem(Long id); /** * 更新字典项 * @param item 字典项 * @return */ - void updateDictItem(SysDictItem item); + R updateDictItem(SysDictItem item); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictService.java index 58ff67c4..90779628 100755 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysDictService.java @@ -1,22 +1,24 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.service; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.entity.SysDict; +import com.pig4cloud.pig.common.core.util.R; /** * 字典表 @@ -28,21 +30,22 @@ public interface SysDictService extends IService { /** * 根据ID 删除字典 - * @param id + * @param ids ID列表 * @return */ - void removeDict(Long id); + R removeDictByIds(Long[] ids); /** * 更新字典 * @param sysDict 字典 * @return */ - void updateDict(SysDict sysDict); + R updateDict(SysDict sysDict); /** - * 清除缓存 + * 同步缓存 (清空缓存) + * @return R */ - void clearDictCache(); + R syncDictCache(); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysFileService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysFileService.java index b73f129e..2ca5ba7f 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysFileService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysFileService.java @@ -20,9 +20,8 @@ package com.pig4cloud.pig.admin.service; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.entity.SysFile; import com.pig4cloud.pig.common.core.util.R; -import org.springframework.web.multipart.MultipartFile; - import jakarta.servlet.http.HttpServletResponse; +import org.springframework.web.multipart.MultipartFile; /** * 文件管理 @@ -54,12 +53,4 @@ public interface SysFileService extends IService { */ Boolean deleteFile(Long id); - /** - * 获取外网访问地址 - * @param bucket - * @param fileName - * @return - */ - String onlineFile(String bucket, String fileName); - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysLogService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysLogService.java index e81ccccb..7fe4dc7b 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysLogService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysLogService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; @@ -21,15 +24,13 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.dto.SysLogDTO; import com.pig4cloud.pig.admin.api.entity.SysLog; -import java.util.List; - /** *

* 日志表 服务类 *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-11-20 */ public interface SysLogService extends IService { @@ -39,13 +40,13 @@ public interface SysLogService extends IService { * @param sysLog * @return */ - Page getLogByPage(Page page, SysLogDTO sysLog); + Page getLogByPage(Page page, SysLogDTO sysLog); /** - * 列表查询日志 - * @param sysLog 查询条件 - * @return List + * 插入日志 + * @param sysLog 日志对象 + * @return true/false */ - List getLogList(SysLogDTO sysLog); + Boolean saveLog(SysLog sysLog); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysMenuService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysMenuService.java index 6b842e50..c1594d85 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysMenuService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysMenuService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; @@ -19,6 +22,7 @@ package com.pig4cloud.pig.admin.service; import cn.hutool.core.lang.tree.Tree; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.entity.SysMenu; +import com.pig4cloud.pig.common.core.util.R; import java.util.List; import java.util.Set; @@ -29,7 +33,7 @@ import java.util.Set; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ public interface SysMenuService extends IService { @@ -38,14 +42,14 @@ public interface SysMenuService extends IService { * @param roleId 角色ID * @return 菜单列表 */ - Set findMenuByRoleId(Long roleId); + List findMenuByRoleId(Long roleId); /** * 级联删除菜单 * @param id 菜单ID - * @return true成功, false失败 + * @return 成功、失败 */ - Boolean removeMenuById(Long id); + R removeMenuById(Long id); /** * 更新菜单信息 @@ -56,23 +60,18 @@ public interface SysMenuService extends IService { /** * 构建树 - * @param lazy 是否是懒加载 * @param parentId 父节点ID + * @param menuName 菜单名称 * @return */ - List> treeMenu(boolean lazy, Long parentId); + List> treeMenu(Long parentId, String menuName, String type); /** * 查询菜单 - * @param menuSet + * @param voSet * @param parentId * @return */ - List> filterMenu(Set menuSet, Long parentId); - - /** - * 清除菜单缓存 - */ - void clearMenuCache(); + List> filterMenu(Set voSet, String type, Long parentId); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/AppService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysMobileService.java similarity index 78% rename from pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/AppService.java rename to pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysMobileService.java index 80981864..d102831e 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/AppService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysMobileService.java @@ -17,28 +17,19 @@ package com.pig4cloud.pig.admin.service; -import com.pig4cloud.pig.admin.api.dto.AppSmsDTO; import com.pig4cloud.pig.common.core.util.R; /** * @author lengleng * @date 2018/11/14 */ -public interface AppService { +public interface SysMobileService { /** * 发送手机验证码 - * @param sms phone + * @param mobile mobile * @return code */ - R sendSmsCode(AppSmsDTO sms); - - /** - * 校验验证码 - * @param phone 手机号 - * @param code 验证码 - * @return - */ - boolean check(String phone, String code); + R sendSmsCode(String mobile); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysOauthClientDetailsService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysOauthClientDetailsService.java index ce4026c7..110c7c99 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysOauthClientDetailsService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysOauthClientDetailsService.java @@ -1,23 +1,28 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails; +import com.pig4cloud.pig.common.core.util.R; /** *

@@ -25,27 +30,36 @@ import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-05-15 */ public interface SysOauthClientDetailsService extends IService { /** - * 通过ID删除客户端 - * @param id + * 根据客户端信息 + * @param clientDetails * @return */ - Boolean removeClientDetailsById(String id); + Boolean updateClientById(SysOauthClientDetails clientDetails); /** - * 修改客户端信息 - * @param sysOauthClientDetails + * 添加客户端 + * @param clientDetails * @return */ - Boolean updateClientDetailsById(SysOauthClientDetails sysOauthClientDetails); + Boolean saveClient(SysOauthClientDetails clientDetails); /** - * 清除客户端缓存 + * 分页查询客户端信息 + * @param page + * @param query + * @return */ - void clearClientCache(); + Page queryPage(Page page, SysOauthClientDetails query); + + /** + * 同步缓存 (清空缓存) + * @return R + */ + R syncClientCache(); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPostService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPostService.java index 6bd2ea6c..e7349fa3 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPostService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPostService.java @@ -26,13 +26,19 @@ import org.springframework.validation.BindingResult; import java.util.List; /** - * 岗位管理 服务类 + * 岗位信息表 * * @author fxz - * @date 2022-03-15 17:18:40 + * @date 2022-03-26 12:50:43 */ public interface SysPostService extends IService { + /** + * 导出excel 表格 + * @return + */ + List listPost(); + /** * 导入岗位 * @param excelVOList 岗位列表 @@ -41,10 +47,4 @@ public interface SysPostService extends IService { */ R importPost(List excelVOList, BindingResult bindingResult); - /** - * 导出excel 表格 - * @return - */ - List listPost(); - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPublicParamService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPublicParamService.java index a834f9f2..e6f50ee4 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPublicParamService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysPublicParamService.java @@ -45,10 +45,10 @@ public interface SysPublicParamService extends IService { /** * 删除参数 - * @param publicId + * @param publicIds 参数列表 * @return */ - R removeParam(Long publicId); + R removeParamByIds(Long[] publicIds); /** * 同步缓存 diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java index f8f5c084..73a13c6e 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; @@ -25,13 +28,13 @@ import com.pig4cloud.pig.admin.api.entity.SysRoleMenu; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ public interface SysRoleMenuService extends IService { /** * 更新角色菜单 - * @param roleId 角色 + * @param roleId 角色ID * @param menuIds 菜单ID拼成的字符串,每个id之间根据逗号分隔 * @return */ diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleService.java index c00b36a1..cbd3e5c1 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; @@ -19,6 +22,7 @@ package com.pig4cloud.pig.admin.service; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pig.admin.api.entity.SysRole; import com.pig4cloud.pig.admin.api.vo.RoleExcelVO; +import com.pig4cloud.pig.admin.api.vo.RoleVO; import com.pig4cloud.pig.common.core.util.R; import org.springframework.validation.BindingResult; @@ -30,16 +34,38 @@ import java.util.List; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ public interface SysRoleService extends IService { /** - * 通过角色ID,删除角色 - * @param id + * 通过用户ID,查询角色信息 + * @param userId * @return */ - Boolean removeRoleById(Long id); + List findRolesByUserId(Long userId); + + /** + * 根据角色ID 查询角色列表 + * @param roleIdList 角色ID列表 + * @param key 缓存key + * @return + */ + List findRolesByRoleIds(List roleIdList, String key); + + /** + * 通过角色ID,删除角色 + * @param ids + * @return + */ + Boolean removeRoleByIds(Long[] ids); + + /** + * 根据角色菜单列表 + * @param roleVo 角色&菜单列表 + * @return + */ + Boolean updateRoleMenus(RoleVO roleVo); /** * 导入角色 diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserRoleService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserRoleService.java index 6860414f..b86a402a 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserRoleService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserRoleService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; @@ -25,7 +28,7 @@ import com.pig4cloud.pig.admin.api.entity.SysUserRole; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ public interface SysUserRoleService extends IService { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java index f58f39c5..cfcdfa0a 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service; @@ -28,11 +31,10 @@ import com.pig4cloud.pig.common.core.util.R; import org.springframework.validation.BindingResult; import java.util.List; -import java.util.Set; /** * @author lengleng - * @date 2019/2/1 + * @date 2017/10/31 */ public interface SysUserService extends IService { @@ -41,7 +43,7 @@ public interface SysUserService extends IService { * @param sysUser 用户 * @return userInfo */ - UserInfo getUserInfo(SysUser sysUser); + UserInfo findUserInfo(SysUser sysUser); /** * 分页查询用户信息(含有角色信息) @@ -49,19 +51,19 @@ public interface SysUserService extends IService { * @param userDTO 参数列表 * @return */ - IPage getUserWithRolePage(Page page, UserDTO userDTO); + IPage getUsersWithRolePage(Page page, UserDTO userDTO); /** * 删除用户 - * @param sysUser 用户 + * @param ids 用户 * @return boolean */ - Boolean removeUserById(SysUser sysUser); + Boolean deleteUserByIds(Long[] ids); /** * 更新当前用户基本信息 * @param userDto 用户信息 - * @return Boolean 操作成功返回true,操作失败返回false + * @return Boolean */ R updateUserInfo(UserDTO userDto); @@ -70,21 +72,14 @@ public interface SysUserService extends IService { * @param userDto 用户信息 * @return */ - R updateUser(UserDTO userDto); + Boolean updateUser(UserDTO userDto); /** * 通过ID查询用户信息 * @param id 用户ID * @return 用户信息 */ - UserVO getUserVoById(Long id); - - /** - * 查询上级部门的用户信息 - * @param username 用户名 - * @return R - */ - List listAncestorUsersByUsername(String username); + UserVO selectUserVoById(Long id); /** * 保存用户信息 @@ -108,13 +103,6 @@ public interface SysUserService extends IService { */ R importUser(List excelVOList, BindingResult bindingResult); - /** - * 根据部门 id 列表查询对应的用户 id 集合 - * @param deptIds 部门 id 列表 - * @return userIdList - */ - List listUserIdByDeptIds(Set deptIds); - /** * 注册用户 * @param userDto 用户信息 @@ -122,4 +110,25 @@ public interface SysUserService extends IService { */ R registerUser(UserDTO userDto); + /** + * 锁定用户 + * @param username + * @return + */ + R lockUser(String username); + + /** + * 修改密码 + * @param userDto 用户信息 + * @return + */ + R changePassword(UserDTO userDto); + + /** + * 校验密码 + * @param password 密码明文 + * @return + */ + R checkPassword(String password); + } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDeptRelationServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDeptRelationServiceImpl.java deleted file mode 100644 index 3f077e3d..00000000 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDeptRelationServiceImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.admin.service.impl; - -import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.pig4cloud.pig.admin.api.entity.SysDept; -import com.pig4cloud.pig.admin.api.entity.SysDeptRelation; -import com.pig4cloud.pig.admin.mapper.SysDeptRelationMapper; -import com.pig4cloud.pig.admin.service.SysDeptRelationService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.stream.Collectors; - -/** - *

- * 服务实现类 - *

- * - * @author lengleng - * @since 2019/2/1 - */ -@Service -@RequiredArgsConstructor -public class SysDeptRelationServiceImpl extends ServiceImpl - implements SysDeptRelationService { - - private final SysDeptRelationMapper sysDeptRelationMapper; - - /** - * 维护部门关系 - * @param sysDept 部门 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void saveDeptRelation(SysDept sysDept) { - // 增加部门关系表 - List relationList = sysDeptRelationMapper.selectList( - Wrappers.query().lambda().eq(SysDeptRelation::getDescendant, sysDept.getParentId())) - .stream() - .map(relation -> { - relation.setDescendant(sysDept.getDeptId()); - return relation; - }) - .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(relationList)) { - this.saveBatch(relationList); - } - - // 自己也要维护到关系表中 - SysDeptRelation own = new SysDeptRelation(); - own.setDescendant(sysDept.getDeptId()); - own.setAncestor(sysDept.getDeptId()); - sysDeptRelationMapper.insert(own); - } - - /** - * 通过ID删除部门关系 - * @param id - */ - @Override - public void removeDeptRelationById(Long id) { - baseMapper.deleteDeptRelationsById(id); - } - - /** - * 更新部门关系 - * @param relation - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDeptRelation(SysDeptRelation relation) { - baseMapper.deleteDeptRelations(relation); - baseMapper.insertDeptRelations(relation); - } - -} diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDeptServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDeptServiceImpl.java index b141b4e3..31cd166c 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDeptServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDeptServiceImpl.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service.impl; @@ -20,18 +23,20 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.TreeNode; import cn.hutool.core.lang.tree.TreeUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pig4cloud.pig.admin.api.entity.SysDept; -import com.pig4cloud.pig.admin.api.entity.SysDeptRelation; +import com.pig4cloud.pig.admin.api.vo.DeptExcelVo; import com.pig4cloud.pig.admin.mapper.SysDeptMapper; -import com.pig4cloud.pig.admin.service.SysDeptRelationService; import com.pig4cloud.pig.admin.service.SysDeptService; -import com.pig4cloud.pig.common.security.util.SecurityUtils; -import lombok.RequiredArgsConstructor; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.plugin.excel.vo.ErrorMessage; +import lombok.AllArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.BindingResult; import java.util.*; import java.util.stream.Collectors; @@ -42,28 +47,13 @@ import java.util.stream.Collectors; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-01-20 */ @Service -@RequiredArgsConstructor +@AllArgsConstructor public class SysDeptServiceImpl extends ServiceImpl implements SysDeptService { - private final SysDeptRelationService sysDeptRelationService; - - /** - * 添加信息部门 - * @param dept 部门 - * @return - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Boolean saveDept(SysDept dept) { - SysDept sysDept = new SysDept(); - BeanUtils.copyProperties(dept, sysDept); - this.save(sysDept); - sysDeptRelationService.saveDeptRelation(sysDept); - return Boolean.TRUE; - } + private final SysDeptMapper deptMapper; /** * 删除部门 @@ -74,85 +64,26 @@ public class SysDeptServiceImpl extends ServiceImpl impl @Transactional(rollbackFor = Exception.class) public Boolean removeDeptById(Long id) { // 级联删除部门 - List idList = sysDeptRelationService - .list(Wrappers.query().lambda().eq(SysDeptRelation::getAncestor, id)) - .stream() - .map(SysDeptRelation::getDescendant) - .collect(Collectors.toList()); + List idList = this.listDescendant(id).stream().map(SysDept::getDeptId).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(idList)) { - this.removeByIds(idList); - } + Optional.ofNullable(idList).filter(CollUtil::isNotEmpty).ifPresent(this::removeByIds); - // 删除部门级联关系 - sysDeptRelationService.removeDeptRelationById(id); return Boolean.TRUE; } - /** - * 更新部门 - * @param sysDept 部门信息 - * @return 成功、失败 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Boolean updateDeptById(SysDept sysDept) { - // 更新部门状态 - this.updateById(sysDept); - // 更新部门关系 - SysDeptRelation relation = new SysDeptRelation(); - relation.setAncestor(sysDept.getParentId()); - relation.setDescendant(sysDept.getDeptId()); - sysDeptRelationService.updateDeptRelation(relation); - return Boolean.TRUE; - } - - @Override - public List listChildDeptId(Long deptId) { - List deptRelations = sysDeptRelationService.list(Wrappers.lambdaQuery() - .eq(SysDeptRelation::getAncestor, deptId) - .ne(SysDeptRelation::getDescendant, deptId)); - if (CollUtil.isNotEmpty(deptRelations)) { - return deptRelations.stream().map(SysDeptRelation::getDescendant).collect(Collectors.toList()); - } - return new ArrayList<>(); - } - /** * 查询全部部门树 - * @return 树 + * @param deptName + * @return 树 部门名称 */ @Override - public List> listDeptTrees() { - return getDeptTree(this.list(Wrappers.emptyWrapper()), 0L); - } + public List> selectTree(String deptName) { + // 查询全部部门 + List deptAllList = deptMapper + .selectList(Wrappers.lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName)); - /** - * 查询用户部门树 - * @return - */ - @Override - public List> listCurrentUserDeptTrees() { - Long deptId = SecurityUtils.getUser().getDeptId(); - List descendantIdList = sysDeptRelationService - .list(Wrappers.query().lambda().eq(SysDeptRelation::getAncestor, deptId)) - .stream() - .map(SysDeptRelation::getDescendant) - .collect(Collectors.toList()); - - List deptList = baseMapper.selectBatchIds(descendantIdList); - Optional dept = deptList.stream().filter(item -> item.getDeptId().intValue() == deptId).findFirst(); - return getDeptTree(deptList, dept.isPresent() ? dept.get().getParentId() : 0L); - } - - /** - * 构建部门树 - * @param depts 部门 - * @param parentId 父级id - * @return - */ - private List> getDeptTree(List depts, Long parentId) { - List> collect = depts.stream() + // 权限内部门 + List> collect = deptAllList.stream() .filter(dept -> dept.getDeptId().intValue() != dept.getParentId()) .sorted(Comparator.comparingInt(SysDept::getSortOrder)) .map(dept -> { @@ -161,15 +92,119 @@ public class SysDeptServiceImpl extends ServiceImpl impl treeNode.setParentId(dept.getParentId()); treeNode.setName(dept.getName()); treeNode.setWeight(dept.getSortOrder()); - // 扩展属性 - Map extra = new HashMap<>(4); + // 有权限不返回标识 + Map extra = new HashMap<>(8); extra.put("createTime", dept.getCreateTime()); treeNode.setExtra(extra); return treeNode; }) .collect(Collectors.toList()); - return TreeUtil.build(collect, parentId); + // 模糊查询 不组装树结构 直接返回 表格方便编辑 + if (StrUtil.isNotBlank(deptName)) { + return collect.stream().map(node -> { + Tree tree = new Tree<>(); + tree.putAll(node.getExtra()); + BeanUtils.copyProperties(node, tree); + return tree; + }).collect(Collectors.toList()); + } + + return TreeUtil.build(collect, 0L); + } + + /** + * 导出部门 + * @return + */ + @Override + public List listExcelVo() { + List list = this.list(); + List deptExcelVos = list.stream().map(item -> { + DeptExcelVo deptExcelVo = new DeptExcelVo(); + deptExcelVo.setName(item.getName()); + Optional first = this.list() + .stream() + .filter(it -> item.getParentId().equals(it.getDeptId())) + .map(SysDept::getName) + .findFirst(); + deptExcelVo.setParentName(first.orElse("根部门")); + deptExcelVo.setSortOrder(item.getSortOrder()); + return deptExcelVo; + }).collect(Collectors.toList()); + return deptExcelVos; + } + + @Override + public R importDept(List excelVOList, BindingResult bindingResult) { + List errorMessageList = (List) bindingResult.getTarget(); + + List deptList = this.list(); + for (DeptExcelVo item : excelVOList) { + Set errorMsg = new HashSet<>(); + boolean exsitUsername = deptList.stream().anyMatch(sysDept -> item.getName().equals(sysDept.getName())); + if (exsitUsername) { + errorMsg.add("部门名称已经存在"); + } + SysDept one = this.getOne(Wrappers.lambdaQuery().eq(SysDept::getName, item.getParentName())); + if (item.getParentName().equals("根部门")) { + one = new SysDept(); + one.setDeptId(0L); + } + if (one == null) { + errorMsg.add("上级部门不存在"); + } + if (CollUtil.isEmpty(errorMsg)) { + SysDept sysDept = new SysDept(); + sysDept.setName(item.getName()); + sysDept.setParentId(one.getDeptId()); + sysDept.setSortOrder(item.getSortOrder()); + baseMapper.insert(sysDept); + } + else { + // 数据不合法情况 + errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg)); + } + } + if (CollUtil.isNotEmpty(errorMessageList)) { + return R.failed(errorMessageList); + } + return R.ok(null, "部门导入成功"); + } + + /** + * 查询所有子节点 (包含当前节点) + * @param deptId 部门ID 目标部门ID + * @return ID + */ + @Override + public List listDescendant(Long deptId) { + // 查询全部部门 + List allDeptList = baseMapper.selectList(Wrappers.emptyWrapper()); + + // 递归查询所有子节点 + List resDeptList = new ArrayList<>(); + recursiveDept(allDeptList, deptId, resDeptList); + + // 添加当前节点 + resDeptList.addAll(allDeptList.stream() + .filter(sysDept -> deptId.equals(sysDept.getDeptId())) + .collect(Collectors.toList())); + return resDeptList; + } + + /** + * 递归查询所有子节点。 + * @param allDeptList 所有部门列表 + * @param parentId 父部门ID + * @param resDeptList 结果集合 + */ + private void recursiveDept(List allDeptList, Long parentId, List resDeptList) { + // 使用 Stream API 进行筛选和遍历 + allDeptList.stream().filter(sysDept -> sysDept.getParentId().equals(parentId)).forEach(sysDept -> { + resDeptList.add(sysDept); + recursiveDept(allDeptList, sysDept.getDeptId(), resDeptList); + }); } } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDictItemServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDictItemServiceImpl.java index 65c729f2..b265c8cf 100755 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDictItemServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysDictItemServiceImpl.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.admin.service.impl; @@ -25,10 +26,10 @@ import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum; import com.pig4cloud.pig.common.core.exception.ErrorCodes; import com.pig4cloud.pig.common.core.util.MsgUtils; -import lombok.RequiredArgsConstructor; +import com.pig4cloud.pig.common.core.util.R; +import lombok.AllArgsConstructor; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; -import org.springframework.util.Assert; /** * 字典项 @@ -37,7 +38,7 @@ import org.springframework.util.Assert; * @date 2019/03/19 */ @Service -@RequiredArgsConstructor +@AllArgsConstructor public class SysDictItemServiceImpl extends ServiceImpl implements SysDictItemService { private final SysDictService dictService; @@ -49,14 +50,15 @@ public class SysDictItemServiceImpl extends ServiceImpl implements SysDictService { private final SysDictItemMapper dictItemMapper; /** * 根据ID 删除字典 - * @param id 字典ID + * @param ids 字典ID 列表 * @return */ @Override @Transactional(rollbackFor = Exception.class) @CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true) - public void removeDict(Long id) { - SysDict dict = this.getById(id); - // 系统内置 - Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag()), - MsgUtils.getMessage(ErrorCodes.SYS_DICT_DELETE_SYSTEM)); - baseMapper.deleteById(id); - dictItemMapper.delete(Wrappers.lambdaQuery().eq(SysDictItem::getDictId, id)); + public R removeDictByIds(Long[] ids) { + + List dictIdList = baseMapper.selectBatchIds(CollUtil.toList(ids)) + .stream() + .filter(sysDict -> !sysDict.getSystemFlag().equals(DictTypeEnum.SYSTEM.getType()))// 系统内置类型不删除 + .map(SysDict::getId) + .collect(Collectors.toList()); + + baseMapper.deleteBatchIds(dictIdList); + + dictItemMapper.delete(Wrappers.lambdaQuery().in(SysDictItem::getDictId, dictIdList)); + return R.ok(); } /** @@ -67,19 +77,25 @@ public class SysDictServiceImpl extends ServiceImpl impl * @return */ @Override - @CacheEvict(value = CacheConstants.DICT_DETAILS, key = "#dict.type") - public void updateDict(SysDict dict) { + @CacheEvict(value = CacheConstants.DICT_DETAILS, key = "#dict.dictType") + public R updateDict(SysDict dict) { SysDict sysDict = this.getById(dict.getId()); // 系统内置 - Assert.state(!DictTypeEnum.SYSTEM.getType().equals(sysDict.getSystemFlag()), - MsgUtils.getMessage(ErrorCodes.SYS_DICT_UPDATE_SYSTEM)); + if (DictTypeEnum.SYSTEM.getType().equals(sysDict.getSystemFlag())) { + return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_DICT_UPDATE_SYSTEM)); + } this.updateById(dict); + return R.ok(dict); } + /** + * 同步缓存 (清空缓存) + * @return R + */ @Override @CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true) - public void clearDictCache() { - + public R syncDictCache() { + return R.ok(); } } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysFileServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysFileServiceImpl.java index 3e9f197e..3a7ff84d 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysFileServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysFileServiceImpl.java @@ -26,8 +26,9 @@ import com.pig4cloud.pig.admin.api.entity.SysFile; import com.pig4cloud.pig.admin.mapper.SysFileMapper; import com.pig4cloud.pig.admin.service.SysFileService; import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.plugin.oss.OssProperties; -import com.pig4cloud.plugin.oss.service.OssTemplate; +import com.pig4cloud.pig.common.file.core.FileProperties; +import com.pig4cloud.pig.common.file.core.FileTemplate; +import jakarta.servlet.http.HttpServletResponse; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -35,11 +36,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import jakarta.servlet.http.HttpServletResponse; -import java.time.Duration; -import java.time.temporal.ChronoUnit; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; +import java.util.Objects; /** * 文件管理 @@ -52,9 +52,9 @@ import java.util.Map; @AllArgsConstructor public class SysFileServiceImpl extends ServiceImpl implements SysFileService { - private final OssProperties ossProperties; + private final FileTemplate fileTemplate; - private final OssTemplate ossTemplate; + private final FileProperties properties; /** * 上传文件 @@ -65,13 +65,12 @@ public class SysFileServiceImpl extends ServiceImpl impl public R uploadFile(MultipartFile file) { String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(file.getOriginalFilename()); Map resultMap = new HashMap<>(4); - resultMap.put("bucketName", ossProperties.getBucketName()); + resultMap.put("bucketName", properties.getBucketName()); resultMap.put("fileName", fileName); - resultMap.put("url", String.format("/admin/sys-file/%s/%s", ossProperties.getBucketName(), fileName)); + resultMap.put("url", String.format("/admin/sys-file/%s/%s", properties.getBucketName(), fileName)); - try { - ossTemplate.putObject(ossProperties.getBucketName(), fileName, file.getContentType(), - file.getInputStream()); + try (InputStream inputStream = file.getInputStream()) { + fileTemplate.putObject(properties.getBucketName(), fileName, inputStream, file.getContentType()); // 文件管理数据记录,收集管理追踪文件 fileLog(file, fileName); } @@ -90,7 +89,7 @@ public class SysFileServiceImpl extends ServiceImpl impl */ @Override public void getFile(String bucket, String fileName, HttpServletResponse response) { - try (S3Object s3Object = ossTemplate.getObject(bucket, fileName)) { + try (S3Object s3Object = fileTemplate.getObject(bucket, fileName)) { response.setContentType("application/octet-stream; charset=UTF-8"); IoUtil.copy(s3Object.getObjectContent(), response.getOutputStream()); } @@ -109,7 +108,10 @@ public class SysFileServiceImpl extends ServiceImpl impl @Transactional(rollbackFor = Exception.class) public Boolean deleteFile(Long id) { SysFile file = this.getById(id); - ossTemplate.removeObject(ossProperties.getBucketName(), file.getFileName()); + if (Objects.isNull(file)) { + return Boolean.FALSE; + } + fileTemplate.removeObject(properties.getBucketName(), file.getFileName()); return this.removeById(id); } @@ -124,19 +126,8 @@ public class SysFileServiceImpl extends ServiceImpl impl sysFile.setOriginal(file.getOriginalFilename()); sysFile.setFileSize(file.getSize()); sysFile.setType(FileUtil.extName(file.getOriginalFilename())); - sysFile.setBucketName(ossProperties.getBucketName()); + sysFile.setBucketName(properties.getBucketName()); this.save(sysFile); } - /** - * 默认获取文件的在线地址 - * @param bucket - * @param fileName - * @return - */ - @Override - public String onlineFile(String bucket, String fileName) { - return ossTemplate.getObjectURL(bucket, fileName, Duration.of(7, ChronoUnit.DAYS)); - } - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysLogServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysLogServiceImpl.java index eb04d3f6..f956a0ae 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysLogServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysLogServiceImpl.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service.impl; @@ -27,8 +30,7 @@ import com.pig4cloud.pig.admin.api.entity.SysLog; import com.pig4cloud.pig.admin.mapper.SysLogMapper; import com.pig4cloud.pig.admin.service.SysLogService; import org.springframework.stereotype.Service; - -import java.util.List; +import org.springframework.transaction.annotation.Transactional; /** *

@@ -36,42 +38,37 @@ import java.util.List; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-11-20 */ @Service public class SysLogServiceImpl extends ServiceImpl implements SysLogService { @Override public Page getLogByPage(Page page, SysLogDTO sysLog) { - return baseMapper.selectPage(page, buildQueryWrapper(sysLog)); - } - /** - * 列表查询日志 - * @param sysLog 查询条件 - * @return List - */ - @Override - public List getLogList(SysLogDTO sysLog) { - return baseMapper.selectList(buildQueryWrapper(sysLog)); - } - - /** - * 构建查询的 wrapper - * @param sysLog 查询条件 - * @return LambdaQueryWrapper - */ - private LambdaQueryWrapper buildQueryWrapper(SysLogDTO sysLog) { - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() - .eq(StrUtil.isNotBlank(sysLog.getType()), SysLog::getType, sysLog.getType()) - .like(StrUtil.isNotBlank(sysLog.getRemoteAddr()), SysLog::getRemoteAddr, sysLog.getRemoteAddr()); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + if (StrUtil.isNotBlank(sysLog.getLogType())) { + wrapper.eq(SysLog::getLogType, sysLog.getLogType()); + } if (ArrayUtil.isNotEmpty(sysLog.getCreateTime())) { wrapper.ge(SysLog::getCreateTime, sysLog.getCreateTime()[0]) .le(SysLog::getCreateTime, sysLog.getCreateTime()[1]); } - return wrapper; + return baseMapper.selectPage(page, wrapper); + } + + /** + * 插入日志 + * @param sysLog 日志对象 + * @return true/false + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean saveLog(SysLog sysLog) { + baseMapper.insert(sysLog); + return Boolean.TRUE; } } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysMenuServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysMenuServiceImpl.java index 09fadb1e..1041e048 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysMenuServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysMenuServiceImpl.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service.impl; @@ -20,6 +23,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.TreeNode; import cn.hutool.core.lang.tree.TreeUtil; +import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -33,19 +37,22 @@ import com.pig4cloud.pig.common.core.constant.CommonConstants; import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum; import com.pig4cloud.pig.common.core.exception.ErrorCodes; import com.pig4cloud.pig.common.core.util.MsgUtils; -import lombok.RequiredArgsConstructor; +import com.pig4cloud.pig.common.core.util.R; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; -import jakarta.validation.constraints.NotNull; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; /** @@ -57,34 +64,31 @@ import java.util.stream.Collectors; * @since 2017-10-29 */ @Service -@RequiredArgsConstructor +@AllArgsConstructor +@Slf4j public class SysMenuServiceImpl extends ServiceImpl implements SysMenuService { private final SysRoleMenuMapper sysRoleMenuMapper; @Override - @Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null") - public Set findMenuByRoleId(Long roleId) { + @Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId", unless = "#result.isEmpty()") + public List findMenuByRoleId(Long roleId) { return baseMapper.listMenusByRoleId(roleId); } - /** - * 级联删除菜单 - * @param id 菜单ID - * @return true成功, false失败 - */ @Override @Transactional(rollbackFor = Exception.class) @CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true) - public Boolean removeMenuById(Long id) { + public R removeMenuById(Long id) { // 查询父节点为当前节点的节点 List menuList = this.list(Wrappers.query().lambda().eq(SysMenu::getParentId, id)); - - Assert.isTrue(CollUtil.isEmpty(menuList), MsgUtils.getMessage(ErrorCodes.SYS_MENU_DELETE_EXISTING)); + if (CollUtil.isNotEmpty(menuList)) { + return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_MENU_DELETE_EXISTING)); + } sysRoleMenuMapper.delete(Wrappers.query().lambda().eq(SysRoleMenu::getMenuId, id)); // 删除当前菜单及其子菜单 - return this.removeById(id); + return R.ok(this.removeById(id)); } @Override @@ -95,57 +99,54 @@ public class SysMenuServiceImpl extends ServiceImpl impl /** * 构建树查询 1. 不是懒加载情况,查询全部 2. 是懒加载,根据parentId 查询 2.1 父节点为空,则查询ID -1 - * @param lazy 是否是懒加载 * @param parentId 父节点ID + * @param menuName 菜单名称 * @return */ @Override - public List> treeMenu(boolean lazy, Long parentId) { - if (!lazy) { - List> collect = baseMapper - .selectList(Wrappers.lambdaQuery().orderByAsc(SysMenu::getSortOrder)) - .stream() - .map(getNodeFunction()) - .collect(Collectors.toList()); - - return TreeUtil.build(collect, CommonConstants.MENU_TREE_ROOT_ID); - } - + public List> treeMenu(Long parentId, String menuName, String type) { Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId; List> collect = baseMapper - .selectList( - Wrappers.lambdaQuery().eq(SysMenu::getParentId, parent).orderByAsc(SysMenu::getSortOrder)) + .selectList(Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(menuName), SysMenu::getName, menuName) + .eq(StrUtil.isNotBlank(type), SysMenu::getMenuType, type) + .orderByAsc(SysMenu::getSortOrder)) .stream() .map(getNodeFunction()) .collect(Collectors.toList()); + // 模糊查询 不组装树结构 直接返回 表格方便编辑 + if (StrUtil.isNotBlank(menuName)) { + return collect.stream().map(node -> { + Tree tree = new Tree<>(); + tree.putAll(node.getExtra()); + BeanUtils.copyProperties(node, tree); + return tree; + }).collect(Collectors.toList()); + } + return TreeUtil.build(collect, parent); } /** * 查询菜单 * @param all 全部菜单 + * @param type 类型 * @param parentId 父节点ID * @return */ @Override - public List> filterMenu(Set all, Long parentId) { + public List> filterMenu(Set all, String type, Long parentId) { List> collect = all.stream() - .filter(menu -> MenuTypeEnum.LEFT_MENU.getType().equals(menu.getType())) - .filter(menu -> StrUtil.isNotBlank(menu.getPath())) + .filter(menuTypePredicate(type)) .map(getNodeFunction()) .collect(Collectors.toList()); + Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId; return TreeUtil.build(collect, parent); } - @Override - @CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true) - public void clearMenuCache() { - - } - @NotNull private Function> getNodeFunction() { return menu -> { @@ -156,16 +157,42 @@ public class SysMenuServiceImpl extends ServiceImpl impl node.setWeight(menu.getSortOrder()); // 扩展属性 Map extra = new HashMap<>(); - extra.put("icon", menu.getIcon()); extra.put("path", menu.getPath()); - extra.put("type", menu.getType()); + extra.put("menuType", menu.getMenuType()); extra.put("permission", menu.getPermission()); - extra.put("label", menu.getName()); extra.put("sortOrder", menu.getSortOrder()); - extra.put("keepAlive", menu.getKeepAlive()); + + // 适配 vue3 + Map meta = new HashMap<>(); + meta.put("title", menu.getName()); + meta.put("isLink", menu.getPath() != null && menu.getPath().startsWith("http") ? menu.getPath() : ""); + meta.put("isHide", !BooleanUtil.toBooleanObject(menu.getVisible())); + meta.put("isKeepAlive", BooleanUtil.toBooleanObject(menu.getKeepAlive())); + meta.put("isAffix", false); + meta.put("isIframe", BooleanUtil.toBooleanObject(menu.getEmbedded())); + meta.put("icon", menu.getIcon()); + // 增加英文 + meta.put("enName", menu.getEnName()); + + extra.put("meta", meta); node.setExtra(extra); return node; }; } + /** + * menu 类型断言 + * @param type 类型 + * @return Predicate + */ + private Predicate menuTypePredicate(String type) { + return vo -> { + if (MenuTypeEnum.TOP_MENU.getDescription().equals(type)) { + return MenuTypeEnum.TOP_MENU.getType().equals(vo.getMenuType()); + } + // 其他查询 左侧 + 顶部 + return !MenuTypeEnum.BUTTON.getType().equals(vo.getMenuType()); + }; + } + } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/AppServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysMobileServiceImpl.java similarity index 64% rename from pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/AppServiceImpl.java rename to pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysMobileServiceImpl.java index a68246b5..13f1905d 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/AppServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysMobileServiceImpl.java @@ -17,24 +17,25 @@ package com.pig4cloud.pig.admin.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.RandomUtil; +import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.pig4cloud.pig.admin.api.dto.AppSmsDTO; import com.pig4cloud.pig.admin.api.entity.SysUser; import com.pig4cloud.pig.admin.mapper.SysUserMapper; -import com.pig4cloud.pig.admin.service.AppService; +import com.pig4cloud.pig.admin.service.SysMobileService; import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.SecurityConstants; +import com.pig4cloud.pig.common.core.constant.enums.LoginTypeEnum; import com.pig4cloud.pig.common.core.exception.ErrorCodes; import com.pig4cloud.pig.common.core.util.MsgUtils; import com.pig4cloud.pig.common.core.util.R; -import io.springboot.sms.core.SmsClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import java.util.Objects; +import java.util.List; import java.util.concurrent.TimeUnit; /** @@ -46,58 +47,39 @@ import java.util.concurrent.TimeUnit; @Slf4j @Service @AllArgsConstructor -public class AppServiceImpl implements AppService { +public class SysMobileServiceImpl implements SysMobileService { private final RedisTemplate redisTemplate; private final SysUserMapper userMapper; - private final SmsClient smsClient; - /** * 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端 - * @param sms 手机号 + * @param mobile mobile * @return code */ @Override - public R sendSmsCode(AppSmsDTO sms) { - Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + sms.getPhone()); + public R sendSmsCode(String mobile) { + List userList = userMapper + .selectList(Wrappers.query().lambda().eq(SysUser::getPhone, mobile)); + + if (CollUtil.isEmpty(userList)) { + log.info("手机号未注册:{}", mobile); + return R.ok(Boolean.FALSE, MsgUtils.getMessage(ErrorCodes.SYS_APP_PHONE_UNREGISTERED, mobile)); + } + + Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + mobile); if (codeObj != null) { - log.info("手机号验证码未过期:{},{}", sms.getPhone(), codeObj); + log.info("手机号验证码未过期:{},{}", mobile, codeObj); return R.ok(Boolean.FALSE, MsgUtils.getMessage(ErrorCodes.SYS_APP_SMS_OFTEN)); } - // 校验手机号是否存在 sys_user 表 - if (sms.getExist() - && !userMapper.exists(Wrappers.lambdaQuery().eq(SysUser::getPhone, sms.getPhone()))) { - return R.ok(Boolean.FALSE, MsgUtils.getMessage(ErrorCodes.SYS_APP_PHONE_UNREGISTERED, sms.getPhone())); - } - String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE)); - log.info("手机号生成验证码成功:{},{}", sms.getPhone(), code); + log.debug("手机号生成验证码成功:{},{}", mobile, code); redisTemplate.opsForValue() - .set(CacheConstants.DEFAULT_CODE_KEY + sms.getPhone(), code, SecurityConstants.CODE_TIME, TimeUnit.SECONDS); - - // 调用短信通道发送 - this.smsClient.sendCode(code, sms.getPhone()); + .set(CacheConstants.DEFAULT_CODE_KEY + mobile, code, SecurityConstants.CODE_TIME, TimeUnit.SECONDS); return R.ok(Boolean.TRUE, code); } - /** - * 校验验证码 - * @param phone 手机号 - * @param code 验证码 - * @return - */ - @Override - public boolean check(String phone, String code) { - Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + phone); - - if (Objects.isNull(codeObj)) { - return false; - } - return codeObj.equals(code); - } - } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysOauthClientDetailsServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysOauthClientDetailsServiceImpl.java index 60dbdb81..2e267c7a 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysOauthClientDetailsServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysOauthClientDetailsServiceImpl.java @@ -1,28 +1,36 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service.impl; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails; import com.pig4cloud.pig.admin.mapper.SysOauthClientDetailsMapper; import com.pig4cloud.pig.admin.service.SysOauthClientDetailsService; import com.pig4cloud.pig.common.core.constant.CacheConstants; +import com.pig4cloud.pig.common.core.util.R; +import lombok.RequiredArgsConstructor; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** *

@@ -30,23 +38,13 @@ import org.springframework.stereotype.Service; *

* * @author lengleng - * @since 2019/2/1 + * @since 2018-05-15 */ @Service +@RequiredArgsConstructor public class SysOauthClientDetailsServiceImpl extends ServiceImpl implements SysOauthClientDetailsService { - /** - * 通过ID删除客户端 - * @param id - * @return - */ - @Override - @CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#id") - public Boolean removeClientDetailsById(String id) { - return this.removeById(id); - } - /** * 根据客户端信息 * @param clientDetails @@ -54,17 +52,50 @@ public class SysOauthClientDetailsServiceImpl extends ServiceImpl implements SysPostService { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPublicParamServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPublicParamServiceImpl.java index 677065fd..2fff4c42 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPublicParamServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPublicParamServiceImpl.java @@ -17,6 +17,7 @@ package com.pig4cloud.pig.admin.service.impl; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pig4cloud.pig.admin.api.entity.SysPublicParam; @@ -32,6 +33,9 @@ import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.stream.Collectors; + /** * 公共参数配置 * @@ -73,18 +77,18 @@ public class SysPublicParamServiceImpl extends ServiceImpl idList = this.baseMapper.selectBatchIds(CollUtil.toList(publicIds)) + .stream() + .filter(p -> !p.getSystemFlag().equals(DictTypeEnum.SYSTEM.getType()))// 系统内置的跳过不能删除 + .map(SysPublicParam::getPublicId) + .collect(Collectors.toList()); + return R.ok(this.removeBatchByIds(idList)); } /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java index f57049a7..afdd1016 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service.impl; @@ -23,14 +26,14 @@ import com.pig4cloud.pig.admin.api.entity.SysRoleMenu; import com.pig4cloud.pig.admin.mapper.SysRoleMenuMapper; import com.pig4cloud.pig.admin.service.SysRoleMenuService; import com.pig4cloud.pig.common.core.constant.CacheConstants; -import lombok.RequiredArgsConstructor; +import lombok.AllArgsConstructor; import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; /** @@ -39,10 +42,10 @@ import java.util.stream.Collectors; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Service -@RequiredArgsConstructor +@AllArgsConstructor public class SysRoleMenuServiceImpl extends ServiceImpl implements SysRoleMenuService { private final CacheManager cacheManager; @@ -54,6 +57,7 @@ public class SysRoleMenuServiceImpl extends ServiceImplquery().lambda().eq(SysRoleMenu::getRoleId, roleId)); @@ -68,10 +72,9 @@ public class SysRoleMenuServiceImpl extends ServiceImpl * * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Service -@RequiredArgsConstructor +@AllArgsConstructor public class SysRoleServiceImpl extends ServiceImpl implements SysRoleService { - private final SysRoleMenuMapper sysRoleMenuMapper; + private SysRoleMenuService roleMenuService; + + /** + * 通过用户ID,查询角色信息 + * @param userId + * @return + */ + @Override + public List findRolesByUserId(Long userId) { + return baseMapper.listRolesByUserId(userId); + } + + /** + * 根据角色ID 查询角色列表,注意缓存删除 + * @param roleIdList 角色ID列表 + * @param key 缓存key + * @return + */ + @Override + @Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()") + public List findRolesByRoleIds(List roleIdList, String key) { + return baseMapper.selectBatchIds(roleIdList); + } /** * 通过角色ID,删除角色,并清空角色菜单缓存 - * @param id + * @param ids * @return */ @Override @Transactional(rollbackFor = Exception.class) - @CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true) - public Boolean removeRoleById(Long id) { - sysRoleMenuMapper.delete(Wrappers.update().lambda().eq(SysRoleMenu::getRoleId, id)); - return this.removeById(id); + public Boolean removeRoleByIds(Long[] ids) { + roleMenuService + .remove(Wrappers.update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids))); + return this.removeBatchByIds(CollUtil.toList(ids)); + } + + /** + * 根据角色菜单列表 + * @param roleVo 角色&菜单列表 + * @return + */ + @Override + public Boolean updateRoleMenus(RoleVO roleVo) { + return roleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds()); } /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserRoleServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserRoleServiceImpl.java index 4fb064d0..820d420b 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserRoleServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserRoleServiceImpl.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service.impl; @@ -28,7 +31,7 @@ import org.springframework.stereotype.Service; *

* * @author lengleng - * @since 2019/2/1 + * @since 2017-10-29 */ @Service public class SysUserRoleServiceImpl extends ServiceImpl implements SysUserRoleService { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java index 1dc22a87..ff15407c 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java @@ -1,17 +1,20 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.pig4cloud.pig.admin.service.impl; @@ -19,6 +22,7 @@ package com.pig4cloud.pig.admin.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -29,26 +33,27 @@ import com.pig4cloud.pig.admin.api.entity.*; import com.pig4cloud.pig.admin.api.util.ParamResolver; import com.pig4cloud.pig.admin.api.vo.UserExcelVO; import com.pig4cloud.pig.admin.api.vo.UserVO; -import com.pig4cloud.pig.admin.mapper.*; -import com.pig4cloud.pig.admin.service.AppService; -import com.pig4cloud.pig.admin.service.SysMenuService; -import com.pig4cloud.pig.admin.service.SysUserService; +import com.pig4cloud.pig.admin.mapper.SysUserMapper; +import com.pig4cloud.pig.admin.mapper.SysUserPostMapper; +import com.pig4cloud.pig.admin.mapper.SysUserRoleMapper; +import com.pig4cloud.pig.admin.service.*; import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CommonConstants; -import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum; import com.pig4cloud.pig.common.core.exception.ErrorCodes; import com.pig4cloud.pig.common.core.util.MsgUtils; import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.security.util.SecurityUtils; import com.pig4cloud.plugin.excel.vo.ErrorMessage; -import lombok.RequiredArgsConstructor; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CacheEvict; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; import org.springframework.validation.BindingResult; import java.time.LocalDateTime; @@ -57,29 +62,29 @@ import java.util.stream.Collectors; /** * @author lengleng - * @date 2019/2/1 + * @date 2017/10/31 */ @Slf4j @Service -@RequiredArgsConstructor +@AllArgsConstructor public class SysUserServiceImpl extends ServiceImpl implements SysUserService { private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder(); - private final AppService appService; - - private final SysRoleMapper sysRoleMapper; - - private final SysDeptMapper sysDeptMapper; - private final SysMenuService sysMenuService; - private final SysPostMapper sysPostMapper; + private final SysRoleService sysRoleService; + + private final SysPostService sysPostService; + + private final SysDeptService sysDeptService; private final SysUserRoleMapper sysUserRoleMapper; private final SysUserPostMapper sysUserPostMapper; + private final CacheManager cacheManager; + /** * 保存用户信息 * @param userDto DTO 对象 @@ -93,12 +98,6 @@ public class SysUserServiceImpl extends ServiceImpl impl sysUser.setDelFlag(CommonConstants.STATUS_NORMAL); sysUser.setPassword(ENCODER.encode(userDto.getPassword())); baseMapper.insert(sysUser); - userDto.getRole().stream().map(roleId -> { - SysUserRole userRole = new SysUserRole(); - userRole.setUserId(sysUser.getUserId()); - userRole.setRoleId(roleId); - return userRole; - }).forEach(sysUserRoleMapper::insert); // 保存用户岗位信息 Optional.ofNullable(userDto.getPost()).ifPresent(posts -> { posts.stream().map(postId -> { @@ -108,6 +107,24 @@ public class SysUserServiceImpl extends ServiceImpl impl return userPost; }).forEach(sysUserPostMapper::insert); }); + + // 如果角色为空,赋默认角色 + if (CollUtil.isEmpty(userDto.getRole())) { + // 获取默认角色编码 + String defaultRole = ParamResolver.getStr("USER_DEFAULT_ROLE"); + // 默认角色 + SysRole sysRole = sysRoleService + .getOne(Wrappers.lambdaQuery().eq(SysRole::getRoleCode, defaultRole)); + userDto.setRole(Collections.singletonList(sysRole.getRoleId())); + } + + // 插入用户角色关系表 + userDto.getRole().stream().map(roleId -> { + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(sysUser.getUserId()); + userRole.setRoleId(roleId); + return userRole; + }).forEach(sysUserRoleMapper::insert); return Boolean.TRUE; } @@ -117,28 +134,27 @@ public class SysUserServiceImpl extends ServiceImpl impl * @return */ @Override - public UserInfo getUserInfo(SysUser sysUser) { + public UserInfo findUserInfo(SysUser sysUser) { UserInfo userInfo = new UserInfo(); userInfo.setSysUser(sysUser); - // 设置角色列表 - List roleList = sysRoleMapper.listRolesByUserId(sysUser.getUserId()); - userInfo.setRoleList(roleList); // 设置角色列表 (ID) - List roleIds = roleList.stream().map(SysRole::getRoleId).collect(Collectors.toList()); + List roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId()) + .stream() + .map(SysRole::getRoleId) + .collect(Collectors.toList()); userInfo.setRoles(ArrayUtil.toArray(roleIds, Long.class)); - // 设置岗位列表 - List postList = sysPostMapper.listPostsByUserId(sysUser.getUserId()); - userInfo.setPostList(postList); - // 设置权限列表(menu.permission) - Set permissions = roleIds.stream() - .map(sysMenuService::findMenuByRoleId) - .flatMap(Collection::stream) - .filter(m -> MenuTypeEnum.BUTTON.getType().equals(m.getType())) - .map(SysMenu::getPermission) - .filter(StrUtil::isNotBlank) - .collect(Collectors.toSet()); - userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class)); + // 设置权限列表(menu.permission) + Set permissions = new HashSet<>(); + roleIds.forEach(roleId -> { + List permissionList = sysMenuService.findMenuByRoleId(roleId) + .stream() + .filter(menu -> StrUtil.isNotEmpty(menu.getPermission())) + .map(SysMenu::getPermission) + .collect(Collectors.toList()); + permissions.addAll(permissionList); + }); + userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class)); return userInfo; } @@ -149,7 +165,7 @@ public class SysUserServiceImpl extends ServiceImpl impl * @return */ @Override - public IPage getUserWithRolePage(Page page, UserDTO userDTO) { + public IPage getUsersWithRolePage(Page page, UserDTO userDTO) { return baseMapper.getUserVosPage(page, userDTO); } @@ -159,22 +175,27 @@ public class SysUserServiceImpl extends ServiceImpl impl * @return 用户信息 */ @Override - public UserVO getUserVoById(Long id) { + public UserVO selectUserVoById(Long id) { return baseMapper.getUserVoById(id); } /** * 删除用户 - * @param sysUser 用户 + * @param ids 用户ID 列表 * @return Boolean */ @Override - @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#sysUser.username") - public Boolean removeUserById(SysUser sysUser) { - sysUserRoleMapper.deleteByUserId(sysUser.getUserId()); - // 删除用户职位关系 - sysUserPostMapper.delete(Wrappers.lambdaQuery().eq(SysUserPost::getUserId, sysUser.getUserId())); - this.removeById(sysUser.getUserId()); + @Transactional(rollbackFor = Exception.class) + public Boolean deleteUserByIds(Long[] ids) { + // 删除 spring cache + List userList = baseMapper.selectBatchIds(CollUtil.toList(ids)); + Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS); + for (SysUser sysUser : userList) { + cache.evict(sysUser.getUsername()); + } + + sysUserRoleMapper.delete(Wrappers.lambdaQuery().in(SysUserRole::getUserId, CollUtil.toList(ids))); + this.removeBatchByIds(CollUtil.toList(ids)); return Boolean.TRUE; } @@ -183,73 +204,47 @@ public class SysUserServiceImpl extends ServiceImpl impl public R updateUserInfo(UserDTO userDto) { UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername()); - // 判断手机号是否修改,更新手机号校验验证码 - if (!StrUtil.equals(userVO.getPhone(), userDto.getPhone())) { - if (!appService.check(userDto.getPhone(), userDto.getCode())) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_APP_SMS_ERROR)); - } - } - - // 修改密码逻辑 SysUser sysUser = new SysUser(); - if (StrUtil.isNotBlank(userDto.getNewpassword1())) { - Assert.isTrue(ENCODER.matches(userDto.getPassword(), userVO.getPassword()), - MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR)); - sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1())); - } sysUser.setPhone(userDto.getPhone()); sysUser.setUserId(userVO.getUserId()); sysUser.setAvatar(userDto.getAvatar()); + sysUser.setNickname(userDto.getNickname()); + sysUser.setName(userDto.getName()); + sysUser.setEmail(userDto.getEmail()); return R.ok(this.updateById(sysUser)); } @Override @Transactional(rollbackFor = Exception.class) @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username") - public R updateUser(UserDTO userDto) { + public Boolean updateUser(UserDTO userDto) { + // 更新用户表信息 SysUser sysUser = new SysUser(); BeanUtils.copyProperties(userDto, sysUser); sysUser.setUpdateTime(LocalDateTime.now()); - if (StrUtil.isNotBlank(userDto.getPassword())) { sysUser.setPassword(ENCODER.encode(userDto.getPassword())); } this.updateById(sysUser); - sysUserRoleMapper - .delete(Wrappers.update().lambda().eq(SysUserRole::getUserId, userDto.getUserId())); - userDto.getRole().forEach(roleId -> { + // 更新用户角色表 + sysUserRoleMapper.delete(Wrappers.lambdaQuery().eq(SysUserRole::getUserId, userDto.getUserId())); + userDto.getRole().stream().map(roleId -> { SysUserRole userRole = new SysUserRole(); userRole.setUserId(sysUser.getUserId()); userRole.setRoleId(roleId); - userRole.insert(); - }); + return userRole; + }).forEach(SysUserRole::insert); + + // 更新用户岗位表 sysUserPostMapper.delete(Wrappers.lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId())); - userDto.getPost().forEach(postId -> { + userDto.getPost().stream().map(postId -> { SysUserPost userPost = new SysUserPost(); userPost.setUserId(sysUser.getUserId()); userPost.setPostId(postId); - userPost.insert(); - }); - return R.ok(); - } - - /** - * 查询上级部门的用户信息 - * @param username 用户名 - * @return R - */ - @Override - public List listAncestorUsersByUsername(String username) { - SysUser sysUser = this.getOne(Wrappers.query().lambda().eq(SysUser::getUsername, username)); - - SysDept sysDept = sysDeptMapper.selectById(sysUser.getDeptId()); - if (sysDept == null) { - return null; - } - - Long parentId = sysDept.getParentId(); - return this.list(Wrappers.query().lambda().eq(SysUser::getDeptId, parentId)); + return userPost; + }).forEach(SysUserPost::insert); + return Boolean.TRUE; } /** @@ -259,6 +254,7 @@ public class SysUserServiceImpl extends ServiceImpl impl */ @Override public List listUser(UserDTO userDTO) { + // 根据数据权限查询全部的用户信息 List voList = baseMapper.selectVoList(userDTO); // 转换成execl 对象输出 List userExcelVOList = voList.stream().map(userVO -> { @@ -289,15 +285,15 @@ public class SysUserServiceImpl extends ServiceImpl impl public R importUser(List excelVOList, BindingResult bindingResult) { // 通用校验获取失败的数据 List errorMessageList = (List) bindingResult.getTarget(); - - // 个性化校验逻辑 - List userList = this.list(); - List deptList = sysDeptMapper.selectList(Wrappers.emptyWrapper()); - List roleList = sysRoleMapper.selectList(Wrappers.emptyWrapper()); - List postList = sysPostMapper.selectList(Wrappers.emptyWrapper()); + List deptList = sysDeptService.list(); + List roleList = sysRoleService.list(); + List postList = sysPostService.list(); // 执行数据插入操作 组装 UserDto for (UserExcelVO excel : excelVOList) { + // 个性化校验逻辑 + List userList = this.list(); + Set errorMsg = new HashSet<>(); // 校验用户名是否存在 boolean exsitUserName = userList.stream() @@ -325,7 +321,7 @@ public class SysUserServiceImpl extends ServiceImpl impl errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList())); } - // 判断输入的岗位名称列表是否合法 + // 判断输入的部门名称列表是否合法 List postNameList = StrUtil.split(excel.getPostNameList(), StrUtil.COMMA); List postCollList = postList.stream() .filter(post -> postNameList.stream().anyMatch(name -> post.getPostName().equals(name))) @@ -352,13 +348,6 @@ public class SysUserServiceImpl extends ServiceImpl impl return R.ok(); } - @Override - public List listUserIdByDeptIds(Set deptIds) { - return this.listObjs( - Wrappers.lambdaQuery(SysUser.class).select(SysUser::getUserId).in(SysUser::getDeptId, deptIds), - Long.class::cast); - } - /** * 插入excel User */ @@ -367,15 +356,19 @@ public class SysUserServiceImpl extends ServiceImpl impl UserDTO userDTO = new UserDTO(); userDTO.setUsername(excel.getUsername()); userDTO.setPhone(excel.getPhone()); + userDTO.setNickname(excel.getNickname()); + userDTO.setName(excel.getName()); + userDTO.setEmail(excel.getEmail()); // 批量导入初始密码为手机号 userDTO.setPassword(userDTO.getPhone()); // 根据部门名称查询部门ID userDTO.setDeptId(deptOptional.get().getDeptId()); + // 插入岗位名称 + List postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList()); + userDTO.setPost(postIdList); // 根据角色名称查询角色ID List roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList()); userDTO.setRole(roleIdList); - List postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList()); - userDTO.setPost(postIdList); // 插入用户 this.saveUser(userDTO); } @@ -387,29 +380,74 @@ public class SysUserServiceImpl extends ServiceImpl impl */ @Override public R registerUser(UserDTO userDto) { - // 校验验证码 - if (!appService.check(userDto.getPhone(), userDto.getCode())) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_APP_SMS_ERROR)); - } - // 判断用户名是否存在 SysUser sysUser = this.getOne(Wrappers.lambdaQuery().eq(SysUser::getUsername, userDto.getUsername())); if (sysUser != null) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, userDto.getUsername())); + String message = MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, userDto.getUsername()); + return R.failed(message); } - - // 获取默认角色编码 - String defaultRole = ParamResolver.getStr("USER_DEFAULT_ROLE"); - // 默认角色 - SysRole sysRole = sysRoleMapper - .selectOne(Wrappers.lambdaQuery().eq(SysRole::getRoleCode, defaultRole)); - - if (sysRole == null) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_PARAM_CONFIG_ERROR, "USER_DEFAULT_ROLE")); - } - - userDto.setRole(Collections.singletonList(sysRole.getRoleId())); return R.ok(saveUser(userDto)); } + /** + * 锁定用户 + * @param username 用户名 + * @return + */ + @Override + @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#username") + public R lockUser(String username) { + SysUser sysUser = baseMapper.selectOne(Wrappers.lambdaQuery().eq(SysUser::getUsername, username)); + + if (Objects.nonNull(sysUser)) { + sysUser.setLockFlag(CommonConstants.STATUS_LOCK); + baseMapper.updateById(sysUser); + } + return R.ok(); + } + + @Override + @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username") + public R changePassword(UserDTO userDto) { + UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername()); + if (Objects.isNull(userVO)) { + return R.failed("用户不存在"); + } + + if (StrUtil.isEmpty(userDto.getPassword())) { + return R.failed("原密码不能为空"); + } + + if (!ENCODER.matches(userDto.getPassword(), userVO.getPassword())) { + log.info("原密码错误,修改个人信息失败:{}", userDto.getUsername()); + return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR)); + } + + if (StrUtil.isEmpty(userDto.getNewpassword1())) { + return R.failed("新密码不能为空"); + } + String password = ENCODER.encode(userDto.getNewpassword1()); + + this.update(Wrappers.lambdaUpdate() + .set(SysUser::getPassword, password) + .eq(SysUser::getUserId, userVO.getUserId())); + return R.ok(); + } + + @Override + public R checkPassword(String password) { + String username = SecurityUtils.getUser().getUsername(); + SysUser condition = new SysUser(); + condition.setUsername(username); + SysUser sysUser = this.getOne(new QueryWrapper<>(condition)); + + if (!ENCODER.matches(password, sysUser.getPassword())) { + log.info("原密码错误"); + return R.failed("密码输入错误"); + } + else { + return R.ok(); + } + } + } diff --git a/pig-upms/pig-upms-biz/src/main/resources/file/approle.xlsx b/pig-upms/pig-upms-biz/src/main/resources/file/approle.xlsx new file mode 100644 index 00000000..0c986e8b Binary files /dev/null and b/pig-upms/pig-upms-biz/src/main/resources/file/approle.xlsx differ diff --git a/pig-upms/pig-upms-biz/src/main/resources/file/dept.xlsx b/pig-upms/pig-upms-biz/src/main/resources/file/dept.xlsx new file mode 100644 index 00000000..69439e53 Binary files /dev/null and b/pig-upms/pig-upms-biz/src/main/resources/file/dept.xlsx differ diff --git a/pig-upms/pig-upms-biz/src/main/resources/file/user.xlsx b/pig-upms/pig-upms-biz/src/main/resources/file/user.xlsx index b67ee8ff..bb557ba5 100644 Binary files a/pig-upms/pig-upms-biz/src/main/resources/file/user.xlsx and b/pig-upms/pig-upms-biz/src/main/resources/file/user.xlsx differ diff --git a/pig-upms/pig-upms-biz/src/main/resources/logback-spring.xml b/pig-upms/pig-upms-biz/src/main/resources/logback-spring.xml old mode 100755 new mode 100644 index 58a4eacd..bacd3f9c --- a/pig-upms/pig-upms-biz/src/main/resources/logback-spring.xml +++ b/pig-upms/pig-upms-biz/src/main/resources/logback-spring.xml @@ -1,23 +1,14 @@ - + 小技巧: 在根pom里面设置统一存放路径,统一管理方便维护 + + /Users/lengleng + + 1. 其他模块加日志输出,直接copy本文件放在resources 目录即可 + 2. 注意修改 的value模块 +--> - - + @@ -69,7 +60,7 @@ - + diff --git a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysDeptMapper.xml b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysDeptMapper.xml index 69fd6f98..25dcf129 100644 --- a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysDeptMapper.xml +++ b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysDeptMapper.xml @@ -1,48 +1,23 @@ - - - - - - - - - - - - - - - diff --git a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysDeptRelationMapper.xml b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysDeptRelationMapper.xml deleted file mode 100644 index 5f5ddcb9..00000000 --- a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysDeptRelationMapper.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - DELETE - FROM sys_dept_relation - WHERE descendant IN (SELECT temp.descendant - FROM (SELECT descendant FROM sys_dept_relation WHERE ancestor = #{descendant}) temp) - AND ancestor IN (SELECT temp.ancestor - FROM (SELECT ancestor - FROM sys_dept_relation - WHERE descendant = #{descendant} - AND ancestor != descendant) temp) - - - - - DELETE - FROM sys_dept_relation - WHERE descendant IN ( - SELECT temp.descendant - FROM ( - SELECT descendant - FROM sys_dept_relation - WHERE ancestor = #{id} - ) temp - ) - - - - - INSERT INTO sys_dept_relation (ancestor, descendant) - SELECT a.ancestor, b.descendant - FROM sys_dept_relation a - CROSS JOIN sys_dept_relation b - WHERE a.descendant = #{ancestor} - AND b.ancestor = #{descendant} - - diff --git a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysMenuMapper.xml b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysMenuMapper.xml index 202a6ede..57198f75 100644 --- a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysMenuMapper.xml +++ b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysMenuMapper.xml @@ -1,18 +1,21 @@ @@ -21,40 +24,53 @@ + - + - + - + + + + + diff --git a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysPostMapper.xml b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysPostMapper.xml index bbcb22fc..eaf29278 100644 --- a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysPostMapper.xml +++ b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysPostMapper.xml @@ -1,5 +1,4 @@ - @@ -26,27 +29,21 @@ - - - - diff --git a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysUserMapper.xml b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysUserMapper.xml index ef261cbc..2b3ed9f7 100644 --- a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysUserMapper.xml +++ b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysUserMapper.xml @@ -1,179 +1,203 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + u.user_id, + u.username, + u.password, + u.salt, + u.phone, + u.avatar, + u.wx_openid, + u.qq_openid, + u.dept_id, + u.del_flag, + u.lock_flag, + u.tenant_id, + u.create_by, + u.create_time ucreate_time, + u.update_time uupdate_time, + r.role_id, + r.role_name, + r.role_code, + r.role_desc, + r.create_time rcreate_time, + r.update_time rupdate_time + - - sys_user.user_id, - sys_user.username, - sys_user.`password`, - sys_user.salt, - sys_user.phone, - sys_user.avatar, - sys_user.dept_id, - sys_user.create_time AS ucreate_time, - sys_user.update_time AS uupdate_time, - sys_user.del_flag AS udel_flag, - sys_user.lock_flag AS lock_flag, - sys_user.dept_id AS deptId, - r.role_id, - r.role_name, - r.role_code, - r.role_desc, - r.create_time AS rcreate_time, - r.update_time AS rupdate_time - + + u.user_id, + u.username, + u.password, + u.salt, + u.phone, + u.avatar, + u.wx_openid, + u.qq_openid, + u.gitee_login, + u.osc_id, + u.del_flag, + u.lock_flag, + u.tenant_id, + u.nickname, + u.name, + u.email, + u.create_by, + u.create_time ucreate_time, + u.update_time uupdate_time, + d.name dept_name, + d.dept_id + - - sys_user.user_id, - sys_user.username, - sys_user.`password`, - sys_user.salt, - sys_user.phone, - sys_user.avatar, - sys_user.create_time AS ucreate_time, - sys_user.update_time AS uupdate_time, - sys_user.del_flag AS udel_flag, - sys_user.lock_flag AS lock_flag, - r.role_id, - r.role_name, - r.role_code, - r.role_desc, - r.create_time AS rcreate_time, - r.update_time AS rupdate_time, - d.name AS deptName, - d.dept_id AS deptId - + - + - + - SELECT sys_user.user_id, - sys_user.username, - sys_user.salt, - sys_user.phone, - sys_user.avatar, - sys_user.dept_id, - sys_user.create_time AS ucreate_time, - sys_user.update_time AS uupdate_time, - sys_user.del_flag AS udel_flag, - sys_user.lock_flag AS lock_flag, - sys_user.dept_id AS deptId, - sys_dept.name AS deptName - FROM sys_user - LEFT JOIN sys_dept ON sys_dept.dept_id = sys_user.dept_id - - sys_user.del_flag = '0' - - - and sys_user.username LIKE #{usernameLike} - - - ORDER BY sys_user.create_time DESC - + + ORDER BY u.create_time DESC + + - + diff --git a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysUserRoleMapper.xml b/pig-upms/pig-upms-biz/src/main/resources/mapper/SysUserRoleMapper.xml deleted file mode 100644 index de2a62a7..00000000 --- a/pig-upms/pig-upms-biz/src/main/resources/mapper/SysUserRoleMapper.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - DELETE FROM sys_user_role WHERE user_id = #{userId} - - - diff --git a/pig-upms/pom.xml b/pig-upms/pom.xml index a5994580..6315445f 100755 --- a/pig-upms/pom.xml +++ b/pig-upms/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.6.4 + 3.7.0-SNAPSHOT pig-upms diff --git a/pig-visual/pig-codegen/pom.xml b/pig-visual/pig-codegen/pom.xml index d5cadd48..fedc023e 100755 --- a/pig-visual/pig-codegen/pom.xml +++ b/pig-visual/pig-codegen/pom.xml @@ -22,7 +22,7 @@ com.pig4cloud pig-visual - 3.6.4 + 3.7.0-SNAPSHOT pig-codegen @@ -65,6 +65,10 @@ mysql-connector-j + + cn.hutool + hutool-json + com.pig4cloud pig-common-core @@ -95,6 +99,12 @@ velocity-tools-generic ${velocity.tool.version} + + + io.springboot.plugin + screw-spring-boot-starter + ${screw.version} + org.springframework.boot diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java index 2fbdc72f..9fb7b06e 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen; @@ -25,13 +26,13 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; /** * @author lengleng - * @date 2020/03/11 代码生成模块 + * @date 2018/07/29 代码生成模块 */ @EnableDynamicDataSource @EnablePigFeignClients @EnableDiscoveryClient -@SpringBootApplication @EnablePigResourceServer +@SpringBootApplication public class PigCodeGenApplication { public static void main(String[] args) { diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java index 60bd7ae9..2b4d7398 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java @@ -1,34 +1,42 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.controller; -import com.baomidou.mybatisplus.core.metadata.IPage; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.ContentType; +import cn.smallbun.screw.boot.config.Screw; +import cn.smallbun.screw.boot.properties.ScrewProperties; +import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pig.codegen.entity.GenDatasourceConf; import com.pig4cloud.pig.codegen.service.GenDatasourceConfService; import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; +import com.pig4cloud.pig.common.core.util.SpringContextHolder; +import com.pig4cloud.pig.common.security.annotation.Inner; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.*; -import java.util.List; +import javax.sql.DataSource; /** * 数据源管理 @@ -39,12 +47,12 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/dsconf") -@Tag(name = "数据源管理模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class GenDsConfController { private final GenDatasourceConfService datasourceConfService; + private final Screw screw; + /** * 分页查询 * @param page 分页对象 @@ -52,8 +60,11 @@ public class GenDsConfController { * @return */ @GetMapping("/page") - public R> getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) { - return R.ok(datasourceConfService.page(page, Wrappers.query(datasourceConf))); + public R getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) { + return R.ok(datasourceConfService.page(page, + Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(datasourceConf.getDsName()), GenDatasourceConf::getDsName, + datasourceConf.getDsName()))); } /** @@ -61,7 +72,8 @@ public class GenDsConfController { * @return */ @GetMapping("/list") - public R> list() { + @Inner(value = false) + public R list() { return R.ok(datasourceConfService.list()); } @@ -71,7 +83,7 @@ public class GenDsConfController { * @return R */ @GetMapping("/{id}") - public R getById(@PathVariable("id") Long id) { + public R getById(@PathVariable("id") Long id) { return R.ok(datasourceConfService.getById(id)); } @@ -80,9 +92,8 @@ public class GenDsConfController { * @param datasourceConf 数据源表 * @return R */ - @SysLog("新增数据源表") @PostMapping - public R save(@RequestBody GenDatasourceConf datasourceConf) { + public R save(@RequestBody GenDatasourceConf datasourceConf) { return R.ok(datasourceConfService.saveDsByEnc(datasourceConf)); } @@ -91,21 +102,42 @@ public class GenDsConfController { * @param conf 数据源表 * @return R */ - @SysLog("修改数据源表") @PutMapping - public R updateById(@RequestBody GenDatasourceConf conf) { + public R updateById(@RequestBody GenDatasourceConf conf) { return R.ok(datasourceConfService.updateDsByEnc(conf)); } /** * 通过id删除数据源表 - * @param id id + * @param ids id * @return R */ - @SysLog("删除数据源表") - @DeleteMapping("/{id}") - public R removeById(@PathVariable Long id) { - return R.ok(datasourceConfService.removeByDsId(id)); + @DeleteMapping + public R removeById(@RequestBody Long[] ids) { + return R.ok(datasourceConfService.removeByDsId(ids)); + } + + /** + * 查询数据源对应的文档 + * @param dsName 数据源名称 + */ + @SneakyThrows + @GetMapping("/doc") + public void generatorDoc(String dsName, HttpServletResponse response) { + // 设置指定的数据源 + DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class); + DynamicDataSourceContextHolder.push(dsName); + DataSource dataSource = dynamicRoutingDataSource.determineDataSource(); + + // 设置指定的目标表 + ScrewProperties screwProperties = SpringContextHolder.getBean(ScrewProperties.class); + + // 生成 + byte[] data = screw.documentGeneration(dataSource, screwProperties).toByteArray(); + response.reset(); + response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length)); + response.setContentType(ContentType.OCTET_STREAM.getValue()); + IoUtil.write(response.getOutputStream(), Boolean.TRUE, data); } } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFieldTypeController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFieldTypeController.java new file mode 100644 index 00000000..e0b8e8e7 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFieldTypeController.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.controller; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.codegen.entity.GenFieldType; +import com.pig4cloud.pig.codegen.service.GenFieldTypeService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:16:01 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/fieldtype") +@Tag(description = "fieldtype", name = "列属性管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class GenFieldTypeController { + + private final GenFieldTypeService fieldTypeService; + + /** + * 分页查询 + * @param page 分页对象 + * @param fieldType 列属性 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + public R getFieldTypePage(Page page, GenFieldType fieldType) { + return R.ok(fieldTypeService.page(page, + Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(fieldType.getColumnType()), GenFieldType::getColumnType, + fieldType.getColumnType()))); + } + + @Operation(summary = "查询列表", description = "查询列表") + @GetMapping("/list") + public R list(GenFieldType fieldType) { + return R.ok(fieldTypeService.list(Wrappers.query(fieldType))); + } + + /** + * 通过id查询列属性 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/details/{id}") + public R getById(@PathVariable("id") Long id) { + return R.ok(fieldTypeService.getById(id)); + } + + @GetMapping("/details") + public R getDetails(GenFieldType query) { + return R.ok(fieldTypeService.getOne(Wrappers.query(query), false)); + } + + /** + * 新增列属性 + * @param fieldType 列属性 + * @return R + */ + @Operation(summary = "新增列属性", description = "新增列属性") + @SysLog("新增列属性") + @PostMapping + public R save(@RequestBody GenFieldType fieldType) { + return R.ok(fieldTypeService.save(fieldType)); + } + + /** + * 修改列属性 + * @param fieldType 列属性 + * @return R + */ + @Operation(summary = "修改列属性", description = "修改列属性") + @SysLog("修改列属性") + @PutMapping + public R updateById(@RequestBody GenFieldType fieldType) { + return R.ok(fieldTypeService.updateById(fieldType)); + } + + /** + * 通过id删除列属性 + * @param ids id + * @return R + */ + @Operation(summary = "通过id删除列属性", description = "通过id删除列属性") + @SysLog("通过id删除列属性") + @DeleteMapping + public R removeById(@RequestBody Long[] ids) { + return R.ok(fieldTypeService.removeBatchByIds(CollUtil.toList(ids))); + } + + /** + * 导出excel 表格 + * @param fieldType 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + public List export(GenFieldType fieldType) { + return fieldTypeService.list(Wrappers.query(fieldType)); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java deleted file mode 100755 index 23c01a28..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.codegen.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.codegen.entity.GenFormConf; -import com.pig4cloud.pig.codegen.service.GenFormConfService; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -/** - * 表单管理 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/form") -@Tag(name = "表单管理") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class GenFormConfController { - - private final GenFormConfService genRecordService; - - /** - * 分页查询 - * @param page 分页对象 - * @param formConf 生成记录 - * @return - */ - @Operation(summary = "分页查询", description = "分页查询") - @GetMapping("/page") - public R> getGenFormConfPage(Page page, GenFormConf formConf) { - return R.ok(genRecordService.page(page, Wrappers.query(formConf))); - } - - /** - * 通过id查询生成记录 - * @param id id - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/{id}") - public R getById(@PathVariable("id") Integer id) { - return R.ok(genRecordService.getById(id)); - } - - /** - * 通过id查询生成记录 - * @param dsName 数据源ID - * @param tableName tableName - * @return R - */ - @Operation(summary = "通过tableName查询表单信息") - @GetMapping("/info") - public R form(String dsName, String tableName) { - return R.ok(genRecordService.getForm(dsName, tableName)); - } - - /** - * 新增生成记录 - * @param formConf 生成记录 - * @return R - */ - @Operation(summary = "新增生成记录", description = "新增生成记录") - @SysLog("新增生成记录") - @PostMapping - @PreAuthorize("@pms.hasPermission('gen_form_add')") - public R save(@RequestBody GenFormConf formConf) { - return R.ok(genRecordService.save(formConf)); - } - - /** - * 通过id删除生成记录 - * @param id id - * @return R - */ - @Operation(summary = "通过id删除生成记录", description = "通过id删除生成记录") - @SysLog("通过id删除生成记录") - @DeleteMapping("/{id}") - @PreAuthorize("@pms.hasPermission('gen_form_del')") - public R removeById(@PathVariable Long id) { - return R.ok(genRecordService.removeById(id)); - } - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenGroupController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenGroupController.java new file mode 100644 index 00000000..c603101f --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenGroupController.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.controller; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.codegen.entity.GenGroupEntity; +import com.pig4cloud.pig.codegen.service.GenGroupService; +import com.pig4cloud.pig.codegen.util.vo.GroupVo; +import com.pig4cloud.pig.codegen.util.vo.TemplateGroupDTO; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 模板分组 + * + * @author PIG + * @date 2023-02-21 20:01:53 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/group") +@Tag(description = "group", name = "模板分组管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class GenGroupController { + + private final GenGroupService genGroupService; + + /** + * 分页查询 + * @param page 分页对象 + * @param genGroup 模板分组 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + @PreAuthorize("@pms.hasPermission('codegen_group_view')") + public R getgenGroupPage(Page page, GenGroupEntity genGroup) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .like(genGroup.getId() != null, GenGroupEntity::getId, genGroup.getId()) + .like(StrUtil.isNotEmpty(genGroup.getGroupName()), GenGroupEntity::getGroupName, genGroup.getGroupName()); + return R.ok(genGroupService.page(page, wrapper)); + } + + /** + * 通过id查询模板分组 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{id}") + @PreAuthorize("@pms.hasPermission('codegen_group_view')") + public R getById(@PathVariable("id") Long id) { + return R.ok(genGroupService.getGroupVoById(id)); + } + + /** + * 新增模板分组 + * @param genTemplateGroup 模板分组 + * @return R + */ + @Operation(summary = "新增模板分组", description = "新增模板分组") + @SysLog("新增模板分组") + @PostMapping + @PreAuthorize("@pms.hasPermission('codegen_group_add')") + public R save(@RequestBody TemplateGroupDTO genTemplateGroup) { + genGroupService.saveGenGroup(genTemplateGroup); + return R.ok(); + } + + /** + * 修改模板分组 + * @param groupVo 模板分组 + * @return R + */ + @Operation(summary = "修改模板分组", description = "修改模板分组") + @SysLog("修改模板分组") + @PutMapping + @PreAuthorize("@pms.hasPermission('codegen_group_edit')") + public R updateById(@RequestBody GroupVo groupVo) { + genGroupService.updateGroupAndTemplateById(groupVo); + return R.ok(); + } + + /** + * 通过id删除模板分组 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除模板分组", description = "通过id删除模板分组") + @SysLog("通过id删除模板分组") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('codegen_group_del')") + public R removeById(@RequestBody Long[] ids) { + genGroupService.delGroupAndTemplate(ids); + return R.ok(); + } + + /** + * 导出excel 表格 + * @param genGroup 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('codegen_group_export')") + public List export(GenGroupEntity genGroup) { + return genGroupService.list(Wrappers.query(genGroup)); + } + + @GetMapping("/list") + @Operation(summary = "查询列表", description = "查询列表") + public R list() { + List list = genGroupService.list(); + return R.ok(list); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTableController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTableController.java new file mode 100644 index 00000000..4ee48193 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTableController.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.codegen.entity.GenTable; +import com.pig4cloud.pig.codegen.entity.GenTableColumnEntity; +import com.pig4cloud.pig.codegen.service.GenTableColumnService; +import com.pig4cloud.pig.codegen.service.GenTableService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:34:55 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/table") +@Tag(description = "table", name = "列属性管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class GenTableController { + + private final GenTableColumnService tableColumnService; + + private final GenTableService tableService; + + /** + * 分页查询 + * @param page 分页对象 + * @param table 列属性 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + public R getTablePage(Page page, GenTable table) { + + return R.ok(tableService.list(page, table)); + } + + /** + * 通过id查询列属性 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{id}") + public R getById(@PathVariable("id") Long id) { + return R.ok(tableService.getById(id)); + } + + /** + * 新增列属性 + * @param table 列属性 + * @return R + */ + @Operation(summary = "新增列属性", description = "新增列属性") + @SysLog("新增列属性") + @PostMapping + public R save(@RequestBody GenTable table) { + return R.ok(tableService.save(table)); + } + + /** + * 修改列属性 + * @param table 列属性 + * @return R + */ + @Operation(summary = "修改列属性", description = "修改列属性") + @SysLog("修改列属性") + @PutMapping + public R updateById(@RequestBody GenTable table) { + return R.ok(tableService.updateById(table)); + } + + /** + * 通过id删除列属性 + * @param id id + * @return R + */ + @Operation(summary = "通过id删除列属性", description = "通过id删除列属性") + @SysLog("通过id删除列属性") + @DeleteMapping("/{id}") + public R removeById(@PathVariable Long id) { + return R.ok(tableService.removeById(id)); + } + + /** + * 导出excel 表格 + * @param table 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + public List export(GenTable table) { + return tableService.list(Wrappers.query(table)); + } + + @GetMapping("/list/{dsName}") + public R listTable(@PathVariable("dsName") String dsName) { + return R.ok(tableService.queryDsAllTable(dsName)); + } + + @GetMapping("/column/{dsName}/{tableName}") + public R column(@PathVariable("dsName") String dsName, @PathVariable String tableName) { + return R.ok(tableService.queryColumn(dsName, tableName)); + } + + /** + * 获取表信息 + * @param dsName 数据源 + * @param tableName 表名称 + */ + @GetMapping("/{dsName}/{tableName}") + public R info(@PathVariable("dsName") String dsName, @PathVariable String tableName) { + return R.ok(tableService.queryOrBuildTable(dsName, tableName)); + } + + /** + * 同步表信息 + * @param dsName 数据源 + * @param tableName 表名称 + */ + @GetMapping("/sync/{dsName}/{tableName}") + public R sync(@PathVariable("dsName") String dsName, @PathVariable String tableName) { + // 表配置删除 + tableService.remove( + Wrappers.lambdaQuery().eq(GenTable::getDsName, dsName).eq(GenTable::getTableName, tableName)); + // 字段配置删除 + tableColumnService.remove(Wrappers.lambdaQuery() + .eq(GenTableColumnEntity::getDsName, dsName) + .eq(GenTableColumnEntity::getTableName, tableName)); + return R.ok(tableService.queryOrBuildTable(dsName, tableName)); + } + + /** + * 修改表字段数据 + * @param dsName 数据源 + * @param tableName 表名称 + * @param tableFieldList 字段列表 + */ + @PutMapping("/field/{dsName}/{tableName}") + public R updateTableField(@PathVariable("dsName") String dsName, @PathVariable String tableName, + @RequestBody List tableFieldList) { + tableColumnService.updateTableField(dsName, tableName, tableFieldList); + return R.ok(); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTemplateController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTemplateController.java new file mode 100644 index 00000000..4b122c5f --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTemplateController.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.controller; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.codegen.entity.GenTemplateEntity; +import com.pig4cloud.pig.codegen.service.GenTemplateService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 模板 + * + * @author PIG + * @date 2023-02-21 17:15:44 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/template") +@Tag(description = "template", name = "模板管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class GenTemplateController { + + private final GenTemplateService genTemplateService; + + /** + * 分页查询 + * @param page 分页对象 + * @param genTemplate 模板 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + @PreAuthorize("@pms.hasPermission('codegen_template_view')") + public R getgenTemplatePage(Page page, GenTemplateEntity genTemplate) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .like(genTemplate.getId() != null, GenTemplateEntity::getId, genTemplate.getId()) + .like(StrUtil.isNotEmpty(genTemplate.getTemplateName()), GenTemplateEntity::getTemplateName, + genTemplate.getTemplateName()); + return R.ok(genTemplateService.page(page, wrapper)); + } + + /** + * 查询全部模板 + * @return + */ + @Operation(summary = "查询全部", description = "查询全部") + @GetMapping("/list") + @PreAuthorize("@pms.hasPermission('codegen_template_view')") + public R list() { + return R.ok(genTemplateService.list(Wrappers.emptyWrapper())); + } + + /** + * 通过id查询模板 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{id}") + @PreAuthorize("@pms.hasPermission('codegen_template_view')") + public R getById(@PathVariable("id") Long id) { + return R.ok(genTemplateService.getById(id)); + } + + /** + * 新增模板 + * @param genTemplate 模板 + * @return R + */ + @Operation(summary = "新增模板", description = "新增模板") + @SysLog("新增模板") + @PostMapping + @PreAuthorize("@pms.hasPermission('codegen_template_add')") + public R save(@RequestBody GenTemplateEntity genTemplate) { + return R.ok(genTemplateService.save(genTemplate)); + } + + /** + * 修改模板 + * @param genTemplate 模板 + * @return R + */ + @Operation(summary = "修改模板", description = "修改模板") + @SysLog("修改模板") + @PutMapping + @PreAuthorize("@pms.hasPermission('codegen_template_edit')") + public R updateById(@RequestBody GenTemplateEntity genTemplate) { + return R.ok(genTemplateService.updateById(genTemplate)); + } + + /** + * 通过id删除模板 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除模板", description = "通过id删除模板") + @SysLog("通过id删除模板") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('codegen_template_del')") + public R removeById(@RequestBody Long[] ids) { + return R.ok(genTemplateService.removeBatchByIds(CollUtil.toList(ids))); + } + + /** + * 导出excel 表格 + * @param genTemplate 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('codegen_template_export')") + public List export(GenTemplateEntity genTemplate) { + return genTemplateService.list(Wrappers.query(genTemplate)); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTemplateGroupController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTemplateGroupController.java new file mode 100644 index 00000000..aeba3601 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenTemplateGroupController.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.controller; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.codegen.entity.GenTemplateGroupEntity; +import com.pig4cloud.pig.codegen.service.GenTemplateGroupService; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 模板分组关联表 + * + * @author PIG + * @date 2023-02-22 09:25:15 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/templateGroup") +@Tag(description = "templateGroup", name = "模板分组关联表管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class GenTemplateGroupController { + + private final GenTemplateGroupService genTemplateGroupService; + + /** + * 分页查询 + * @param page 分页对象 + * @param genTemplateGroup 模板分组关联表 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + @PreAuthorize("@pms.hasPermission('codegen_templateGroup_view')") + public R getgenTemplateGroupPage(Page page, GenTemplateGroupEntity genTemplateGroup) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + return R.ok(genTemplateGroupService.page(page, wrapper)); + } + + /** + * 通过id查询模板分组关联表 + * @param groupId id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{groupId}") + @PreAuthorize("@pms.hasPermission('codegen_templateGroup_view')") + public R getById(@PathVariable("groupId") Long groupId) { + return R.ok(genTemplateGroupService.getById(groupId)); + } + + /** + * 新增模板分组关联表 + * @param genTemplateGroup 模板分组关联表 + * @return R + */ + @Operation(summary = "新增模板分组关联表", description = "新增模板分组关联表") + @SysLog("新增模板分组关联表") + @PostMapping + @PreAuthorize("@pms.hasPermission('codegen_templateGroup_add')") + public R save(@RequestBody GenTemplateGroupEntity genTemplateGroup) { + return R.ok(genTemplateGroupService.save(genTemplateGroup)); + } + + /** + * 修改模板分组关联表 + * @param genTemplateGroup 模板分组关联表 + * @return R + */ + @Operation(summary = "修改模板分组关联表", description = "修改模板分组关联表") + @SysLog("修改模板分组关联表") + @PutMapping + @PreAuthorize("@pms.hasPermission('codegen_templateGroup_edit')") + public R updateById(@RequestBody GenTemplateGroupEntity genTemplateGroup) { + return R.ok(genTemplateGroupService.updateById(genTemplateGroup)); + } + + /** + * 通过id删除模板分组关联表 + * @param ids groupId列表 + * @return R + */ + @Operation(summary = "通过id删除模板分组关联表", description = "通过id删除模板分组关联表") + @SysLog("通过id删除模板分组关联表") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('codegen_templateGroup_del')") + public R removeById(@RequestBody Long[] ids) { + return R.ok(genTemplateGroupService.removeBatchByIds(CollUtil.toList(ids))); + } + + /** + * 导出excel 表格 + * @param genTemplateGroup 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('codegen_templateGroup_export')") + public List export(GenTemplateGroupEntity genTemplateGroup) { + return genTemplateGroupService.list(Wrappers.query(genTemplateGroup)); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java index da20ba30..cd1305c6 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java @@ -1,37 +1,39 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.controller; import cn.hutool.core.io.IoUtil; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.codegen.entity.GenConfig; +import cn.hutool.core.util.StrUtil; import com.pig4cloud.pig.codegen.service.GeneratorService; import com.pig4cloud.pig.common.core.util.R; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -import jakarta.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; import java.util.List; import java.util.Map; +import java.util.zip.ZipOutputStream; /** * 代码生成器 @@ -42,47 +44,61 @@ import java.util.Map; @RestController @RequiredArgsConstructor @RequestMapping("/generator") -@Tag(name = "代码生成模块") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class GeneratorController { private final GeneratorService generatorService; /** - * 列表 - * @param tableName 参数集 - * @param dsName 数据源编号 - * @return 数据库表 + * ZIP 下载生成代码 + * @param tableIds 数据表ID + * @param response 流输出对象 */ - @GetMapping("/page") - public R>>> getPage(Page page, String tableName, String dsName) { - return R.ok(generatorService.getPage(page, tableName, dsName)); + @SneakyThrows + @GetMapping("/download") + public void download(String tableIds, HttpServletResponse response) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(outputStream); + + // 生成代码 + for (String tableId : tableIds.split(StrUtil.COMMA)) { + generatorService.downloadCode(Long.parseLong(tableId), zip); + } + + IoUtil.close(zip); + + // zip压缩包数据 + byte[] data = outputStream.toByteArray(); + + response.reset(); + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s.zip", tableIds)); + response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length)); + response.setContentType("application/octet-stream; charset=UTF-8"); + IoUtil.write(response.getOutputStream(), false, data); + } + + /** + * 目标目录生成代码 + */ + @ResponseBody + @GetMapping("/code") + public R code(String tableIds) throws Exception { + // 生成代码 + for (String tableId : tableIds.split(StrUtil.COMMA)) { + generatorService.generatorCode(Long.valueOf(tableId)); + } + + return R.ok(); } /** * 预览代码 - * @param genConfig 数据表配置 + * @param tableId 表ID * @return */ - @GetMapping("/preview") - public R> previewCode(GenConfig genConfig) { - return R.ok(generatorService.previewCode(genConfig)); - } - - /** - * 生成代码 - */ @SneakyThrows - @PostMapping("/code") - public void generatorCode(@RequestBody GenConfig genConfig, HttpServletResponse response) { - byte[] data = generatorService.generatorCode(genConfig); - response.reset(); - response.setHeader(HttpHeaders.CONTENT_DISPOSITION, - String.format("attachment; filename=%s.zip", genConfig.getTableName())); - response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length)); - response.setContentType("application/octet-stream; charset=UTF-8"); - - IoUtil.write(response.getOutputStream(), Boolean.TRUE, data); + @GetMapping("/preview") + public List> preview(Long tableId) { + return generatorService.preview(tableId); } } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java index 1755b4fa..bcbc8919 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.entity; @@ -35,6 +36,11 @@ public class ColumnEntity { */ private String dataType; + /** + * JAVA 数据类型 + */ + private String javaType; + /** * 备注 */ diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java index dbbc6173..7a6789fb 100644 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.entity; @@ -61,7 +62,7 @@ public class GenConfig { private String comments; /** - * 代码风格 0 - avue 1 - element + * 代码风格 0 - avue 1 - element 2 - uview */ private String style; diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java index caec1e5c..ca85bcc8 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java @@ -1,28 +1,28 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.baomidou.mybatisplus.annotation.TableName; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; + /** * 数据源表 * @@ -32,7 +32,9 @@ import lombok.EqualsAndHashCode; @Data @TableName("gen_datasource_conf") @EqualsAndHashCode(callSuper = true) -public class GenDatasourceConf extends BaseEntity { +public class GenDatasourceConf extends Model { + + private static final long serialVersionUID = 1L; /** * 主键 @@ -46,10 +48,40 @@ public class GenDatasourceConf extends BaseEntity { private String name; /** - * jdbcurl + * 数据库类型 + */ + private String dsType; + + /** + * 配置类型 (0 主机形式 | 1 url形式) + */ + private Integer confType; + + /** + * 主机地址 + */ + private String host; + + /** + * 端口 + */ + private Integer port; + + /** + * jdbc-url */ private String url; + /** + * 实例 + */ + private String instance; + + /** + * 数据库名称 + */ + private String dsName; + /** * 用户名 */ @@ -61,9 +93,22 @@ public class GenDatasourceConf extends BaseEntity { private String password; /** - * 删除标记 + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + + /** + * 0-正常,1-删除 */ @TableLogic + @TableField(fill = FieldFill.INSERT) private String delFlag; } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFieldType.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFieldType.java new file mode 100644 index 00000000..8a5da8b4 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFieldType.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.LocalDateTime; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:16:01 + */ +@Data +@TableName("gen_field_type") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "列属性") +public class GenFieldType extends Model { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "id") + private Long id; + + /** + * 字段类型 + */ + @Schema(description = "字段类型") + private String columnType; + + /** + * 属性类型 + */ + @Schema(description = "属性类型") + private String attrType; + + /** + * 属性包名 + */ + @Schema(description = "属性包名") + private String packageName; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @Schema(description = "修改时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + + /** + * 删除标识(0-正常,1-删除) + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") + private String delFlag; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java deleted file mode 100755 index 2f68a3b8..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.codegen.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 生成记录 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@Data -@TableName("gen_form_conf") -@Schema(description = "生成记录") -@EqualsAndHashCode(callSuper = true) -public class GenFormConf extends BaseEntity { - - /** - * ID - */ - @TableId(type = IdType.ASSIGN_ID) - @Schema(description = "ID") - private Long id; - - /** - * 表名称 - */ - @Schema(description = "表名称") - private String tableName; - - /** - * 表单信息 - */ - @Schema(description = "表单信息") - private String formInfo; - - /** - * 删除标记 - */ - @Schema(description = "删除标记") - private String delFlag; - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenGroupEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenGroupEntity.java new file mode 100644 index 00000000..5418808b --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenGroupEntity.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.LocalDateTime; + +/** + * 模板分组 + * + * @author PIG + * @date 2023-02-21 20:01:53 + */ +@Data +@TableName("gen_group") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "模板分组") +public class GenGroupEntity extends Model { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "id") + private Long id; + + /** + * 分组名称 + */ + @Schema(description = "分组名称") + private String groupName; + + /** + * 分组描述 + */ + @Schema(description = "分组描述") + @TableField(fill = FieldFill.INSERT) + private String groupDesc; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @Schema(description = "修改时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + + /** + * 删除标识(0-正常,1-删除) + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") + private String delFlag; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTable.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTable.java new file mode 100644 index 00000000..0ef736ae --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTable.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:34:55 + */ +@Data +@TableName("gen_table") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "列属性") +public class GenTable extends Model { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "id") + private Long id; + + /** + * 数据源名称 + */ + @Schema(description = "数据源名称") + private String dsName; + + /** + * 数据源类型 + */ + @Schema(description = "数据源类型") + private String dbType; + + /** + * 表名 + */ + @Schema(description = "表名") + private String tableName; + + /** + * 类名 + */ + @Schema(description = "类名") + private String className; + + /** + * 说明 + */ + @Schema(description = "说明") + private String tableComment; + + /** + * 作者 + */ + @Schema(description = "作者") + private String author; + + /** + * 邮箱 + */ + @Schema(description = "邮箱") + private String email; + + /** + * 项目包名 + */ + @Schema(description = "项目包名") + private String packageName; + + /** + * 项目版本号 + */ + @Schema(description = "项目版本号") + private String version; + + /** + * 生成方式 0:zip压缩包 1:自定义目录 + */ + @Schema(description = "生成方式 0:zip压缩包 1:自定义目录") + private Integer generatorType; + + /** + * 后端生成路径 + */ + @Schema(description = "后端生成路径") + private String backendPath; + + /** + * 前端生成路径 + */ + @Schema(description = "前端生成路径") + private String frontendPath; + + /** + * 模块名 + */ + @Schema(description = "模块名") + private String moduleName; + + /** + * 功能名 + */ + @Schema(description = "功能名") + private String functionName; + + /** + * 表单布局 1:一列 2:两列 + */ + @Schema(description = "表单布局 1:一列 2:两列") + private Integer formLayout; + + /** + * 基类ID + */ + @Schema(description = "基类ID") + private Long baseclassId; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + private LocalDateTime createTime; + + /** + * 代码生成风格 + */ + private Long style; + + /** + * 字段列表 + */ + @TableField(exist = false) + private List fieldList; + + /** + * 代码风格(模版分组信息) + */ + @TableField(exist = false) + private List groupList; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTableColumnEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTableColumnEntity.java new file mode 100755 index 00000000..a54612b7 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTableColumnEntity.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author lengleng + * @date 2023-02-06 + * + * 记录表字段的配置信息 + */ +@Data +@TableName("gen_table_column") +@EqualsAndHashCode(callSuper = true) +public class GenTableColumnEntity extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 数据源名 + */ + private String dsName; + + /** + * 表名称 + */ + private String tableName; + + /** + * 字段名称 + */ + private String fieldName; + + /** + * 排序 + */ + private Integer sort; + + /** + * 字段类型 + */ + private String fieldType; + + /** + * 字段说明 + */ + private String fieldComment; + + /** + * 属性名 + */ + private String attrName; + + /** + * 属性类型 + */ + private String attrType; + + /** + * 属性包名 + */ + private String packageName; + + /** + * 自动填充 + */ + private String autoFill; + + /** + * 主键 0:否 1:是 + */ + private boolean primaryPk; + + /** + * 基类字段 0:否 1:是 + */ + private boolean baseField; + + /** + * 表单项 0:否 1:是 + */ + private boolean formItem; + + /** + * 表单必填 0:否 1:是 + */ + private boolean formRequired; + + /** + * 表单类型 + */ + private String formType; + + /** + * 表单效验 + */ + private String formValidator; + + /** + * 列表项 0:否 1:是 + */ + private boolean gridItem; + + /** + * 列表排序 0:否 1:是 + */ + private boolean gridSort; + + /** + * 查询项 0:否 1:是 + */ + private boolean queryItem; + + /** + * 查询方式 + */ + private String queryType; + + /** + * 查询表单类型 + */ + private String queryFormType; + + /** + * 字段字典类型 + */ + @TableField(updateStrategy = FieldStrategy.IGNORED) + private String fieldDict; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTemplateEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTemplateEntity.java new file mode 100644 index 00000000..10b0f185 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTemplateEntity.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.LocalDateTime; + +/** + * 模板 + * + * @author PIG + * @date 2023-02-21 17:15:44 + */ +@Data +@TableName("gen_template") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "模板") +public class GenTemplateEntity extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "主键") + private Long id; + + /** + * 模板名称 + */ + @Schema(description = "模板名称") + private String templateName; + + /** + * 模板路径 + */ + @Schema(description = "模板路径") + private String generatorPath; + + /** + * 模板描述 + */ + @Schema(description = "模板描述") + private String templateDesc; + + /** + * 模板代码 + */ + @Schema(description = "模板代码") + private String templateCode; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.UPDATE) + @Schema(description = "修改人") + private String updateBy; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @Schema(description = "修改时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + + /** + * 删除标识(0-正常,1-删除) + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记,1:已删除,0:正常") + private String delFlag; + +} diff --git a/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTemplateGroupEntity.java old mode 100755 new mode 100644 similarity index 53% rename from pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTemplateGroupEntity.java index 8431d722..ebe3e95e --- a/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTemplateGroupEntity.java @@ -14,45 +14,41 @@ * this software without specific prior written permission. * Author: lengleng (wangiegie@gmail.com) */ -#set($excludeColumns = ["create_time","update_time","create_by","update_by"]) -package ${package}.${moduleName}.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; +package com.pig4cloud.pig.codegen.entity; + import com.baomidou.mybatisplus.annotation.TableName; -import com.pig4cloud.pig.common.mybatis.base.BaseEntity; +import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; -#if(${hasBigDecimal}) -import java.math.BigDecimal; -#end +import lombok.experimental.Accessors; /** - * ${comments} + * 模板分组关联表 * - * @author ${author} - * @date ${datetime} + * @author PIG + * @date 2023-02-22 09:25:15 */ @Data -@TableName("${tableName}") +@TableName("gen_template_group") +@Accessors(chain = true) @EqualsAndHashCode(callSuper = true) -@Schema(description = "${comments}") -public class ${className} extends BaseEntity { +@Schema(description = "模板分组关联表") +public class GenTemplateGroupEntity extends Model { -#foreach ($column in $columns) -## 排除部分字段 -#if(!$excludeColumns.contains($column.columnName)) - /** - * $column.comments - */ -#if($column.columnName == $pk.columnName) - @TableId(type = IdType.ASSIGN_ID) -#end - @Schema(description ="$column.comments"#if($column.hidden),hidden=$column.hidden#end) - private $column.attrType $column.lowerAttrName; + private static final long serialVersionUID = 1L; -#end -#end + /** + * 分组id + */ + @Schema(description = "分组id") + private Long groupId; + + /** + * 模板id + */ + @Schema(description = "模板id") + private Long templateId; } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java index a682efae..b909698c 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.entity; @@ -57,4 +58,9 @@ public class TableEntity { */ private String lowerClassName; + /** + * 数据库类型 (用于根据数据库个性化) + */ + private String dbType; + } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java index be10be26..6192b5ac 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.mapper; diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDynamicMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDynamicMapper.java new file mode 100755 index 00000000..d20c04fc --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDynamicMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.mapper; + +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.LinkedHashMap; +import java.util.List; + +/** + * 动态查询 + * + * @author lengleng + * @date 2022-07-09 + */ +@Mapper +public interface GenDynamicMapper { + + @InterceptorIgnore(tenantLine = "true") + List> dynamicQuerySql(@Param("value") String sq); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFieldTypeMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFieldTypeMapper.java new file mode 100644 index 00000000..0d92ab79 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFieldTypeMapper.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.codegen.entity.GenFieldType; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Set; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:16:01 + */ +@Mapper +public interface GenFieldTypeMapper extends BaseMapper { + + /** + * 根据tableId,获取包列表 + * @param dsName 数据源名称 + * @param tableName 表名称 + * @return 返回包列表 + */ + Set getPackageByTableId(@Param("dsName") String dsName, @Param("tableName") String tableName); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFormConfMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFormConfMapper.java deleted file mode 100755 index 6a9da95b..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFormConfMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.codegen.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.pig4cloud.pig.codegen.entity.GenFormConf; -import org.apache.ibatis.annotations.Mapper; - -/** - * 生成记录 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@Mapper -public interface GenFormConfMapper extends BaseMapper { - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenGroupMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenGroupMapper.java new file mode 100644 index 00000000..146e2fa1 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenGroupMapper.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.codegen.entity.GenGroupEntity; +import com.pig4cloud.pig.codegen.util.vo.GroupVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 模板分组 + * + * @author PIG + * @date 2023-02-21 20:01:53 + */ +@Mapper +public interface GenGroupMapper extends BaseMapper { + + GroupVo getGroupVoById(@Param("id") Long id); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTableColumnMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTableColumnMapper.java new file mode 100644 index 00000000..3b2a66f7 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTableColumnMapper.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.codegen.entity.GenTableColumnEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:16:01 + */ +@Mapper +public interface GenTableColumnMapper extends BaseMapper { + +} diff --git a/pig-visual/pig-codegen/src/main/resources/template/Mapper.java.vm b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTableMapper.java old mode 100755 new mode 100644 similarity index 80% rename from pig-visual/pig-codegen/src/main/resources/template/Mapper.java.vm rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTableMapper.java index d5f3d393..27d2698b --- a/pig-visual/pig-codegen/src/main/resources/template/Mapper.java.vm +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTableMapper.java @@ -15,19 +15,19 @@ * Author: lengleng (wangiegie@gmail.com) */ -package ${package}.${moduleName}.mapper; +package com.pig4cloud.pig.codegen.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import ${package}.${moduleName}.entity.${className}; +import com.pig4cloud.pig.codegen.entity.GenTable; import org.apache.ibatis.annotations.Mapper; /** - * ${comments} + * 列属性 * - * @author ${author} - * @date ${datetime} + * @author pigx code generator + * @date 2023-02-06 20:34:55 */ @Mapper -public interface ${className}Mapper extends BaseMapper<${className}> { +public interface GenTableMapper extends BaseMapper { } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTemplateGroupMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTemplateGroupMapper.java new file mode 100644 index 00000000..4be972a4 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTemplateGroupMapper.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.codegen.entity.GenTemplateGroupEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 模板分组关联表 + * + * @author PIG + * @date 2023-02-22 09:25:15 + */ +@Mapper +public interface GenTemplateGroupMapper extends BaseMapper { + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTemplateMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTemplateMapper.java new file mode 100644 index 00000000..be2dc684 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenTemplateMapper.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.codegen.entity.GenTemplateEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 模板 + * + * @author PIG + * @date 2023-02-21 17:15:44 + */ +@Mapper +public interface GenTemplateMapper extends BaseMapper { + + /** + * 根据groupId查询 模板 + * @param groupId + * @return + */ + List listTemplateById(Long groupId); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java index da0c91eb..6952289a 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java @@ -1,25 +1,28 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.mapper; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; +import com.pig4cloud.pig.codegen.entity.ColumnEntity; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -31,16 +34,23 @@ import java.util.Map; * @author lengleng * @date 2018-07-30 */ -@Mapper -public interface GeneratorMapper { +public interface GeneratorMapper extends BaseMapper { + + /** + * 查询全部的表 + * @return + */ + @InterceptorIgnore(tenantLine = "true") + List> queryTable(); /** * 分页查询表格 - * @param page - * @param tableName + * @param page 分页信息 + * @param tableName 表名称 * @return */ - IPage>> queryList(Page page, @Param("tableName") String tableName); + @InterceptorIgnore(tenantLine = "true") + IPage> queryTable(Page page, @Param("tableName") String tableName); /** * 查询表信息 @@ -49,15 +59,39 @@ public interface GeneratorMapper { * @return */ @DS("#last") + @InterceptorIgnore(tenantLine = "true") Map queryTable(@Param("tableName") String tableName, String dsName); /** - * 查询表列信息 + * 分页查询表分页信息 + * @param page + * @param tableName + * @param dsName + * @return + */ + @DS("#last") + @InterceptorIgnore(tenantLine = "true") + IPage selectTableColumn(Page page, @Param("tableName") String tableName, + @Param("dsName") String dsName); + + /** + * 查询表全部列信息 + * @param tableName + * @param dsName + * @return + */ + @DS("#last") + @InterceptorIgnore(tenantLine = "true") + List selectTableColumn(@Param("tableName") String tableName, @Param("dsName") String dsName); + + /** + * 查询表全部列信息 * @param tableName 表名称 * @param dsName 数据源名称 * @return */ @DS("#last") - List> queryColumns(@Param("tableName") String tableName, String dsName); + @InterceptorIgnore(tenantLine = "true") + List> selectMapTableColumn(@Param("tableName") String tableName, String dsName); } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMysqlMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMysqlMapper.java new file mode 100755 index 00000000..26a7cb63 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMysqlMapper.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.mapper; + +import org.apache.ibatis.annotations.Mapper; + +/** + * 支持 mysql 代码生成器 + * + * @author lengleng + * @date 2020-12-11 + */ +@Mapper +public interface GeneratorMysqlMapper extends GeneratorMapper { + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenCodeService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenCodeService.java deleted file mode 100644 index 4e9f9cd5..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenCodeService.java +++ /dev/null @@ -1,329 +0,0 @@ -package com.pig4cloud.pig.codegen.service; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.StrUtil; -import com.pig4cloud.pig.codegen.entity.ColumnEntity; -import com.pig4cloud.pig.codegen.entity.GenConfig; -import com.pig4cloud.pig.codegen.entity.GenFormConf; -import com.pig4cloud.pig.codegen.entity.TableEntity; -import com.pig4cloud.pig.common.core.constant.CommonConstants; -import com.pig4cloud.pig.common.core.exception.CheckedException; -import lombok.SneakyThrows; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.WordUtils; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.tools.generic.DateTool; -import org.apache.velocity.tools.generic.MathTool; - -import java.io.File; -import java.io.StringWriter; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipOutputStream; - -/** - * 生成代码抽象 - * - * @author Fxz - * @date 2022/7/21 02:24 - */ -public interface GenCodeService { - - default Map gen(GenConfig genConfig, Map table, List> columns, - ZipOutputStream zip, GenFormConf formConf) { - // 构建表实体 - TableEntity tableEntity = buildTableEntity(genConfig, table); - - // 处理列相关 - buildColumnEntity(tableEntity, columns); - - // 模板入参 - Map tempModel = buildTempModel(tableEntity, genConfig); - - return renderData(genConfig, zip, tableEntity, tempModel, formConf); - } - - /** - * 渲染数据 - * @param genConfig 用户输入相关 - * @param zip 输出zip流 - * @param tableEntity 表格实体 - * @param map 参数集合 - * @param formConf 表单设计 - */ - @SneakyThrows - default Map renderData(GenConfig genConfig, ZipOutputStream zip, TableEntity tableEntity, - Map map, GenFormConf formConf) { - // 设置velocity资源加载器 - Properties prop = new Properties(); - prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - Velocity.init(prop); - - VelocityContext context = new VelocityContext(map); - // 函数库 - context.put("math", new MathTool()); - context.put("dateTool", new DateTool()); - - // 获取模板列表 - List templates = getTemplates(genConfig); - Map resultMap = new LinkedHashMap<>(8); - - for (String template : templates) { - // 渲染模板 - StringWriter sw = new StringWriter(); - Template tpl = Velocity.getTemplate(template, CharsetUtil.UTF_8); - tpl.merge(context, sw); - - // 添加到zip - String fileName = getFileName(template, tableEntity.getCaseClassName(), map.get("package").toString(), - map.get("moduleName").toString()); - - if (zip != null) { - try { - zip.putNextEntry(new ZipEntry(Objects.requireNonNull(fileName))); - IoUtil.write(zip, StandardCharsets.UTF_8, false, sw.toString()); - IoUtil.close(sw); - } - catch (ZipException zipException) { - } - zip.closeEntry(); - } - resultMap.put(template, sw.toString()); - } - - return resultMap; - } - - /** - * 注入支持的模板列表 - * @param config 用户输入 - * @return ListString - */ - default List getTemplates(GenConfig config) { - List templates = new ArrayList<>(); - templates.add("template/Entity.java.vm"); - templates.add("template/Mapper.java.vm"); - templates.add("template/Mapper.xml.vm"); - templates.add("template/Service.java.vm"); - templates.add("template/ServiceImpl.java.vm"); - templates.add("template/Controller.java.vm"); - templates.add("template/menu.sql.vm"); - return templates; - } - - /** - * 获取文件名 - */ - default String getFileName(String template, String className, String packageName, String moduleName) { - String packagePath = CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" - + File.separator + "java" + File.separator; - - if (StringUtils.isNotBlank(packageName)) { - packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator; - } - - if (template.contains("Entity.java.vm")) { - return packagePath + "entity" + File.separator + className + ".java"; - } - - if (template.contains("Mapper.java.vm")) { - return packagePath + "mapper" + File.separator + className + "Mapper.java"; - } - - if (template.contains("Service.java.vm")) { - return packagePath + "service" + File.separator + className + "Service.java"; - } - - if (template.contains("ServiceImpl.java.vm")) { - return packagePath + "service" + File.separator + "impl" + File.separator + className + "ServiceImpl.java"; - } - - if (template.contains("Controller.java.vm")) { - return packagePath + "controller" + File.separator + className + "Controller.java"; - } - - if (template.contains("Mapper.xml.vm")) { - return CommonConstants.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator - + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml"; - } - - if (template.contains("menu.sql.vm")) { - return className.toLowerCase() + "_menu.sql"; - } - - return null; - } - - default Map buildTempModel(TableEntity tableEntity, GenConfig genConfig) { - // 封装模板数据 - Map map = new HashMap<>(16); - map.put("tableName", tableEntity.getTableName()); - map.put("pk", tableEntity.getPk()); - map.put("className", tableEntity.getCaseClassName()); - map.put("classname", tableEntity.getLowerClassName()); - map.put("pathName", tableEntity.getLowerClassName().toLowerCase()); - map.put("columns", tableEntity.getColumns()); - map.put("datetime", DateUtil.now()); - - if (StrUtil.isNotBlank(genConfig.getComments())) { - map.put("comments", genConfig.getComments()); - } - else { - map.put("comments", tableEntity.getComments()); - } - - if (StrUtil.isNotBlank(genConfig.getAuthor())) { - map.put("author", genConfig.getAuthor()); - } - else { - map.put("author", getConfig().getString("author")); - } - - if (StrUtil.isNotBlank(genConfig.getModuleName())) { - map.put("moduleName", genConfig.getModuleName()); - } - else { - map.put("moduleName", getConfig().getString("moduleName")); - } - - if (StrUtil.isNotBlank(genConfig.getPackageName())) { - map.put("package", genConfig.getPackageName()); - map.put("mainPath", genConfig.getPackageName()); - } - else { - map.put("package", getConfig().getString("package")); - map.put("mainPath", getConfig().getString("mainPath")); - } - - return map; - } - - /** - * 构建 ColumnEntity - * @param columns 列元信息 - */ - default void buildColumnEntity(TableEntity tableEntity, List> columns) { - // 获取需要在swagger文档中隐藏的属性字段 - List hiddenColumns = getConfig().getList("hiddenColumn"); - // 列信息 - List columnList = new ArrayList<>(); - for (Map column : columns) { - ColumnEntity columnEntity = new ColumnEntity(); - columnEntity.setColumnName(column.get("columnName")); - columnEntity.setDataType(column.get("dataType")); - columnEntity.setExtra(column.get("extra")); - columnEntity.setNullable("NO".equals(column.get("isNullable"))); - columnEntity.setColumnType(column.get("columnType")); - // 隐藏不需要的在接口文档中展示的字段 - if (hiddenColumns.contains(column.get("columnName"))) { - columnEntity.setHidden(Boolean.TRUE); - } - else { - columnEntity.setHidden(Boolean.FALSE); - } - // 列名转换成Java属性名 - String attrName = columnToJava(columnEntity.getColumnName()); - columnEntity.setCaseAttrName(attrName); - columnEntity.setLowerAttrName(StringUtils.uncapitalize(attrName)); - - // 判断注释是否为空 - if (StrUtil.isNotBlank(column.get("columnComment"))) { - // 注意去除换行符号 - columnEntity.setComments(StrUtil.removeAllLineBreaks(column.get("columnComment"))); - } - else { - columnEntity.setComments(columnEntity.getLowerAttrName()); - } - - // 列的数据类型,转换成Java类型 - String dataType = StrUtil.subBefore(columnEntity.getDataType(), "(", false); - String attrType = getConfig().getString(dataType, "unknowType"); - columnEntity.setAttrType(attrType); - - // 是否主键 - if ("PRI".equalsIgnoreCase(column.get("columnKey")) && tableEntity.getPk() == null) { - tableEntity.setPk(columnEntity); - } - - columnList.add(columnEntity); - } - tableEntity.setColumns(columnList); - - // 没主键,则第一个字段为主键 - if (tableEntity.getPk() == null) { - tableEntity.setPk(tableEntity.getColumns().get(0)); - } - } - - /** - * 构建 TableEntity - * @param genConfig 用户输入相关 - * @param table 表元信息 - * @return TableEntity - */ - default TableEntity buildTableEntity(GenConfig genConfig, Map table) { - // 表信息 - TableEntity tableEntity = new TableEntity(); - tableEntity.setTableName(table.get("tableName")); - - if (StrUtil.isNotBlank(genConfig.getComments())) { - tableEntity.setComments(genConfig.getComments()); - } - else { - tableEntity.setComments(table.get("tableComment")); - } - - String tablePrefix; - if (StrUtil.isNotBlank(genConfig.getTablePrefix())) { - tablePrefix = genConfig.getTablePrefix(); - } - else { - tablePrefix = getConfig().getString("tablePrefix"); - } - // 表名转换成Java类名 - String className = tableToJava(tableEntity.getTableName(), tablePrefix); - tableEntity.setCaseClassName(className); - tableEntity.setLowerClassName(StringUtils.uncapitalize(className)); - - return tableEntity; - } - - /** - * 获取配置信息 - */ - default Configuration getConfig() { - try { - return new PropertiesConfiguration("generator.properties"); - } - catch (ConfigurationException e) { - throw new CheckedException("获取配置文件失败,", e); - } - } - - /** - * 表名转换成Java类名 - */ - default String tableToJava(String tableName, String tablePrefix) { - if (StringUtils.isNotBlank(tablePrefix)) { - tableName = tableName.replaceFirst(tablePrefix, ""); - } - return columnToJava(tableName); - } - - /** - * 列名转换成Java属性名 - */ - default String columnToJava(String columnName) { - return WordUtils.capitalizeFully(columnName, new char[] { '_' }).replace("_", ""); - } - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java index 5965b5b0..01ec1ce4 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.service; @@ -56,9 +57,9 @@ public interface GenDatasourceConfService extends IService { /** * 通过数据源名称删除 - * @param dsId 数据源ID + * @param dsIds 数据源ID * @return */ - Boolean removeByDsId(Long dsId); + Boolean removeByDsId(Long[] dsIds); } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFieldTypeService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFieldTypeService.java new file mode 100644 index 00000000..9168cdde --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFieldTypeService.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.codegen.entity.GenFieldType; + +import java.util.Set; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:16:01 + */ +public interface GenFieldTypeService extends IService { + + /** + * 根据tableId,获取包列表 + * @param dsName 数据源名称 + * @param tableName 表名称 + * @return 返回包列表 + */ + Set getPackageByTableId(String dsName, String tableName); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFormConfService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFormConfService.java deleted file mode 100755 index 0b79b535..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFormConfService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.codegen.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.pig4cloud.pig.codegen.entity.GenFormConf; - -/** - * 表单管理 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -public interface GenFormConfService extends IService { - - /** - * 获取表单信息 - * @param dsName 数据源ID - * @param tableName 表名称 - * @return - */ - String getForm(String dsName, String tableName); - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenGroupService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenGroupService.java new file mode 100644 index 00000000..c9b3cd76 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenGroupService.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.codegen.util.vo.GroupVo; +import com.pig4cloud.pig.codegen.util.vo.TemplateGroupDTO; +import com.pig4cloud.pig.codegen.entity.GenGroupEntity; + +/** + * 模板分组 + * + * @author PIG + * @date 2023-02-21 20:01:53 + */ +public interface GenGroupService extends IService { + + void saveGenGroup(TemplateGroupDTO genTemplateGroup); + + /** + * 删除分组关系 + * @param ids + */ + void delGroupAndTemplate(Long[] ids); + + /** + * 查询group数据 + * @param id + */ + GroupVo getGroupVoById(Long id); + + /** + * 更新group数据 + * @param groupVo + */ + void updateGroupAndTemplateById(GroupVo groupVo); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTableColumnService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTableColumnService.java new file mode 100644 index 00000000..812ab1ba --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTableColumnService.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.codegen.entity.GenTableColumnEntity; + +import java.util.List; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:16:01 + */ +public interface GenTableColumnService extends IService { + + /** + * 初始化字段列表 + * @param tableFieldList 表字段列表 + */ + void initFieldList(List tableFieldList); + + /** + * 更新表字段 + * @param dsName 数据源名称 + * @param tableName 表名称 + * @param tableFieldList 表字段列表 + */ + void updateTableField(String dsName, String tableName, List tableFieldList); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTableService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTableService.java new file mode 100644 index 00000000..0b41754d --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTableService.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.codegen.entity.GenTable; + +import java.util.List; +import java.util.Map; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:34:55 + */ +public interface GenTableService extends IService { + + /** + * 获取默认配置信息 + * @return 默认配置信息 + */ + Map getGeneratorConfig(); + + /** + * 分页查询表格列表 + * @param page 分页对象 + * @param table 查询条件 + * @return 表格列表分页结果 + */ + IPage list(Page page, GenTable table); + + /** + * 根据数据源名称和表名查询或构建表格 + * @param dsName 数据源名称 + * @param tableName 表名 + * @return 查询到的表格信息 + */ + GenTable queryOrBuildTable(String dsName, String tableName); + + /** + * 查询指定数据源下的所有表格 + * @param dsName 数据源名称 + * @return 所有表格的列表 + */ + List> queryDsAllTable(String dsName); + + /** + * 查询指定数据源和表名的列信息 + * @param dsName 数据源名称 + * @param tableName 表名 + * @return 列信息列表 + */ + List> queryColumn(String dsName, String tableName); + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTemplateGroupService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTemplateGroupService.java new file mode 100644 index 00000000..d5241de8 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTemplateGroupService.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.codegen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.codegen.entity.GenTemplateGroupEntity; + +/** + * 模板分组关联表 + * + * @author PIG + * @date 2023-02-22 09:25:15 + */ +public interface GenTemplateGroupService extends IService { + +} diff --git a/pig-visual/pig-codegen/src/main/resources/template/Service.java.vm b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTemplateService.java old mode 100755 new mode 100644 similarity index 79% rename from pig-visual/pig-codegen/src/main/resources/template/Service.java.vm rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTemplateService.java index 5d808ef5..a465dc20 --- a/pig-visual/pig-codegen/src/main/resources/template/Service.java.vm +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenTemplateService.java @@ -15,17 +15,17 @@ * Author: lengleng (wangiegie@gmail.com) */ -package ${package}.${moduleName}.service; +package com.pig4cloud.pig.codegen.service; import com.baomidou.mybatisplus.extension.service.IService; -import ${package}.${moduleName}.entity.${className}; +import com.pig4cloud.pig.codegen.entity.GenTemplateEntity; /** - * ${comments} + * 模板 * - * @author ${author} - * @date ${datetime} + * @author PIG + * @date 2023-02-21 17:15:44 */ -public interface ${className}Service extends IService<${className}> { +public interface GenTemplateService extends IService { } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java index 380db098..675dc0c9 100644 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java @@ -1,27 +1,25 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.service; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.codegen.entity.GenConfig; - import java.util.List; import java.util.Map; +import java.util.zip.ZipOutputStream; /** * @author lengleng @@ -30,26 +28,23 @@ import java.util.Map; public interface GeneratorService { /** - * 生成代码 - * @param tableNames 表名称 - * @return + * 生成代码zip写出 + * @param tableId 表 + * @param zip 输出流 */ - byte[] generatorCode(GenConfig tableNames); - - /** - * 分页查询表 - * @param page 分页信息 - * @param tableName 表名 - * @param name 数据源ID - * @return - */ - IPage>> getPage(Page page, String tableName, String name); + void downloadCode(Long tableId, ZipOutputStream zip); /** * 预览代码 - * @param genConfig 查询条件 - * @return + * @param tableId 表 + * @return [{模板名称:渲染结果}] */ - Map previewCode(GenConfig genConfig); + List> preview(Long tableId); + + /** + * 目标目录写入渲染结果 + * @param tableId 表 + */ + void generatorCode(Long tableId); } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java index 8dc7da32..5b83efb2 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java @@ -1,35 +1,41 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; -import com.baomidou.dynamic.datasource.creator.DataSourceCreator; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import com.baomidou.dynamic.datasource.creator.DataSourceProperty; +import com.baomidou.dynamic.datasource.creator.DefaultDataSourceCreator; +import com.baomidou.dynamic.datasource.creator.druid.DruidConfig; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pig4cloud.pig.codegen.entity.GenDatasourceConf; import com.pig4cloud.pig.codegen.mapper.GenDatasourceConfMapper; import com.pig4cloud.pig.codegen.service.GenDatasourceConfService; import com.pig4cloud.pig.common.core.util.SpringContextHolder; +import com.pig4cloud.pig.common.datasource.enums.DsConfTypeEnum; +import com.pig4cloud.pig.common.datasource.enums.DsJdbcUrlEnum; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.jasypt.encryption.StringEncryptor; import org.springframework.stereotype.Service; import javax.sql.DataSource; +import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -47,7 +53,7 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl dynamicRoutingDataSource.removeDataSource(ds.getName())); + this.baseMapper.deleteBatchIds(CollUtil.toList(dsIds)); return Boolean.TRUE; } @@ -119,10 +126,14 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl + implements GenFieldTypeService { + + /** + * 根据tableId,获取包列表 + * @param dsName 数据源名称 + * @param tableName 表名称 + * @return 返回包列表 + */ + @Override + public Set getPackageByTableId(String dsName, String tableName) { + Set importList = baseMapper.getPackageByTableId(dsName, tableName); + return importList.stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenFormConfServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenFormConfServiceImpl.java deleted file mode 100755 index a7d150e5..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenFormConfServiceImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.pig4cloud.pig.codegen.service.impl; - -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.pig4cloud.pig.codegen.entity.ColumnEntity; -import com.pig4cloud.pig.codegen.entity.GenFormConf; -import com.pig4cloud.pig.codegen.mapper.GenFormConfMapper; -import com.pig4cloud.pig.codegen.mapper.GeneratorMapper; -import com.pig4cloud.pig.codegen.service.GenCodeService; -import com.pig4cloud.pig.codegen.service.GenFormConfService; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import org.apache.commons.lang.StringUtils; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; -import org.springframework.stereotype.Service; - -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * 表单管理 - * - * @author lengleng - * @date 2019-08-12 15:55:35 - */ -@Service -@RequiredArgsConstructor -public class GenFormConfServiceImpl extends ServiceImpl implements GenFormConfService { - - private final GeneratorMapper generatorMapper; - - private final GenCodeService avue; - - /** - * 1. 根据数据源、表名称,查询已配置表单信息 2. 不存在调用模板生成 - * @param dsName 数据源ID - * @param tableName 表名称 - * @return - */ - @Override - @SneakyThrows - public String getForm(String dsName, String tableName) { - GenFormConf form = getOne(Wrappers.lambdaQuery() - .eq(GenFormConf::getTableName, tableName) - .orderByDesc(GenFormConf::getCreateTime), false); - - if (form != null) { - return form.getFormInfo(); - } - - List> columns = generatorMapper.queryColumns(tableName, dsName); - // 设置velocity资源加载器 - Properties prop = new Properties(); - prop.put("file.resource.loader.class", ClasspathResourceLoader.class.getName()); - Velocity.init(prop); - Template template = Velocity.getTemplate("template/avue/crud.js.vm", CharsetUtil.UTF_8); - VelocityContext context = new VelocityContext(); - - List columnList = new ArrayList<>(); - for (Map column : columns) { - ColumnEntity columnEntity = new ColumnEntity(); - columnEntity.setComments(column.get("columnComment")); - columnEntity.setLowerAttrName(StringUtils.uncapitalize(avue.columnToJava(column.get("columnName")))); - columnList.add(columnEntity); - } - context.put("columns", columnList); - StringWriter writer = new StringWriter(); - template.merge(context, writer); - return StrUtil.trim(StrUtil.removePrefix(writer.toString(), "export const tableOption =")); - } - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenGroupServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenGroupServiceImpl.java new file mode 100644 index 00000000..6e92bf76 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenGroupServiceImpl.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pig.codegen.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pig.codegen.entity.GenGroupEntity; +import com.pig4cloud.pig.codegen.entity.GenTemplateGroupEntity; +import com.pig4cloud.pig.codegen.mapper.GenGroupMapper; +import com.pig4cloud.pig.codegen.service.GenGroupService; +import com.pig4cloud.pig.codegen.service.GenTemplateGroupService; +import com.pig4cloud.pig.codegen.util.vo.GroupVo; +import com.pig4cloud.pig.codegen.util.vo.TemplateGroupDTO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +/** + * 模板分组 + * + * @author PIG + * @date 2023-02-21 20:01:53 + */ +@Slf4j +@Service +@AllArgsConstructor +public class GenGroupServiceImpl extends ServiceImpl implements GenGroupService { + + private final GenTemplateGroupService genTemplateGroupService; + + /** + * 新增模板分组 + * @param genTemplateGroup + */ + @Override + public void saveGenGroup(TemplateGroupDTO genTemplateGroup) { + // 1.保存group + GenGroupEntity groupEntity = new GenGroupEntity(); + BeanUtil.copyProperties(genTemplateGroup, groupEntity); + baseMapper.insert(groupEntity); + // 2.保存关系 + List goals = new LinkedList<>(); + for (Long TemplateId : genTemplateGroup.getTemplateId()) { + GenTemplateGroupEntity templateGroup = new GenTemplateGroupEntity(); + templateGroup.setTemplateId(TemplateId).setGroupId(groupEntity.getId()); + goals.add(templateGroup); + } + genTemplateGroupService.saveBatch(goals); + + } + + /** + * 按照ids删除 + * @param ids groupIds + */ + @Override + public void delGroupAndTemplate(Long[] ids) { + // 删除分组 + this.removeBatchByIds(CollUtil.toList(ids)); + // 删除关系 + genTemplateGroupService + .remove(Wrappers.lambdaQuery().in(GenTemplateGroupEntity::getGroupId, ids)); + } + + /** + * 按照id查询 + * @param id + * @return + */ + @Override + public GroupVo getGroupVoById(Long id) { + return baseMapper.getGroupVoById(id); + } + + /** + * 根据id更新 + * @param groupVo + */ + @Override + public void updateGroupAndTemplateById(GroupVo groupVo) { + // 1.更新自身 + GenGroupEntity groupEntity = new GenGroupEntity(); + BeanUtil.copyProperties(groupVo, groupEntity); + this.updateById(groupEntity); + // 2.更新模板 + // 2.1根据id删除之前的模板 + genTemplateGroupService.remove( + Wrappers.lambdaQuery().eq(GenTemplateGroupEntity::getGroupId, groupVo.getId())); + // 2.2根据ids创建新的模板分组赋值 + List goals = new LinkedList<>(); + for (Long templateId : groupVo.getTemplateId()) { + goals.add(new GenTemplateGroupEntity().setGroupId(groupVo.getId()).setTemplateId(templateId)); + } + genTemplateGroupService.saveBatch(goals); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableColumnServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableColumnServiceImpl.java new file mode 100644 index 00000000..57644d97 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableColumnServiceImpl.java @@ -0,0 +1,88 @@ +package com.pig4cloud.pig.codegen.service.impl; + +import cn.hutool.core.text.NamingCase; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pig.codegen.entity.GenFieldType; +import com.pig4cloud.pig.codegen.entity.GenTableColumnEntity; +import com.pig4cloud.pig.codegen.mapper.GenFieldTypeMapper; +import com.pig4cloud.pig.codegen.mapper.GenTableColumnMapper; +import com.pig4cloud.pig.codegen.service.GenTableColumnService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +/** + * 表字段信息管理 + * + * @author lengleng + * @date 2020/5/18 + */ +@Service +@RequiredArgsConstructor +public class GenTableColumnServiceImpl extends ServiceImpl + implements GenTableColumnService { + + private final GenFieldTypeMapper fieldTypeMapper; + + /** + * 初始化表单字段列表,主要是将数据库表中的字段转化为表单需要的字段数据格式,并为审计字段排序 + * @param tableFieldList 表单字段列表 + */ + public void initFieldList(List tableFieldList) { + // 字段类型、属性类型映射 + List list = fieldTypeMapper.selectList(Wrappers.emptyWrapper()); + Map fieldTypeMap = new LinkedHashMap<>(list.size()); + list.forEach( + fieldTypeMapping -> fieldTypeMap.put(fieldTypeMapping.getColumnType().toLowerCase(), fieldTypeMapping)); + + // 索引计数器 + AtomicInteger index = new AtomicInteger(0); + tableFieldList.forEach(field -> { + // 将字段名转化为驼峰格式 + field.setAttrName(NamingCase.toCamelCase(field.getFieldName())); + + // 获取字段对应的类型 + GenFieldType fieldTypeMapping = fieldTypeMap.getOrDefault(field.getFieldType().toLowerCase(), null); + if (fieldTypeMapping == null) { + // 没找到对应的类型,则为Object类型 + field.setAttrType("Object"); + } + else { + field.setAttrType(fieldTypeMapping.getAttrType()); + field.setPackageName(fieldTypeMapping.getPackageName()); + } + + // 设置查询类型和表单查询类型都为“=” + field.setQueryType("="); + field.setQueryFormType("text"); + + // 设置表单类型为文本框类型 + field.setFormType("text"); + + // 保证审计字段最后显示 + field.setSort(Objects.isNull(field.getSort()) ? index.getAndIncrement() : field.getSort()); + }); + } + + /** + * 更新指定数据源和表名的表单字段信息 + * @param dsName 数据源名称 + * @param tableName 表名 + * @param tableFieldList 表单字段列表 + */ + @Override + public void updateTableField(String dsName, String tableName, List tableFieldList) { + AtomicInteger sort = new AtomicInteger(); + this.updateBatchById(tableFieldList.stream() + .peek(field -> field.setSort(sort.getAndIncrement())) + .collect(Collectors.toList())); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableServiceImpl.java new file mode 100644 index 00000000..5060bd30 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableServiceImpl.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pig.codegen.service.impl; + +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.io.resource.ClassPathResource; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.NamingCase; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pig.codegen.entity.GenGroupEntity; +import com.pig4cloud.pig.codegen.entity.GenTable; +import com.pig4cloud.pig.codegen.entity.GenTableColumnEntity; +import com.pig4cloud.pig.codegen.mapper.GenTableMapper; +import com.pig4cloud.pig.codegen.mapper.GeneratorMapper; +import com.pig4cloud.pig.codegen.service.GenGroupService; +import com.pig4cloud.pig.codegen.service.GenTableColumnService; +import com.pig4cloud.pig.codegen.service.GenTableService; +import com.pig4cloud.pig.codegen.util.*; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 列属性 + * + * @author pigx code generator + * @date 2023-02-06 20:34:55 + */ +@Service +@RequiredArgsConstructor +public class GenTableServiceImpl extends ServiceImpl implements GenTableService { + + /** + * 默认配置信息 + */ + private static final String CONFIG_PATH = "template/config.json"; + + private final GenTableColumnService columnService; + + private final GenGroupService genGroupService; + + /** + * 获取配置信息 + * @return + */ + @Override + public Map getGeneratorConfig() { + ClassPathResource classPathResource = new ClassPathResource(CONFIG_PATH); + JSONObject jsonObject = JSONUtil.parseObj(IoUtil.readUtf8(classPathResource.getStream())); + return jsonObject.getRaw(); + } + + @Override + public List> queryDsAllTable(String dsName) { + GeneratorMapper mapper = GenKit.getMapper(dsName); + // 手动切换数据源 + DynamicDataSourceContextHolder.push(dsName); + return mapper.queryTable(); + } + + @Override + public List> queryColumn(String dsName, String tableName) { + GeneratorMapper mapper = GenKit.getMapper(dsName); + return mapper.selectMapTableColumn(tableName, dsName); + } + + @Override + public IPage list(Page page, GenTable table) { + GeneratorMapper mapper = GenKit.getMapper(table.getDsName()); + // 手动切换数据源 + DynamicDataSourceContextHolder.push(table.getDsName()); + return mapper.queryTable(page, table.getTableName()); + } + + /** + * 获取表信息 + * @param dsName + * @param tableName + * @return + */ + @Override + public GenTable queryOrBuildTable(String dsName, String tableName) { + GenTable genTable = baseMapper.selectOne( + Wrappers.lambdaQuery().eq(GenTable::getTableName, tableName).eq(GenTable::getDsName, dsName)); + // 如果 genTable 为空, 执行导入 + if (Objects.isNull(genTable)) { + genTable = this.tableImport(dsName, tableName); + } + + List fieldList = columnService.list(Wrappers.lambdaQuery() + .eq(GenTableColumnEntity::getDsName, dsName) + .eq(GenTableColumnEntity::getTableName, tableName) + .orderByAsc(GenTableColumnEntity::getSort)); + genTable.setFieldList(fieldList); + + // 查询模板分组信息 + List groupEntities = genGroupService.list(); + genTable.setGroupList(groupEntities); + return genTable; + } + + @Transactional(rollbackFor = Exception.class) + public GenTable tableImport(String dsName, String tableName) { + GeneratorMapper mapper = GenKit.getMapper(dsName); + // 手动切换数据源 + DynamicDataSourceContextHolder.push(dsName); + + // 查询表是否存在 + GenTable table = new GenTable(); + + // 从数据库获取表信息 + Map queryTable = mapper.queryTable(tableName, dsName); + + // 获取默认表配置信息 () + Map generatorConfig = getGeneratorConfig(); + JSONObject project = (JSONObject) generatorConfig.get("project"); + JSONObject developer = (JSONObject) generatorConfig.get("developer"); + + table.setPackageName(project.getStr("packageName")); + table.setVersion(project.getStr("version")); + table.setBackendPath(project.getStr("backendPath")); + table.setFrontendPath(project.getStr("frontendPath")); + table.setAuthor(developer.getStr("author")); + table.setEmail(developer.getStr("email")); + table.setTableName(tableName); + table.setDsName(dsName); + table.setTableComment(MapUtil.getStr(queryTable, "tableComment")); + table.setDbType(MapUtil.getStr(queryTable, "dbType")); + table.setFormLayout(2); + table.setGeneratorType(GeneratorFileTypeEnum.ZIP.ordinal()); + table.setClassName(NamingCase.toPascalCase(tableName)); + table.setModuleName(GenKit.getModuleName(table.getPackageName())); + table.setFunctionName(GenKit.getFunctionName(tableName)); + table.setCreateTime(LocalDateTime.now()); + this.save(table); + + // 获取原生字段数据 + List> queryColumnList = mapper.selectMapTableColumn(tableName, dsName); + List tableFieldList = new ArrayList<>(); + + for (Map columnMap : queryColumnList) { + String columnName = MapUtil.getStr(columnMap, "columnName"); + GenTableColumnEntity genTableColumnEntity = new GenTableColumnEntity(); + genTableColumnEntity.setTableName(tableName); + genTableColumnEntity.setDsName(dsName); + genTableColumnEntity.setFieldName(MapUtil.getStr(columnMap, "columnName")); + genTableColumnEntity.setFieldComment(MapUtil.getStr(columnMap, "comments")); + genTableColumnEntity.setFieldType(MapUtil.getStr(columnMap, "dataType")); + String columnKey = MapUtil.getStr(columnMap, "columnKey"); + genTableColumnEntity.setPrimaryPk(StringUtils.isNotBlank(columnKey) && "PRI".equalsIgnoreCase(columnKey)); + genTableColumnEntity.setAutoFill("DEFAULT"); + genTableColumnEntity.setFormItem(true); + genTableColumnEntity.setGridItem(true); + + // 审计字段处理 + if (EnumUtil.contains(CommonColumnFiledEnum.class, columnName)) { + CommonColumnFiledEnum commonColumnFiledEnum = CommonColumnFiledEnum.valueOf(columnName); + genTableColumnEntity.setFormItem(commonColumnFiledEnum.getFormItem()); + genTableColumnEntity.setGridItem(commonColumnFiledEnum.getGridItem()); + genTableColumnEntity.setAutoFill(commonColumnFiledEnum.getAutoFill()); + genTableColumnEntity.setSort(commonColumnFiledEnum.getSort()); + } + tableFieldList.add(genTableColumnEntity); + } + // 初始化字段数据 + columnService.initFieldList(tableFieldList); + // 保存列数据 + columnService.saveOrUpdateBatch(tableFieldList); + table.setFieldList(tableFieldList); + return table; + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTemplateGroupServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTemplateGroupServiceImpl.java new file mode 100644 index 00000000..e360d0d2 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTemplateGroupServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pig.codegen.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pig.codegen.entity.GenTemplateGroupEntity; +import com.pig4cloud.pig.codegen.mapper.GenTemplateGroupMapper; +import com.pig4cloud.pig.codegen.service.GenTemplateGroupService; +import org.springframework.stereotype.Service; + +/** + * 模板分组关联表 + * + * @author PIG + * @date 2023-02-22 09:25:15 + */ +@Service +public class GenTemplateGroupServiceImpl extends ServiceImpl + implements GenTemplateGroupService { + +} diff --git a/pig-visual/pig-codegen/src/main/resources/template/ServiceImpl.java.vm b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTemplateServiceImpl.java old mode 100755 new mode 100644 similarity index 69% rename from pig-visual/pig-codegen/src/main/resources/template/ServiceImpl.java.vm rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTemplateServiceImpl.java index bce38eee..45d4f4d6 --- a/pig-visual/pig-codegen/src/main/resources/template/ServiceImpl.java.vm +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTemplateServiceImpl.java @@ -14,21 +14,22 @@ * this software without specific prior written permission. * Author: lengleng (wangiegie@gmail.com) */ -package ${package}.${moduleName}.service.impl; +package com.pig4cloud.pig.codegen.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import ${package}.${moduleName}.entity.${className}; -import ${package}.${moduleName}.mapper.${className}Mapper; -import ${package}.${moduleName}.service.${className}Service; +import com.pig4cloud.pig.codegen.entity.GenTemplateEntity; +import com.pig4cloud.pig.codegen.mapper.GenTemplateMapper; +import com.pig4cloud.pig.codegen.service.GenTemplateService; import org.springframework.stereotype.Service; /** - * ${comments} + * 模板 * - * @author ${author} - * @date ${datetime} + * @author PIG + * @date 2023-02-21 11:08:43 */ @Service -public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements ${className}Service { +public class GenTemplateServiceImpl extends ServiceImpl + implements GenTemplateService { } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java index 9d65392a..7876c094 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java @@ -1,42 +1,46 @@ /* - * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * Copyright (c) 2018-2025, lengleng All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) */ package com.pig4cloud.pig.codegen.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; -import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.codegen.entity.GenConfig; -import com.pig4cloud.pig.codegen.entity.GenFormConf; -import com.pig4cloud.pig.codegen.mapper.GenFormConfMapper; -import com.pig4cloud.pig.codegen.mapper.GeneratorMapper; -import com.pig4cloud.pig.codegen.service.GenCodeService; -import com.pig4cloud.pig.codegen.service.GeneratorService; -import com.pig4cloud.pig.codegen.support.StyleTypeEnum; +import cn.hutool.json.JSONObject; +import com.pig4cloud.pig.codegen.entity.GenTable; +import com.pig4cloud.pig.codegen.entity.GenTableColumnEntity; +import com.pig4cloud.pig.codegen.entity.GenTemplateEntity; +import com.pig4cloud.pig.codegen.service.*; +import com.pig4cloud.pig.codegen.util.VelocityKit; +import com.pig4cloud.pig.codegen.util.vo.GroupVo; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.io.ByteArrayOutputStream; +import java.io.File; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; /** @@ -45,99 +49,206 @@ import java.util.zip.ZipOutputStream; *

* 代码生成器 */ +@Slf4j @Service @RequiredArgsConstructor public class GeneratorServiceImpl implements GeneratorService { - private final GeneratorMapper generatorMapper; + private final GenTableColumnService columnService; - private final GenFormConfMapper genFormConfMapper; + private final GenFieldTypeService fieldTypeService; - private final Map genCodeServiceMap; + private final GenTableService tableService; + + private final GenGroupService genGroupService; + + private final GenTemplateService genTemplateService; /** - * 分页查询表 - * @param tableName 查询条件 - * @param dsName - * @return + * 生成代码zip写出 + * @param tableId 表 + * @param zip 输出流 */ @Override - @DS("#last") - public IPage>> getPage(Page page, String tableName, String dsName) { - page.setOptimizeCountSql(false); - return generatorMapper.queryList(page, tableName); + @SneakyThrows + public void downloadCode(Long tableId, ZipOutputStream zip) { + // 数据模型 + Map dataModel = getDataModel(tableId); + + Long style = (Long) dataModel.get("style"); + + GroupVo groupVo = genGroupService.getGroupVoById(style); + List templateList = groupVo.getTemplateList(); + + Map generatorConfig = tableService.getGeneratorConfig(); + JSONObject project = (JSONObject) generatorConfig.get("project"); + String frontendPath = project.getStr("frontendPath"); + String backendPath = project.getStr("backendPath"); + + for (GenTemplateEntity template : templateList) { + String templateCode = template.getTemplateCode(); + String generatorPath = template.getGeneratorPath(); + + dataModel.put("frontendPath", frontendPath); + dataModel.put("backendPath", backendPath); + String content = VelocityKit.renderStr(templateCode, dataModel); + String path = VelocityKit.renderStr(generatorPath, dataModel); + + // 添加到zip + zip.putNextEntry(new ZipEntry(path)); + IoUtil.writeUtf8(zip, false, content); + zip.flush(); + zip.closeEntry(); + } + } /** - * 预览代码 - * @param genConfig 查询条件 - * @return + * 表达式优化的预览代码方法 + * @param tableId 表 + * @return [{模板名称:渲染结果}] */ @Override - public Map previewCode(GenConfig genConfig) { - // 根据tableName 查询最新的表单配置 - List formConfList = genFormConfMapper.selectList(Wrappers.lambdaQuery() - .eq(GenFormConf::getTableName, genConfig.getTableName()) - .orderByDesc(GenFormConf::getCreateTime)); + @SneakyThrows + public List> preview(Long tableId) { + // 数据模型 + Map dataModel = getDataModel(tableId); - String tableNames = genConfig.getTableName(); - String dsName = genConfig.getDsName(); + Long style = (Long) dataModel.get("style"); - // 获取实现 - GenCodeService genCodeService = genCodeServiceMap.get(StyleTypeEnum.getDecs(genConfig.getStyle())); + // 获取模板列表,Lambda 表达式简化代码 + List templateList = genGroupService.getGroupVoById(style).getTemplateList(); - for (String tableName : StrUtil.split(tableNames, StrUtil.DASHED)) { - // 查询表信息 - Map table = generatorMapper.queryTable(tableName, dsName); - // 查询列信息 - List> columns = generatorMapper.queryColumns(tableName, dsName); - // 生成代码 - if (CollUtil.isNotEmpty(formConfList)) { - return genCodeService.gen(genConfig, table, columns, null, formConfList.get(0)); - } - else { - return genCodeService.gen(genConfig, table, columns, null, null); - } - } + Map generatorConfig = tableService.getGeneratorConfig(); + JSONObject project = (JSONObject) generatorConfig.get("project"); + String frontendPath = project.getStr("frontendPath"); + String backendPath = project.getStr("backendPath"); - return MapUtil.empty(); + return templateList.stream().map(template -> { + String templateCode = template.getTemplateCode(); + String generatorPath = template.getGeneratorPath(); + + // 预览模式下, 使用相对路径展示 + dataModel.put("frontendPath", frontendPath); + dataModel.put("backendPath", backendPath); + String content = VelocityKit.renderStr(templateCode, dataModel); + String path = VelocityKit.renderStr(generatorPath, dataModel); + + // 使用 map 简化代码 + return new HashMap(4) { + { + put("code", content); + put("codePath", path); + } + }; + }).collect(Collectors.toList()); } /** - * 生成代码 - * @param genConfig 生成配置 - * @return + * 目标目录写入渲染结果方法 + * @param tableId 表 */ @Override - public byte[] generatorCode(GenConfig genConfig) { - // 根据tableName 查询最新的表单配置 - List formConfList = genFormConfMapper.selectList(Wrappers.lambdaQuery() - .eq(GenFormConf::getTableName, genConfig.getTableName()) - .orderByDesc(GenFormConf::getCreateTime)); + public void generatorCode(Long tableId) { + // 数据模型 + Map dataModel = getDataModel(tableId); + Long style = (Long) dataModel.get("style"); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ZipOutputStream zip = new ZipOutputStream(outputStream); + // 获取模板列表,Lambda 表达式简化代码 + List templateList = genGroupService.getGroupVoById(style).getTemplateList(); - String tableNames = genConfig.getTableName(); - String dsName = genConfig.getDsName(); + templateList.forEach(template -> { + String templateCode = template.getTemplateCode(); + String generatorPath = template.getGeneratorPath(); + String content = VelocityKit.renderStr(templateCode, dataModel); + String path = VelocityKit.renderStr(generatorPath, dataModel); + FileUtil.writeUtf8String(content, path); + }); + } - GenCodeService genCodeService = genCodeServiceMap.get(StyleTypeEnum.getDecs(genConfig.getStyle())); + /** + * 通过 Lambda 表达式优化的获取数据模型方法 + * @param tableId 表格 ID + * @return 数据模型 Map 对象 + */ + private Map getDataModel(Long tableId) { + // 获取表格信息 + GenTable table = tableService.getById(tableId); + // 获取字段列表 + List fieldList = columnService.lambdaQuery() + .eq(GenTableColumnEntity::getDsName, table.getDsName()) + .eq(GenTableColumnEntity::getTableName, table.getTableName()) + .orderByAsc(GenTableColumnEntity::getSort) + .list(); - for (String tableName : StrUtil.split(tableNames, StrUtil.DASHED)) { - // 查询表信息 - Map table = generatorMapper.queryTable(tableName, dsName); - // 查询列信息 - List> columns = generatorMapper.queryColumns(tableName, dsName); - // 生成代码 - if (CollUtil.isNotEmpty(formConfList)) { - genCodeService.gen(genConfig, table, columns, zip, formConfList.get(0)); - } - else { - genCodeService.gen(genConfig, table, columns, zip, null); - } + table.setFieldList(fieldList); + + // 创建数据模型对象 + Map dataModel = new HashMap<>(); + + // 填充数据模型 + dataModel.put("dbType", table.getDbType()); + dataModel.put("package", table.getPackageName()); + dataModel.put("packagePath", table.getPackageName().replace(".", File.separator)); + dataModel.put("version", table.getVersion()); + dataModel.put("moduleName", table.getModuleName()); + dataModel.put("ModuleName", StrUtil.upperFirst(table.getModuleName())); + dataModel.put("functionName", table.getFunctionName()); + dataModel.put("FunctionName", StrUtil.upperFirst(table.getFunctionName())); + dataModel.put("formLayout", table.getFormLayout()); + dataModel.put("style", table.getStyle()); + dataModel.put("author", table.getAuthor()); + dataModel.put("datetime", DateUtil.now()); + dataModel.put("date", DateUtil.today()); + setFieldTypeList(dataModel, table); + + // 获取导入的包列表 + Set importList = fieldTypeService.getPackageByTableId(table.getDsName(), table.getTableName()); + dataModel.put("importList", importList); + dataModel.put("tableName", table.getTableName()); + dataModel.put("tableComment", table.getTableComment()); + dataModel.put("className", StrUtil.lowerFirst(table.getClassName())); + dataModel.put("ClassName", table.getClassName()); + dataModel.put("fieldList", table.getFieldList()); + + dataModel.put("backendPath", table.getBackendPath()); + dataModel.put("frontendPath", table.getFrontendPath()); + return dataModel; + } + + /** + * 将表字段按照类型分组并存储到数据模型中 + * @param dataModel 存储数据的 Map 对象 + * @param table 表信息对象 + */ + private void setFieldTypeList(Map dataModel, GenTable table) { + // 按字段类型分组,使用 Map 存储不同类型的字段列表 + Map> typeMap = table.getFieldList() + .stream() + .collect(Collectors.partitioningBy(GenTableColumnEntity::isPrimaryPk)); + + // 从分组后的 Map 中获取不同类型的字段列表 + List primaryList = typeMap.get(true); + List formList = typeMap.get(false) + .stream() + .filter(GenTableColumnEntity::isFormItem) + .collect(Collectors.toList()); + List gridList = typeMap.get(false) + .stream() + .filter(GenTableColumnEntity::isGridItem) + .collect(Collectors.toList()); + List queryList = typeMap.get(false) + .stream() + .filter(GenTableColumnEntity::isQueryItem) + .collect(Collectors.toList()); + + if (CollUtil.isNotEmpty(primaryList)) { + dataModel.put("pk", primaryList.get(0)); } - IoUtil.close(zip); - return outputStream.toByteArray(); + dataModel.put("primaryList", primaryList); + dataModel.put("formList", formList); + dataModel.put("gridList", gridList); + dataModel.put("queryList", queryList); } } diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/temp/AvueGenCodeServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/temp/AvueGenCodeServiceImpl.java deleted file mode 100644 index d7865f71..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/temp/AvueGenCodeServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.pig4cloud.pig.codegen.service.impl.temp; - -import cn.hutool.core.io.IoUtil; -import com.pig4cloud.pig.codegen.entity.GenConfig; -import com.pig4cloud.pig.codegen.entity.GenFormConf; -import com.pig4cloud.pig.codegen.entity.TableEntity; -import com.pig4cloud.pig.codegen.service.GenCodeService; -import com.pig4cloud.pig.common.core.constant.CommonConstants; -import lombok.SneakyThrows; -import org.springframework.stereotype.Service; - -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -/** - * @author Fxz - * @date 2022/7/21 02:45 - */ -@Service("avue") -public class AvueGenCodeServiceImpl implements GenCodeService { - - public final String CRUD_PREFIX = "export const tableOption ="; - - /** - * 注入支持的模板列表 - * @param config 用户输入 - * @return ListString - */ - @Override - public List getTemplates(GenConfig config) { - List templates = GenCodeService.super.getTemplates(config); - templates.add("template/avue/index.vue.vm"); - templates.add("template/avue/crud.js.vm"); - templates.add("template/avue/api.js.vm"); - return templates; - } - - /** - * 获取文件名 - * @param template - * @param className - * @param packageName - * @param moduleName - */ - @Override - public String getFileName(String template, String className, String packageName, String moduleName) { - if (template.contains("avue/index.vue.vm")) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" - + File.separator + moduleName + File.separator + className.toLowerCase() + File.separator - + "index.vue"; - } - - if (template.contains("avue/api.js.vm")) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + File.separator - + className.toLowerCase() + ".js"; - } - - if (template.contains("avue/crud.js.vm")) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "const" - + File.separator + "crud" + File.separator + className.toLowerCase() + ".js"; - } - - return GenCodeService.super.getFileName(template, className, packageName, moduleName); - } - - /** - * 渲染数据 - * @param genConfig 用户输入相关 - * @param zip 输出zip流 - * @param tableEntity 表格实体 - * @param map 参数集合 - * @param formConf 表单设计 - * @return - */ - @SneakyThrows - public Map renderData(GenConfig genConfig, ZipOutputStream zip, TableEntity tableEntity, - Map map, GenFormConf formConf) { - - Map resultMap = new HashMap<>(); - - if (Objects.nonNull(formConf)) { - // 存在 curd 存在设计好的JSON 则使用Json 覆盖 - String crudTempName = "template/avue/crud.js.vm"; - String fileName = getFileName(crudTempName, tableEntity.getCaseClassName(), map.get("package").toString(), - map.get("moduleName").toString()); - String contents = CRUD_PREFIX + formConf.getFormInfo(); - - if (zip != null) { - zip.putNextEntry(new ZipEntry(Objects.requireNonNull(fileName))); - IoUtil.write(zip, StandardCharsets.UTF_8, false, contents); - zip.closeEntry(); - } - resultMap.putAll(GenCodeService.super.renderData(genConfig, zip, tableEntity, map, formConf)); - resultMap.put(crudTempName, contents); - return resultMap; - } - return GenCodeService.super.renderData(genConfig, zip, tableEntity, map, formConf); - } - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/temp/EleGenCodeServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/temp/EleGenCodeServiceImpl.java deleted file mode 100644 index 680f0406..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/temp/EleGenCodeServiceImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.pig4cloud.pig.codegen.service.impl.temp; - -import com.pig4cloud.pig.codegen.entity.GenConfig; -import com.pig4cloud.pig.codegen.service.GenCodeService; -import com.pig4cloud.pig.common.core.constant.CommonConstants; -import org.springframework.stereotype.Service; - -import java.io.File; -import java.util.List; - -/** - * @author Fxz - * @date 2022/7/21 02:46 - */ -@Service("element") -public class EleGenCodeServiceImpl implements GenCodeService { - - /** - * 注入支持的模板列表 - * @param config 用户输入 - * @return ListString - */ - @Override - public List getTemplates(GenConfig config) { - List templates = GenCodeService.super.getTemplates(config); - templates.add("template/element/index.vue.vm"); - templates.add("template/element/form.vue.vm"); - templates.add("template/avue/api.js.vm"); - return templates; - } - - /** - * 获取文件名 - * @param template - * @param className - * @param packageName - * @param moduleName - */ - @Override - public String getFileName(String template, String className, String packageName, String moduleName) { - if (template.contains("element/index.vue.vm")) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" - + File.separator + moduleName + File.separator + className.toLowerCase() + File.separator - + "index.vue"; - } - - if (template.contains("element/form.vue.vm")) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" - + File.separator + moduleName + File.separator + className.toLowerCase() + File.separator - + className.toLowerCase() + "-form.vue"; - } - - if (template.contains("avue/api.js.vm")) { - return CommonConstants.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + File.separator - + className.toLowerCase() + ".js"; - } - - return GenCodeService.super.getFileName(template, className, packageName, moduleName); - } - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/StyleTypeEnum.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/StyleTypeEnum.java deleted file mode 100644 index 3de92f7c..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/StyleTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.pig4cloud.pig.codegen.support; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * @author lengleng - * @date 2021/7/31 - *

- * 代码生成风格 - */ -@Getter -@AllArgsConstructor -public enum StyleTypeEnum { - - /** - * 前端类型-avue 风格 - */ - AVUE("0", "avue"), - - /** - * 前端类型-element 风格 - */ - ELEMENT("1", "element"); - - /** - * 类型 - */ - private String style; - - /** - * 描述 - */ - private String description; - - public static String getDecs(String style) { - return Arrays.stream(StyleTypeEnum.values()) - .filter(styleTypeEnum -> styleTypeEnum.getStyle().equals(style)) - .findFirst() - .orElse(ELEMENT) - .getDescription(); - } - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CommonColumnFiledEnum.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CommonColumnFiledEnum.java new file mode 100644 index 00000000..47cdd843 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CommonColumnFiledEnum.java @@ -0,0 +1,62 @@ +package com.pig4cloud.pig.codegen.util; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author lengleng + * @date 2023/3/12 + *

+ * 通用字段的填充策略和显示策略 + */ +@Getter +@AllArgsConstructor +public enum CommonColumnFiledEnum { + + /** + * create_by 字段 + */ + create_by(false, false, "INSERT", 100), + + /** + * create_time 字段 + */ + create_time(false, false, "INSERT", 101), + /** + * update_by 字段 + */ + update_by(false, false, "INSERT_UPDATE", 102), + /** + * update_time 字段 + */ + update_time(false, false, "INSERT_UPDATE", 103), + /** + * del_flag 字段 + */ + del_flag(false, false, "DEFAULT", 104), + /** + * tenant_id 字段 + */ + tenant_id(false, false, "DEFAULT", 105); + + /** + * 表单是否默认显示 + */ + private Boolean formItem; + + /** + * 表格是否默认显示 + */ + private Boolean gridItem; + + /** + * 自动填充策略 + */ + private String autoFill; + + /** + * 排序值 + */ + private Integer sort; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/DictTool.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/DictTool.java new file mode 100644 index 00000000..50eaefb1 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/DictTool.java @@ -0,0 +1,32 @@ +package com.pig4cloud.pig.codegen.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; + +import java.util.HashSet; +import java.util.List; + +/** + * @author lengleng + * @date 2023/2/7 + */ +public class DictTool { + + /** + * 将字段列表转换为带有双引号的逗号分隔的字符串 + * @return 带有双引号的逗号分隔的字符串 + */ + public static String quotation(List fields) { + + return CollUtil.join(new HashSet<>(fields), StrUtil.COMMA, s -> String.format("'%s'", s)); + } + + /** + * 将字段列表转换为逗号分隔的字符串 + * @return 逗号分隔的字符串 + */ + public static String format(List fields) { + return CollUtil.join(new HashSet<>(fields), StrUtil.COMMA); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GenKit.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GenKit.java new file mode 100644 index 00000000..057c4165 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GenKit.java @@ -0,0 +1,75 @@ +package com.pig4cloud.pig.codegen.util; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.pig4cloud.pig.codegen.entity.GenDatasourceConf; +import com.pig4cloud.pig.codegen.mapper.GenDatasourceConfMapper; +import com.pig4cloud.pig.codegen.mapper.GeneratorMapper; +import com.pig4cloud.pig.common.core.util.SpringContextHolder; +import com.pig4cloud.pig.common.datasource.enums.DsJdbcUrlEnum; +import lombok.experimental.UtilityClass; +import org.springframework.context.ApplicationContext; + +import java.util.Map; + +/** + * 代码生成工具类 + * + * @author lengleng + * @date 2023/2/16 + */ +@UtilityClass +public class GenKit { + + /** + * 获取功能名 sys_a_b sysAb + * @param tableName 表名 + * @return 功能名 + */ + public String getFunctionName(String tableName) { + return StrUtil.toCamelCase(tableName); + } + + /** + * 获取模块名称 + * @param packageName 包名 + * @return 功能名 + */ + public String getModuleName(String packageName) { + return StrUtil.subAfter(packageName, ".", true); + } + + /** + * 获取数据源对应方言的mapper + * @param dsName 数据源名称 + * @return GeneratorMapper + */ + public GeneratorMapper getMapper(String dsName) { + // 获取目标数据源数据库类型 + GenDatasourceConfMapper datasourceConfMapper = SpringContextHolder.getBean(GenDatasourceConfMapper.class); + GenDatasourceConf datasourceConf = datasourceConfMapper + .selectOne(Wrappers.lambdaQuery().eq(GenDatasourceConf::getName, dsName)); + + String dbConfType; + // 默认MYSQL 数据源 + if (datasourceConf == null) { + dbConfType = DsJdbcUrlEnum.MYSQL.getDbName(); + } + else { + dbConfType = datasourceConf.getDsType(); + } + // 获取全部数据实现 + ApplicationContext context = SpringContextHolder.getApplicationContext(); + Map beansOfType = context.getBeansOfType(GeneratorMapper.class); + + // 根据数据类型选择mapper + for (String key : beansOfType.keySet()) { + if (StrUtil.containsIgnoreCase(key, dbConfType)) { + return beansOfType.get(key); + } + } + + throw new IllegalArgumentException("dsName 不合法: " + dsName); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorFileTypeEnum.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorFileTypeEnum.java new file mode 100644 index 00000000..dc744e79 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorFileTypeEnum.java @@ -0,0 +1,14 @@ +package com.pig4cloud.pig.codegen.util; + +public enum GeneratorFileTypeEnum { + + /** + * zip + */ + ZIP, + /** + * 目录直接写入 + */ + DIRECTORY; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/NamingCaseTool.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/NamingCaseTool.java new file mode 100644 index 00000000..afdd446d --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/NamingCaseTool.java @@ -0,0 +1,35 @@ +package com.pig4cloud.pig.codegen.util; + +import cn.hutool.core.text.NamingCase; + +/** + * 命名规则处理,针对驼峰,下划线等处理 + * + * @author lengleng + * @date 2023/1/31 + */ +public class NamingCaseTool { + + /** + * 传入字段获取的get方法 + * @param in 字段名称 + * @return + */ + public static String getProperty(String in) { + return String.format("get%s", NamingCase.toPascalCase(in)); + } + + public static String setProperty(String in) { + return String.format("set%s", NamingCase.toPascalCase(in)); + } + + /** + * 首字母大写 + * @param in 字段 + * @return 首字母大写 + */ + public static String pascalCase(String in) { + return String.format(NamingCase.toPascalCase(in)); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/VelocityKit.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/VelocityKit.java new file mode 100644 index 00000000..8f7f1301 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/VelocityKit.java @@ -0,0 +1,69 @@ +package com.pig4cloud.pig.codegen.util; + +import cn.hutool.core.util.CharsetUtil; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.apache.velocity.tools.generic.DateTool; +import org.apache.velocity.tools.generic.MathTool; +import org.springframework.stereotype.Service; + +import java.io.StringWriter; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; + +/** + * 模板引擎工具类 + * + * @author lengleng + * @date 2023/2/7 + */ +@Service +public class VelocityKit { + + /** + * Velocity 模板渲染方法 + * @param template 模板 + * @param map 数据模型 + * @return 渲染结果 + */ + public static String render(String template, Map map) { + // 设置velocity资源加载器 + Properties prop = new Properties(); + prop.put("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + Velocity.init(prop); + + VelocityContext context = new VelocityContext(map); + // 函数库,使用 Lambda 表达式简化代码 + Optional.of(new MathTool()).ifPresent(mt -> context.put("math", mt)); + Optional.of(new DateTool()).ifPresent(dt -> context.put("dateTool", dt)); + Optional.of(new DictTool()).ifPresent(dt -> context.put("dict", dt)); + Optional.of(new NamingCaseTool()).ifPresent(nct -> context.put("str", nct)); + + // 渲染模板,使用 Lambda 表达式简化代码 + StringWriter sw = new StringWriter(); + Optional.ofNullable(Velocity.getTemplate(template, CharsetUtil.UTF_8)).ifPresent(tpl -> tpl.merge(context, sw)); + return sw.toString(); + } + + /** + * 渲染文本 + * @param str + * @param dataModel 数据 + * @return + */ + public static String renderStr(String str, Map dataModel) { + // 设置velocity资源加载器 + Velocity.init(); + StringWriter stringWriter = new StringWriter(); + VelocityContext context = new VelocityContext(dataModel); + // 函数库 + context.put("math", new MathTool()); + context.put("dateTool", new DateTool()); + context.put("dict", new DictTool()); + context.put("str", new NamingCaseTool()); + Velocity.evaluate(context, stringWriter, "renderStr", str); + return stringWriter.toString(); + } + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/GroupVo.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/GroupVo.java new file mode 100644 index 00000000..23f6abb5 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/GroupVo.java @@ -0,0 +1,45 @@ +package com.pig4cloud.pig.codegen.util.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.pig4cloud.pig.codegen.entity.GenTemplateEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +public class GroupVo { + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "id") + private Long id; + + /** + * 分组名称 + */ + @Schema(description = "分组名称") + private String groupName; + + /** + * 分组描述 + */ + @Schema(description = "分组描述") + private String groupDesc; + + /** + * 模板ids + */ + @Schema(description = "拥有的模板列表") + private Long[] templateId; + + /** + * 模板列表 + */ + @Schema(description = "拥有的模板列表") + private List templateList; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/SqlDto.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/SqlDto.java new file mode 100644 index 00000000..25393e64 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/SqlDto.java @@ -0,0 +1,22 @@ +package com.pig4cloud.pig.codegen.util.vo; + +import lombok.Data; + +/** + * @author lengleng + * @date 2022/5/2 + */ +@Data +public class SqlDto { + + /** + * 数据源ID + */ + private String dsName; + + /** + * sql脚本 + */ + private String sql; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/TemplateGroupDTO.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/TemplateGroupDTO.java new file mode 100644 index 00000000..8ff23058 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/vo/TemplateGroupDTO.java @@ -0,0 +1,21 @@ +package com.pig4cloud.pig.codegen.util.vo; + +import com.pig4cloud.pig.codegen.entity.GenGroupEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@Data +@Schema(description = "模板传输对象") +@EqualsAndHashCode(callSuper = true) +public class TemplateGroupDTO extends GenGroupEntity { + + /** + * 模板id集合 + */ + @Schema(description = "模板id集合") + private List templateId; + +} diff --git a/pig-visual/pig-codegen/src/main/resources/generator.properties b/pig-visual/pig-codegen/src/main/resources/generator.properties deleted file mode 100755 index 5031d40e..00000000 --- a/pig-visual/pig-codegen/src/main/resources/generator.properties +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F - -mainPath=com.pig4cloud.pig -#\u5305\u540D -package=com.pig4cloud.pig -moduleName=demo -#\u4F5C\u8005 -author=pig code generator - -#\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00) -tablePrefix=table_ - -#\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F -tinyint=Integer -smallint=Integer -mediumint=Integer -int=Integer -integer=Integer -bigint=Long -float=Float -double=Double -decimal=BigDecimal -bit=Boolean - -char=String -bpchar=String -varchar=String -tinytext=String -text=String -mediumtext=String -longtext=String - -date=LocalDateTime -datetime=LocalDateTime -timestamp=LocalDateTime diff --git a/pig-visual/pig-codegen/src/main/resources/logback-spring.xml b/pig-visual/pig-codegen/src/main/resources/logback-spring.xml old mode 100755 new mode 100644 index fa238198..c109e784 --- a/pig-visual/pig-codegen/src/main/resources/logback-spring.xml +++ b/pig-visual/pig-codegen/src/main/resources/logback-spring.xml @@ -1,23 +1,31 @@ + - - + @@ -63,13 +71,16 @@ + + + + - - + diff --git a/pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm b/pig-visual/pig-codegen/src/main/resources/mapper/GenFieldTypeMapper.xml old mode 100755 new mode 100644 similarity index 57% rename from pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm rename to pig-visual/pig-codegen/src/main/resources/mapper/GenFieldTypeMapper.xml index 25c0fa0e..43b07282 --- a/pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm +++ b/pig-visual/pig-codegen/src/main/resources/mapper/GenFieldTypeMapper.xml @@ -21,15 +21,21 @@ - + - -#foreach($column in $columns) -#if($column.lowerAttrName==$pk.lowerAttrName) - -#else - -#end -#end - + + + + + + + + + diff --git a/pig-visual/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml deleted file mode 100755 index 422acb7c..00000000 --- a/pig-visual/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/pig-visual/pig-codegen/src/main/resources/mapper/GenGroupMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GenGroupMapper.xml new file mode 100644 index 00000000..83d36147 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/resources/mapper/GenGroupMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/pig-visual/pig-codegen/src/main/resources/mapper/GenTableMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GenTableMapper.xml new file mode 100644 index 00000000..e9a64953 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/resources/mapper/GenTableMapper.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pig-visual/pig-codegen/src/main/resources/mapper/GenTemplateGroupMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GenTemplateGroupMapper.xml new file mode 100644 index 00000000..fff11ebc --- /dev/null +++ b/pig-visual/pig-codegen/src/main/resources/mapper/GenTemplateGroupMapper.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/pig-visual/pig-codegen/src/main/resources/mapper/GenTemplateMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GenTemplateMapper.xml new file mode 100644 index 00000000..02f10b21 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/resources/mapper/GenTemplateMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMapper.xml deleted file mode 100755 index f226b6fb..00000000 --- a/pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMapper.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - diff --git a/pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMySqlMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMySqlMapper.xml new file mode 100755 index 00000000..ca5b9eb9 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMySqlMapper.xml @@ -0,0 +1,48 @@ + + + + + + + + + SELECT + column_name columnName, + data_type dataType, + column_comment comments, + column_key columnKey, + extra, + is_nullable AS isNullable, + column_type AS columnType + FROM + information_schema.COLUMNS + WHERE + table_name = #{tableName} and table_schema = (select database()) order by ordinal_position + + + + + + + diff --git a/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm deleted file mode 100755 index deae73b0..00000000 --- a/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package ${package}.${moduleName}.controller; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.log.annotation.SysLog; -import ${package}.${moduleName}.entity.${className}; -import ${package}.${moduleName}.service.${className}Service; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.*; - - -/** - * ${comments} - * - * @author ${author} - * @date ${datetime} - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/${pathName}" ) -@Tag(name = "${comments}管理") -@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) -public class ${className}Controller { - - private final ${className}Service ${classname}Service; - - /** - * 分页查询 - * @param page 分页对象 - * @param ${classname} ${comments} - * @return - */ - @Operation(summary = "分页查询", description = "分页查询") - @GetMapping("/page" ) - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" ) - public R get${className}Page(Page page, ${className} ${classname}) { - return R.ok(${classname}Service.page(page, Wrappers.query(${classname}))); - } - - - /** - * 通过id查询${comments} - * @param ${pk.lowerAttrName} id - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/{${pk.lowerAttrName}}" ) - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" ) - public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) { - return R.ok(${classname}Service.getById(${pk.lowerAttrName})); - } - - /** - * 新增${comments} - * @param ${classname} ${comments} - * @return R - */ - @Operation(summary = "新增${comments}", description = "新增${comments}") - @SysLog("新增${comments}" ) - @PostMapping - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" ) - public R save(@RequestBody ${className} ${classname}) { - return R.ok(${classname}Service.save(${classname})); - } - - /** - * 修改${comments} - * @param ${classname} ${comments} - * @return R - */ - @Operation(summary = "修改${comments}", description = "修改${comments}") - @SysLog("修改${comments}" ) - @PutMapping - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" ) - public R updateById(@RequestBody ${className} ${classname}) { - return R.ok(${classname}Service.updateById(${classname})); - } - - /** - * 通过id删除${comments} - * @param ${pk.lowerAttrName} id - * @return R - */ - @Operation(summary = "通过id删除${comments}", description = "通过id删除${comments}") - @SysLog("通过id删除${comments}" ) - @DeleteMapping("/{${pk.lowerAttrName}}" ) - @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" ) - public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) { - return R.ok(${classname}Service.removeById(${pk.lowerAttrName})); - } - -} diff --git a/pig-visual/pig-codegen/src/main/resources/template/avue/api.js.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/api.js.vm deleted file mode 100644 index e257ce76..00000000 --- a/pig-visual/pig-codegen/src/main/resources/template/avue/api.js.vm +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -import request from '@/router/axios' - -export function fetchList(query) { - return request({ - url: '/${moduleName}/${pathName}/page', - method: 'get', - params: query - }) -} - -export function addObj(obj) { - return request({ - url: '/${moduleName}/${pathName}', - method: 'post', - data: obj - }) -} - -export function getObj(id) { - return request({ - url: '/${moduleName}/${pathName}/' + id, - method: 'get' - }) -} - -export function delObj(id) { - return request({ - url: '/${moduleName}/${pathName}/' + id, - method: 'delete' - }) -} - -export function putObj(obj) { - return request({ - url: '/${moduleName}/${pathName}', - method: 'put', - data: obj - }) -} diff --git a/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm deleted file mode 100644 index 05e7fbd3..00000000 --- a/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm +++ /dev/null @@ -1,34 +0,0 @@ -export const tableOption = { - "border": true, - "index": true, - "indexLabel": "序号", - "stripe": true, - "menuAlign": "center", - "align": "center", - "searchMenuSpan": 6, - "column": [ -#set($excludeColumns = ["create_time","update_time","create_by","update_by"]) -#foreach ($column in $columns) -## 当列是主键 或者 列是审计字段时候, 新增不显示,编辑的时候显示单不能编辑 -#if($column.columnName == $pk.columnName || $excludeColumns.contains($column.columnName)) - { - "type": "input", - #if($column.comments) - "label": "$column.comments", - #else - "label": "$column.lowerAttrName", - #end - "prop": "$column.lowerAttrName", - "addDisplay": false, - "editDisabled": true - }#if($foreach.hasNext),#end -#else - { - "type": "input", - "label": "$column.comments", - "prop": "$column.lowerAttrName" - }#if($foreach.hasNext),#end -#end -#end - ] -} diff --git a/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm deleted file mode 100755 index 310aa698..00000000 --- a/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm +++ /dev/null @@ -1,130 +0,0 @@ - - - - diff --git a/pig-visual/pig-codegen/src/main/resources/template/config.json b/pig-visual/pig-codegen/src/main/resources/template/config.json new file mode 100644 index 00000000..4f33f5d0 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/resources/template/config.json @@ -0,0 +1,12 @@ +{ + "project": { + "packageName": "com.pig4cloud.pig", + "version": "1.0.0", + "backendPath": "pig", + "frontendPath": "pig-ui" + }, + "developer": { + "author": "pig", + "email": "pig4cloud@qq.com" + } +} diff --git a/pig-visual/pig-codegen/src/main/resources/template/element/form.vue.vm b/pig-visual/pig-codegen/src/main/resources/template/element/form.vue.vm deleted file mode 100644 index f7fbf7f6..00000000 --- a/pig-visual/pig-codegen/src/main/resources/template/element/form.vue.vm +++ /dev/null @@ -1,102 +0,0 @@ -#set($excludeColumns = ["create_time","update_time","create_by","update_by"]) - - - diff --git a/pig-visual/pig-codegen/src/main/resources/template/element/index.vue.vm b/pig-visual/pig-codegen/src/main/resources/template/element/index.vue.vm deleted file mode 100644 index 5480a7aa..00000000 --- a/pig-visual/pig-codegen/src/main/resources/template/element/index.vue.vm +++ /dev/null @@ -1,130 +0,0 @@ - - - diff --git a/pig-visual/pig-codegen/src/main/resources/template/menu.sql.vm b/pig-visual/pig-codegen/src/main/resources/template/menu.sql.vm deleted file mode 100644 index 565c5d22..00000000 --- a/pig-visual/pig-codegen/src/main/resources/template/menu.sql.vm +++ /dev/null @@ -1,20 +0,0 @@ --- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 根节点 -#set($menuId=${dateTool.getSystemTime()}) - --- 菜单SQL -insert into `sys_menu` (`menu_id`, `parent_id`, `path`, `permission`, `type`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`) - values (${menuId}, '-1', '/${moduleName}/${pathName}/index', '', '0', 'icon-bangzhushouji', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理'); - --- 菜单对应按钮SQL -insert into `sys_menu` ( `parent_id`,`menu_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`) -values(${menuId}, ${math.add($menuId,1)}, '${moduleName}_${pathName}_get', '1', null, '1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}查看'); - -insert into `sys_menu` (`parent_id`, `menu_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`) -values(${menuId}, ${math.add($menuId,2)}, '${moduleName}_${pathName}_add', '1', null, '1', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}新增'); - -insert into `sys_menu` (`parent_id`, `menu_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`) -values(${menuId}, ${math.add($menuId,3)}, '${moduleName}_${pathName}_edit', '1', null, '1', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}修改'); - -insert into `sys_menu` (`parent_id`, `menu_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`) -values(${menuId}, ${math.add($menuId,4)}, '${moduleName}_${pathName}_del', '1', null, '1', '0', '2018-05-15 21:35:18', '3', '2018-07-29 13:38:59', '${comments}删除'); - diff --git a/pig-visual/pig-monitor/pom.xml b/pig-visual/pig-monitor/pom.xml index e643f3cf..06fd1033 100755 --- a/pig-visual/pig-monitor/pom.xml +++ b/pig-visual/pig-monitor/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-visual - 3.6.4 + 3.7.0-SNAPSHOT pig-monitor @@ -61,7 +61,11 @@ org.springframework.boot spring-boot-starter-security - + + org.springframework.security + spring-security-config + + diff --git a/pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java b/pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java index 234ae162..97025d6e 100755 --- a/pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java +++ b/pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java @@ -20,9 +20,13 @@ import de.codecentric.boot.admin.server.config.AdminServerProperties; import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; +import static org.springframework.security.config.Customizer.withDefaults; + /** * WebSecurityConfigurer * @@ -38,6 +42,12 @@ public class WebSecurityConfigurer { this.adminContextPath = adminServerProperties.getContextPath(); } + /** + * spring security 默认的安全策略 + * @param http security注入点 + * @return SecurityFilterChain + * @throws Exception + */ /** * spring security 默认的安全策略 * @param http security注入点 @@ -49,28 +59,17 @@ public class WebSecurityConfigurer { SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); successHandler.setTargetUrlParameter("redirectTo"); successHandler.setDefaultTargetUrl(adminContextPath + "/"); - http.headers() - .frameOptions() - .disable() - .and() - .authorizeHttpRequests() - .requestMatchers(adminContextPath + "/assets/**", adminContextPath + "/login", - adminContextPath + "/instances/**", adminContextPath + "/actuator/**") - .permitAll() - .anyRequest() - .authenticated() - .and() - .formLogin() - .loginPage(adminContextPath + "/login") - .successHandler(successHandler) - .and() - .logout() - .logoutUrl(adminContextPath + "/logout") - .and() - .httpBasic() - .and() - .csrf() - .disable(); + http.headers((header) -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) + .authorizeHttpRequests((authorize) -> authorize + .requestMatchers(adminContextPath + "/assets/**", adminContextPath + "/login", + adminContextPath + "/instances/**", adminContextPath + "/actuator/**") + .permitAll() + .anyRequest() + .authenticated()) + .formLogin((formLogin) -> formLogin.loginPage(adminContextPath + "/login").successHandler(successHandler)) + .logout((logout) -> logout.logoutUrl(adminContextPath + "/logout")) + .httpBasic(withDefaults()) + .csrf(AbstractHttpConfigurer::disable); return http.build(); } diff --git a/pig-visual/pig-quartz/Dockerfile b/pig-visual/pig-quartz/Dockerfile new file mode 100644 index 00000000..e058da5e --- /dev/null +++ b/pig-visual/pig-quartz/Dockerfile @@ -0,0 +1,18 @@ +FROM pig4cloud/java:8-jre + +MAINTAINER wangiegie@gmail.com + +ENV TZ=Asia/Shanghai +ENV JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom" + +RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN mkdir -p /pig-quartz + +WORKDIR /pig-quartz + +EXPOSE 5007 + +ADD ./target/pig-quartz.jar ./ + +CMD sleep 120;java $JAVA_OPTS -jar pig-quartz.jar diff --git a/pig-visual/pig-quartz/pom.xml b/pig-visual/pig-quartz/pom.xml new file mode 100644 index 00000000..010eb4c3 --- /dev/null +++ b/pig-visual/pig-quartz/pom.xml @@ -0,0 +1,91 @@ + + + + com.pig4cloud + pig-visual + 3.7.0-SNAPSHOT + + 4.0.0 + + pig-quartz + jar + + 基于quartz后台定时任务模块 + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.pig4cloud + pig-common-log + + + + com.pig4cloud + pig-common-feign + + + + com.pig4cloud + pig-common-mybatis + + + com.baomidou + mybatis-plus-boot-starter + + + + com.mysql + mysql-connector-j + + + + com.pig4cloud + pig-common-swagger + + + + com.pig4cloud + pig-common-security + + + + org.springframework.boot + spring-boot-starter-quartz + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-undertow + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + io.fabric8 + docker-maven-plugin + + + + diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/PigQuartzApplication.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/PigQuartzApplication.java new file mode 100644 index 00000000..4fa37edf --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/PigQuartzApplication.java @@ -0,0 +1,25 @@ +package com.pig4cloud.pig.daemon.quartz; + +import com.pig4cloud.pig.common.feign.annotation.EnablePigFeignClients; +import com.pig4cloud.pig.common.security.annotation.EnablePigResourceServer; +import com.pig4cloud.pig.common.swagger.annotation.EnablePigDoc; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +/** + * @author frwcloud + * @date 2023-07-05 + */ +@EnablePigDoc("job") +@EnablePigFeignClients +@EnablePigResourceServer +@EnableDiscoveryClient +@SpringBootApplication +public class PigQuartzApplication { + + public static void main(String[] args) { + SpringApplication.run(PigQuartzApplication.class, args); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/AutowireCapableBeanJobFactory.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/AutowireCapableBeanJobFactory.java new file mode 100644 index 00000000..679a3a48 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/AutowireCapableBeanJobFactory.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.config; + +import org.quartz.JobKey; +import org.quartz.spi.TriggerFiredBundle; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.scheduling.quartz.SpringBeanJobFactory; +import org.springframework.util.Assert; + +/** + * @author 郑健楠 + */ +class AutowireCapableBeanJobFactory extends SpringBeanJobFactory { + + private final AutowireCapableBeanFactory beanFactory; + + AutowireCapableBeanJobFactory(AutowireCapableBeanFactory beanFactory) { + Assert.notNull(beanFactory, "Bean factory must not be null"); + this.beanFactory = beanFactory; + } + + @Override + protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { + Object jobInstance = super.createJobInstance(bundle); + this.beanFactory.autowireBean(jobInstance); + + // 此处必须注入 beanName 不然sentinel 报错 + JobKey jobKey = bundle.getTrigger().getJobKey(); + String beanName = jobKey + jobKey.getName(); + this.beanFactory.initializeBean(jobInstance, beanName); + return jobInstance; + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxInitQuartzJob.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxInitQuartzJob.java new file mode 100644 index 00000000..4478bb00 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxInitQuartzJob.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.config; + +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.service.SysJobService; +import com.pig4cloud.pig.daemon.quartz.util.TaskUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.quartz.Scheduler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author 郑健楠 + *

+ * 初始化加载定时任务 + */ +@Slf4j +@Configuration +@AllArgsConstructor +public class PigxInitQuartzJob { + + private final SysJobService sysJobService; + + private final TaskUtil taskUtil; + + private final Scheduler scheduler; + + @Bean + public void customize() { + sysJobService.list().forEach(sysjob -> { + if (PigxQuartzEnum.JOB_STATUS_RELEASE.getType().equals(sysjob.getJobStatus())) { + taskUtil.removeJob(sysjob, scheduler); + } + else if (PigxQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus())) { + taskUtil.resumeJob(sysjob, scheduler); + } + else if (PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) { + taskUtil.pauseJob(sysjob, scheduler); + } + else { + taskUtil.removeJob(sysjob, scheduler); + } + }); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzConfig.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzConfig.java new file mode 100644 index 00000000..a86afb08 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzConfig.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.config; + +import org.quartz.Calendar; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.Trigger; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.quartz.QuartzProperties; +import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * @author 郑健楠 + */ +@EnableAsync +@Configuration +@ConditionalOnClass({ Scheduler.class, SchedulerFactoryBean.class }) +@EnableConfigurationProperties({ QuartzProperties.class }) +public class PigxQuartzConfig { + + private final QuartzProperties properties; + + private final List customizers; + + private final JobDetail[] jobDetails; + + private final Map calendars; + + private final Trigger[] triggers; + + private final ApplicationContext applicationContext; + + public PigxQuartzConfig(QuartzProperties properties, + ObjectProvider> customizers, ObjectProvider jobDetails, + ObjectProvider> calendars, ObjectProvider triggers, + ApplicationContext applicationContext) { + this.properties = properties; + this.customizers = customizers.getIfAvailable(); + this.jobDetails = jobDetails.getIfAvailable(); + this.calendars = calendars.getIfAvailable(); + this.triggers = triggers.getIfAvailable(); + this.applicationContext = applicationContext; + } + + @Bean + @ConditionalOnMissingBean + public SchedulerFactoryBean quartzScheduler() { + SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean(); + schedulerFactoryBean + .setJobFactory(new AutowireCapableBeanJobFactory(this.applicationContext.getAutowireCapableBeanFactory())); + if (!this.properties.getProperties().isEmpty()) { + schedulerFactoryBean.setQuartzProperties(this.asProperties(this.properties.getProperties())); + } + + if (this.jobDetails != null && this.jobDetails.length > 0) { + schedulerFactoryBean.setJobDetails(this.jobDetails); + } + + if (this.calendars != null && !this.calendars.isEmpty()) { + schedulerFactoryBean.setCalendars(this.calendars); + } + + if (this.triggers != null && this.triggers.length > 0) { + schedulerFactoryBean.setTriggers(this.triggers); + } + + this.customize(schedulerFactoryBean); + return schedulerFactoryBean; + } + + private Properties asProperties(Map source) { + Properties properties = new Properties(); + properties.putAll(source); + return properties; + } + + private void customize(SchedulerFactoryBean schedulerFactoryBean) { + if (this.customizers != null) { + + for (SchedulerFactoryBeanCustomizer customizer : this.customizers) { + customizer.customize(schedulerFactoryBean); + } + } + + } + + /** + * 通过SchedulerFactoryBean获取Scheduler的实例 + * @return + */ + @Bean + public Scheduler scheduler() { + return quartzScheduler().getScheduler(); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzCustomizerConfig.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzCustomizerConfig.java new file mode 100644 index 00000000..85dda1a6 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzCustomizerConfig.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.config; + +import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +/** + * @author 郑健楠 + */ +@Configuration +public class PigxQuartzCustomizerConfig implements SchedulerFactoryBeanCustomizer { + + @Override + public void customize(SchedulerFactoryBean schedulerFactoryBean) { + schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(true); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzFactory.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzFactory.java new file mode 100644 index 00000000..11d7ac4f --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzFactory.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.config; + +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.quartz.DisallowConcurrentExecution; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author 郑健楠 + * + *

+ * 动态任务工厂 + */ +@Slf4j +@DisallowConcurrentExecution +public class PigxQuartzFactory implements Job { + + @Autowired + private PigxQuartzInvokeFactory pigxQuartzInvokeFactory; + + @Override + @SneakyThrows + public void execute(JobExecutionContext jobExecutionContext) { + SysJob sysJob = (SysJob) jobExecutionContext.getMergedJobDataMap() + .get(PigxQuartzEnum.SCHEDULE_JOB_KEY.getType()); + pigxQuartzInvokeFactory.init(sysJob, jobExecutionContext.getTrigger()); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzInvokeFactory.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzInvokeFactory.java new file mode 100644 index 00000000..d24de910 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigxQuartzInvokeFactory.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.config; + +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.event.SysJobEvent; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.annotation.Aspect; +import org.quartz.Trigger; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; + +/** + * @author 郑健楠 + */ +@Slf4j +@Aspect +@Service +@AllArgsConstructor +public class PigxQuartzInvokeFactory { + + private final ApplicationEventPublisher publisher; + + @SneakyThrows + void init(SysJob sysJob, Trigger trigger) { + publisher.publishEvent(new SysJobEvent(sysJob, trigger)); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/constants/JobTypeQuartzEnum.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/constants/JobTypeQuartzEnum.java new file mode 100644 index 00000000..b4e597af --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/constants/JobTypeQuartzEnum.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author lengleng + * @date 2019-03-14 + *

+ * 任务类型枚举 + */ +@Getter +@AllArgsConstructor +public enum JobTypeQuartzEnum { + + /** + * 反射java类 + */ + JAVA("1", "反射java类"), + + /** + * spring bean 的方式 + */ + SPRING_BEAN("2", "spring bean容器实例"), + + /** + * rest 调用 + */ + REST("3", "rest调用"), + + /** + * jar + */ + JAR("4", "jar调用"); + + /** + * 类型 + */ + private final String type; + + /** + * 描述 + */ + private final String description; + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/constants/PigxQuartzEnum.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/constants/PigxQuartzEnum.java new file mode 100644 index 00000000..6f7ebda2 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/constants/PigxQuartzEnum.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author 郑健楠 + * + *

+ * 定时任务枚举 + */ +@Getter +@AllArgsConstructor +public enum PigxQuartzEnum { + + /** + * 错失执行策略默认 + */ + MISFIRE_DEFAULT("0", "默认"), + + /** + * 错失执行策略-立即执行错失任务 + */ + MISFIRE_IGNORE_MISFIRES("1", "立即执行错失任务"), + + /** + * 错失执行策略-触发一次执行周期执行 + */ + MISFIRE_FIRE_AND_PROCEED("2", "触发一次执行周期执行"), + + /** + * 错失执行策略-不触发执行周期执行 + */ + MISFIRE_DO_NOTHING("3", "不触发周期执行"), + + /** + * 任务详细信息的key + */ + SCHEDULE_JOB_KEY("scheduleJob", "获取任务详细信息的key"), + + /** + * JOB执行状态:0执行成功 + */ + JOB_LOG_STATUS_SUCCESS("0", "执行成功"), + /** + * JOB执行状态:1执行失败 + */ + JOB_LOG_STATUS_FAIL("1", "执行失败"), + + /** + * JOB状态:1已发布 + */ + JOB_STATUS_RELEASE("1", "已发布"), + /** + * JOB状态:2运行中 + */ + JOB_STATUS_RUNNING("2", "运行中"), + /** + * JOB状态:3暂停 + */ + JOB_STATUS_NOT_RUNNING("3", "暂停"), + /** + * JOB状态:4删除 + */ + JOB_STATUS_DEL("4", "删除"); + + /** + * 类型 + */ + private final String type; + + /** + * 描述 + */ + private final String description; + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/controller/SysJobController.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/controller/SysJobController.java new file mode 100644 index 00000000..8c802f2c --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/controller/SysJobController.java @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.controller; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.log.annotation.SysLog; +import com.pig4cloud.pig.common.security.util.SecurityUtils; +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; +import com.pig4cloud.pig.daemon.quartz.service.SysJobLogService; +import com.pig4cloud.pig.daemon.quartz.service.SysJobService; +import com.pig4cloud.pig.daemon.quartz.util.TaskUtil; +import com.pig4cloud.plugin.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.quartz.Scheduler; +import org.springframework.http.HttpHeaders; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author frwcloud + * @date 2019-01-27 10:04:42 + *

+ * 定时任务管理 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/sys-job") +@Tag(description = "sys-job", name = "定时任务") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysJobController { + + private final SysJobService sysJobService; + + private final SysJobLogService sysJobLogService; + + private final TaskUtil taskUtil; + + private final Scheduler scheduler; + + /** + * 定时任务分页查询 + * @param page 分页对象 + * @param sysJob 定时任务调度表 + * @return + */ + @GetMapping("/page") + @Operation(description = "分页定时业务查询") + public R getSysJobPage(Page page, SysJob sysJob) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(sysJob.getJobName()), SysJob::getJobName, sysJob.getJobName()) + .like(StrUtil.isNotBlank(sysJob.getJobGroup()), SysJob::getJobGroup, sysJob.getJobGroup()) + .eq(StrUtil.isNotBlank(sysJob.getJobStatus()), SysJob::getJobStatus, sysJob.getJobGroup()) + .eq(StrUtil.isNotBlank(sysJob.getJobExecuteStatus()), SysJob::getJobExecuteStatus, + sysJob.getJobExecuteStatus()); + return R.ok(sysJobService.page(page, wrapper)); + } + + /** + * 通过id查询定时任务 + * @param id id + * @return R + */ + @GetMapping("/{id}") + @Operation(description = "唯一标识查询定时任务") + public R getById(@PathVariable("id") Long id) { + return R.ok(sysJobService.getById(id)); + } + + /** + * 新增定时任务 + * @param sysJob 定时任务调度表 + * @return R + */ + @SysLog("新增定时任务") + @PostMapping + @PreAuthorize("@pms.hasPermission('job_sys_job_add')") + @Operation(description = "新增定时任务") + public R save(@RequestBody SysJob sysJob) { + sysJob.setJobStatus(PigxQuartzEnum.JOB_STATUS_RELEASE.getType()); + sysJob.setCreateBy(SecurityUtils.getUser().getUsername()); + return R.ok(sysJobService.save(sysJob)); + } + + /** + * 修改定时任务 + * @param sysJob 定时任务调度表 + * @return R + */ + @SysLog("修改定时任务") + @PutMapping + @PreAuthorize("@pms.hasPermission('job_sys_job_edit')") + @Operation(description = "修改定时任务") + public R updateById(@RequestBody SysJob sysJob) { + sysJob.setUpdateBy(SecurityUtils.getUser().getUsername()); + SysJob querySysJob = this.sysJobService.getById(sysJob.getJobId()); + if (PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(querySysJob.getJobStatus())) { + this.taskUtil.addOrUpateJob(sysJob, scheduler); + sysJobService.updateById(sysJob); + } + else if (PigxQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) { + sysJobService.updateById(sysJob); + } + return R.ok(); + } + + /** + * 通过id删除定时任务 + * @param id id + * @return R + */ + @SysLog("删除定时任务") + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('job_sys_job_del')") + @Operation(description = "唯一标识查询定时任务,暂停任务才能删除") + public R removeById(@PathVariable Long id) { + SysJob querySysJob = this.sysJobService.getById(id); + if (PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(querySysJob.getJobStatus())) { + this.taskUtil.removeJob(querySysJob, scheduler); + this.sysJobService.removeById(id); + } + else if (PigxQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) { + this.sysJobService.removeById(id); + } + return R.ok(); + } + + /** + * 暂停全部定时任务 + * @return + */ + @SysLog("暂停全部定时任务") + @PostMapping("/shutdown-jobs") + @PreAuthorize("@pms.hasPermission('job_sys_job_shutdown_job')") + @Operation(description = "暂停全部定时任务") + public R shutdownJobs() { + taskUtil.pauseJobs(scheduler); + long count = this.sysJobService.count( + new LambdaQueryWrapper().eq(SysJob::getJobStatus, PigxQuartzEnum.JOB_STATUS_RUNNING.getType())); + if (count <= 0) { + return R.ok("无正在运行定时任务"); + } + else { + // 更新定时任务状态条件,运行状态2更新为暂停状态2 + this.sysJobService.update( + SysJob.builder().jobStatus(PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType()).build(), + new UpdateWrapper().lambda() + .eq(SysJob::getJobStatus, PigxQuartzEnum.JOB_STATUS_RUNNING.getType())); + return R.ok("暂停成功"); + } + } + + /** + * 启动全部定时任务 + * @return + */ + @SysLog("启动全部定时任务") + @PostMapping("/start-jobs") + @PreAuthorize("@pms.hasPermission('job_sys_job_start_job')") + @Operation(description = "启动全部定时任务") + public R startJobs() { + // 更新定时任务状态条件,暂停状态3更新为运行状态2 + this.sysJobService.update(SysJob.builder().jobStatus(PigxQuartzEnum.JOB_STATUS_RUNNING.getType()).build(), + new UpdateWrapper().lambda() + .eq(SysJob::getJobStatus, PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType())); + taskUtil.startJobs(scheduler); + return R.ok(); + } + + /** + * 刷新全部定时任务 + * @return + */ + @SysLog("刷新全部定时任务") + @PostMapping("/refresh-jobs") + @PreAuthorize("@pms.hasPermission('job_sys_job_refresh_job')") + @Operation(description = "刷新全部定时任务") + public R refreshJobs() { + sysJobService.list().forEach((sysjob) -> { + if (PigxQuartzEnum.JOB_STATUS_RELEASE.getType().equals(sysjob.getJobStatus()) + || PigxQuartzEnum.JOB_STATUS_DEL.getType().equals(sysjob.getJobStatus())) { + taskUtil.removeJob(sysjob, scheduler); + } + else if (PigxQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus()) + || PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) { + taskUtil.addOrUpateJob(sysjob, scheduler); + } + else { + taskUtil.removeJob(sysjob, scheduler); + } + }); + return R.ok(); + } + + /** + * 启动定时任务 + * @param jobId + * @return + */ + @SysLog("启动定时任务") + @PostMapping("/start-job/{id}") + @PreAuthorize("@pms.hasPermission('job_sys_job_start_job')") + @Operation(description = "启动定时任务") + public R startJob(@PathVariable("id") Long jobId) { + SysJob querySysJob = this.sysJobService.getById(jobId); + if (querySysJob != null && PigxQuartzEnum.JOB_LOG_STATUS_FAIL.getType().equals(querySysJob.getJobStatus())) { + taskUtil.addOrUpateJob(querySysJob, scheduler); + } + else { + taskUtil.resumeJob(querySysJob, scheduler); + } + // 更新定时任务状态条件,暂停状态3更新为运行状态2 + this.sysJobService + .updateById(SysJob.builder().jobId(jobId).jobStatus(PigxQuartzEnum.JOB_STATUS_RUNNING.getType()).build()); + return R.ok(); + } + + /** + * 启动定时任务 + * @param jobId + * @return + */ + @SysLog("立刻执行定时任务") + @PostMapping("/run-job/{id}") + @PreAuthorize("@pms.hasPermission('job_sys_job_run_job')") + @Operation(description = "立刻执行定时任务") + public R runJob(@PathVariable("id") Long jobId) { + SysJob querySysJob = this.sysJobService.getById(jobId); + return TaskUtil.runOnce(scheduler, querySysJob) ? R.ok() : R.failed(); + } + + /** + * 暂停定时任务 + * @return + */ + @SysLog("暂停定时任务") + @PostMapping("/shutdown-job/{id}") + @PreAuthorize("@pms.hasPermission('job_sys_job_shutdown_job')") + @Operation(description = "暂停定时任务") + public R shutdownJob(@PathVariable("id") Long id) { + SysJob querySysJob = this.sysJobService.getById(id); + // 更新定时任务状态条件,运行状态2更新为暂停状态3 + this.sysJobService.updateById(SysJob.builder() + .jobId(querySysJob.getJobId()) + .jobStatus(PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType()) + .build()); + taskUtil.pauseJob(querySysJob, scheduler); + return R.ok(); + } + + /** + * 唯一标识查询定时执行日志 + * @return + */ + @GetMapping("/job-log") + @Operation(description = "唯一标识查询定时执行日志") + public R getJobLog(Page page, SysJobLog sysJobLog) { + return R.ok(sysJobLogService.page(page, Wrappers.query(sysJobLog))); + } + + /** + * 检验任务名称和任务组联合是否唯一 + * @return + */ + @GetMapping("/is-valid-task-name") + @Operation(description = "检验任务名称和任务组联合是否唯一") + public R isValidTaskName(@RequestParam String jobName, @RequestParam String jobGroup) { + return this.sysJobService + .count(Wrappers.query(SysJob.builder().jobName(jobName).jobGroup(jobGroup).build())) > 0 + ? R.failed("任务重复,请检查此组内是否已包含同名任务") : R.ok(); + } + + /** + * 导出任务 + * @param sysJob + * @return + */ + @ResponseExcel + @GetMapping("/export") + @Operation(description = "导出任务") + public List export(SysJob sysJob) { + return sysJobService.list(Wrappers.query(sysJob)); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/controller/SysJobLogController.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/controller/SysJobLogController.java new file mode 100644 index 00000000..4392f037 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/controller/SysJobLogController.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.controller; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; +import com.pig4cloud.pig.daemon.quartz.service.SysJobLogService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.*; + +/** + * @author frwcloud + *

+ * 定时任务执行日志表 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/sys-job-log") +@Tag(description = "sys-job-log", name = "定时任务日志") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SysJobLogController { + + private final SysJobLogService sysJobLogService; + + /** + * 分页查询 + * @param page 分页对象 + * @param sysJobLog 定时任务执行日志表 + * @return + */ + @GetMapping("/page") + @Operation(description = "分页定时任务日志查询") + public R getSysJobLogPage(Page page, SysJobLog sysJobLog) { + return R.ok(sysJobLogService.page(page, Wrappers.query(sysJobLog))); + } + + @DeleteMapping + @Operation(description = "批量删除日志") + public R deleteLogs(@RequestBody Long[] ids) { + return R.ok(sysJobLogService.removeBatchByIds(CollUtil.toList(ids))); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/entity/SysJob.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/entity/SysJob.java new file mode 100644 index 00000000..3d3ca844 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/entity/SysJob.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * 定时任务调度表 + * + * @author frwcloud + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(description = "定时任务") +public class SysJob extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 任务id + */ + @TableId(value = "job_id", type = IdType.ASSIGN_ID) + private Long jobId; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 任务组名 + */ + private String jobGroup; + + /** + * 组内执行顺利,值越大执行优先级越高,最大值9,最小值1 + */ + private String jobOrder; + + /** + * 1、java类;2、spring bean名称;3、rest调用;4、jar调用;9其他 + */ + private String jobType; + + /** + * job_type=3时,rest调用地址,仅支持rest get协议,需要增加String返回值,0成功,1失败;job_type=4时,jar路径;其它值为空 + */ + private String executePath; + + /** + * job_type=1时,类完整路径;job_type=2时,spring bean名称;其它值为空 + */ + private String className; + + /** + * 任务方法 + */ + private String methodName; + + /** + * 参数值 + */ + private String methodParamsValue; + + /** + * cron执行表达式 + */ + private String cronExpression; + + /** + * 错失执行策略(1错失周期立即执行 2错失周期执行一次 3下周期执行) + */ + private String misfirePolicy; + + /** + * 1、多租户任务;2、非多租户任务 + */ + private String jobTenantType; + + /** + * 状态(0、未发布;1、已发布;2、运行中;3、暂停;4、删除;) + */ + private String jobStatus; + + /** + * 状态(0正常 1异常) + */ + private String jobExecuteStatus; + + /** + * 创建者 + */ + @TableField(fill = FieldFill.INSERT) + private String createBy; + + /** + * 更新者 + */ + @TableField(fill = FieldFill.UPDATE) + private String updateBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + + /** + * 首次执行时间 + */ + private LocalDateTime startTime; + + /** + * 上次执行时间 + */ + private LocalDateTime previousTime; + + /** + * 下次执行时间 + */ + private LocalDateTime nextTime; + + /** + * 备注信息 + */ + private String remark; + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/entity/SysJobLog.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/entity/SysJobLog.java new file mode 100644 index 00000000..ba577f40 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/entity/SysJobLog.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * 定时任务执行日志表 + * + * @author frwcloud + * @date 2019-01-27 13:40:20 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(description = "定时任务日志") +public class SysJobLog extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 任务日志ID + */ + @TableId(value = "job_log_id", type = IdType.ASSIGN_ID) + private Long jobLogId; + + /** + * 任务id + */ + private Long jobId; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 任务组名 + */ + private String jobGroup; + + /** + * 组内执行顺利,值越大执行优先级越高,最大值9,最小值1 + */ + private String jobOrder; + + /** + * 1、java类;2、spring bean名称;3、rest调用;4、jar调用;9其他 + */ + private String jobType; + + /** + * job_type=3时,rest调用地址,仅支持post协议;job_type=4时,jar路径;其它值为空 + */ + private String executePath; + + /** + * job_type=1时,类完整路径;job_type=2时,spring bean名称;其它值为空 + */ + private String className; + + /** + * 任务方法 + */ + private String methodName; + + /** + * 参数值 + */ + private String methodParamsValue; + + /** + * cron执行表达式 + */ + private String cronExpression; + + /** + * 日志信息 + */ + private String jobMessage; + + /** + * 执行状态(0正常 1失败) + */ + private String jobLogStatus; + + /** + * 执行时间 + */ + private String executeTime; + + /** + * 异常信息 + */ + private String exceptionInfo; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 租户id + */ + private Long tenantId; + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobEvent.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobEvent.java new file mode 100644 index 00000000..981f91a9 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.event; + +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.quartz.Trigger; + +/** + * @author frwcloud 定时任务多线程事件 + */ +@Getter +@AllArgsConstructor +public class SysJobEvent { + + private final SysJob sysJob; + + private final Trigger trigger; + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobListener.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobListener.java new file mode 100644 index 00000000..27e41402 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobListener.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.event; + +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.util.TaskInvokUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.quartz.Trigger; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +/** + * @author frwcloud 异步监听定时任务事件 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class SysJobListener { + + private final TaskInvokUtil taskInvokUtil; + + @Async + @Order + @EventListener(SysJobEvent.class) + public void comSysJob(SysJobEvent event) { + SysJob sysJob = event.getSysJob(); + Trigger trigger = event.getTrigger(); + taskInvokUtil.invokMethod(sysJob, trigger); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobLogEvent.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobLogEvent.java new file mode 100644 index 00000000..0351d36b --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobLogEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.event; + +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author frwcloud 定时任务日志多线程事件 + */ +@Getter +@AllArgsConstructor +public class SysJobLogEvent { + + private final SysJobLog sysJobLog; + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobLogListener.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobLogListener.java new file mode 100644 index 00000000..e7f9c370 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/event/SysJobLogListener.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.event; + +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; +import com.pig4cloud.pig.daemon.quartz.service.SysJobLogService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +/** + * @author frwcloud 异步监听定时任务日志事件 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class SysJobLogListener { + + private final SysJobLogService sysJobLogService; + + @Async + @Order + @EventListener(SysJobLogEvent.class) + public void saveSysJobLog(SysJobLogEvent event) { + SysJobLog sysJobLog = event.getSysJobLog(); + sysJobLogService.save(sysJobLog); + log.info("执行定时任务日志"); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/exception/TaskException.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/exception/TaskException.java new file mode 100644 index 00000000..9ed8730f --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/exception/TaskException.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.exception; + +/** + * 定时任务异常 + * + * @author 郑健楠 + */ +public class TaskException extends Exception { + + public TaskException() { + super(); + } + + public TaskException(String msg) { + super(msg); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/mapper/SysJobLogMapper.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/mapper/SysJobLogMapper.java new file mode 100644 index 00000000..9a191498 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/mapper/SysJobLogMapper.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; +import org.apache.ibatis.annotations.Mapper; + +/** + * 定时任务执行日志表 + * + * @author frwcloud + * @date 2019-01-27 13:40:20 + */ +@Mapper +public interface SysJobLogMapper extends BaseMapper { + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/mapper/SysJobMapper.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/mapper/SysJobMapper.java new file mode 100644 index 00000000..ebb092d5 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/mapper/SysJobMapper.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import org.apache.ibatis.annotations.Mapper; + +/** + * 定时任务调度表 + * + * @author frwcloud + * @date 2019-01-27 10:04:42 + */ +@Mapper +public interface SysJobMapper extends BaseMapper { + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/SysJobLogService.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/SysJobLogService.java new file mode 100644 index 00000000..5539541b --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/SysJobLogService.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; + +/** + * 定时任务执行日志表 + * + * @author frwcloud + * @date 2019-01-27 13:40:20 + */ +public interface SysJobLogService extends IService { + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/SysJobService.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/SysJobService.java new file mode 100644 index 00000000..fd7e3ad2 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/SysJobService.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; + +/** + * 定时任务调度表 + * + * @author frwcloud + * @date 2019-01-27 10:04:42 + */ +public interface SysJobService extends IService { + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/impl/SysJobLogServiceImpl.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/impl/SysJobLogServiceImpl.java new file mode 100644 index 00000000..23093c5f --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/impl/SysJobLogServiceImpl.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; +import com.pig4cloud.pig.daemon.quartz.mapper.SysJobLogMapper; +import com.pig4cloud.pig.daemon.quartz.service.SysJobLogService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * 定时任务执行日志表 + * + * @author frwcloud + * @date 2019-01-27 13:40:20 + */ +@Slf4j +@Service +@AllArgsConstructor +public class SysJobLogServiceImpl extends ServiceImpl implements SysJobLogService { + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/impl/SysJobServiceImpl.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/impl/SysJobServiceImpl.java new file mode 100644 index 00000000..3ccdc261 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/service/impl/SysJobServiceImpl.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.mapper.SysJobMapper; +import com.pig4cloud.pig.daemon.quartz.service.SysJobService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * 定时任务调度表 + * + * @author frwcloud + * @date 2019-01-27 10:04:42 + */ +@Slf4j +@Service +@AllArgsConstructor +public class SysJobServiceImpl extends ServiceImpl implements SysJobService { + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/task/RestTaskDemo.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/task/RestTaskDemo.java new file mode 100644 index 00000000..188769da --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/task/RestTaskDemo.java @@ -0,0 +1,34 @@ +package com.pig4cloud.pig.daemon.quartz.task; + +import com.pig4cloud.pig.common.core.util.R; +import com.pig4cloud.pig.common.security.annotation.Inner; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalDateTime; + +/** + * 用于测试REST风格调用的demo + * + * @author lishangbu + * @date 2019/3/25 + */ +@Slf4j +@RestController +@RequestMapping("/inner-job") +public class RestTaskDemo { + + /** + * 测试REST风格调用定时任务的演示方法 + */ + @Inner(value = false) + @GetMapping("/{param}") + public R demoMethod(@PathVariable("param") String param) { + log.info("测试于:{},传入参数{}", LocalDateTime.now(), param); + return R.ok(); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/task/SpringBeanTaskDemo.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/task/SpringBeanTaskDemo.java new file mode 100644 index 00000000..040f778a --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/task/SpringBeanTaskDemo.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.task; + +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +/** + * @author 郑健楠 + */ +@Slf4j +@Component("demo") +public class SpringBeanTaskDemo { + + /** + * 测试Spring Bean的演示方法 + */ + @SneakyThrows + public String demoMethod(String para) { + log.info("测试于:{},输入参数{}", LocalDateTime.now(), para); + return PigxQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType(); + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/ITaskInvok.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/ITaskInvok.java new file mode 100644 index 00000000..8db5e563 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/ITaskInvok.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.util; + +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.exception.TaskException; + +/** + * 定时任务反射实现接口类 + * + * @author 郑健楠 + */ +public interface ITaskInvok { + + /** + * 执行反射方法 + * @param sysJob 配置类 + * @throws TaskException + */ + void invokMethod(SysJob sysJob) throws TaskException; + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/JarTaskInvok.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/JarTaskInvok.java new file mode 100644 index 00000000..87c49c3a --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/JarTaskInvok.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.util; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.exception.TaskException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * 定时任务可执行jar反射实现 + * + * @author 郑健楠 + */ +@Slf4j +@Component("jarTaskInvok") +public class JarTaskInvok implements ITaskInvok { + + @Override + public void invokMethod(SysJob sysJob) throws TaskException { + ProcessBuilder processBuilder = new ProcessBuilder(); + File jar = new File(sysJob.getExecutePath()); + processBuilder.directory(jar.getParentFile()); + List commands = new ArrayList<>(); + commands.add("java"); + commands.add("-jar"); + commands.add(sysJob.getExecutePath()); + if (StrUtil.isNotEmpty(sysJob.getMethodParamsValue())) { + commands.add(sysJob.getMethodParamsValue()); + } + processBuilder.command(commands); + try { + processBuilder.start(); + } + catch (IOException e) { + log.error("定时任务jar反射执行异常,执行任务:{}", sysJob.getExecutePath()); + throw new TaskException("定时任务jar反射执行异常,执行任务:" + sysJob.getExecutePath()); + } + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/JavaClassTaskInvok.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/JavaClassTaskInvok.java new file mode 100644 index 00000000..2d6a9736 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/JavaClassTaskInvok.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.util; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.exception.TaskException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * 定时任务java class反射实现 + * + * @author 郑健楠 + */ +@Component("javaClassTaskInvok") +@Slf4j +public class JavaClassTaskInvok implements ITaskInvok { + + @Override + public void invokMethod(SysJob sysJob) throws TaskException { + Object obj; + Class clazz; + Method method; + Object returnValue; + try { + if (StrUtil.isNotEmpty(sysJob.getMethodParamsValue())) { + clazz = Class.forName(sysJob.getClassName()); + obj = clazz.newInstance(); + method = clazz.getDeclaredMethod(sysJob.getMethodName(), String.class); + returnValue = method.invoke(obj, sysJob.getMethodParamsValue()); + } + else { + clazz = Class.forName(sysJob.getClassName()); + obj = clazz.newInstance(); + method = clazz.getDeclaredMethod(sysJob.getMethodName()); + returnValue = method.invoke(obj); + } + if (StrUtil.isEmpty(returnValue.toString()) + || PigxQuartzEnum.JOB_LOG_STATUS_FAIL.getType().equals(returnValue.toString())) { + log.error("定时任务javaClassTaskInvok异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务javaClassTaskInvok业务执行失败,任务:" + sysJob.getClassName()); + } + } + catch (ClassNotFoundException e) { + log.error("定时任务java反射类没有找到,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务java反射类没有找到,执行任务:" + sysJob.getClassName()); + } + catch (IllegalAccessException e) { + log.error("定时任务java反射类异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务java反射类异常,执行任务:" + sysJob.getClassName()); + } + catch (InstantiationException e) { + log.error("定时任务java反射类异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务java反射类异常,执行任务:" + sysJob.getClassName()); + } + catch (NoSuchMethodException e) { + log.error("定时任务java反射执行方法名异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务java反射执行方法名异常,执行任务:" + sysJob.getClassName()); + } + catch (InvocationTargetException e) { + log.error("定时任务java反射执行异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务java反射执行异常,执行任务:" + sysJob.getClassName()); + } + + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/RestTaskInvok.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/RestTaskInvok.java new file mode 100644 index 00000000..e4536cfc --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/RestTaskInvok.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.util; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.exception.TaskException; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 定时任务rest反射实现 + * + * @author 郑健楠 + */ +@Slf4j +@AllArgsConstructor +@Component("restTaskInvok") +public class RestTaskInvok implements ITaskInvok { + + @Override + public void invokMethod(SysJob sysJob) throws TaskException { + try { + HttpRequest request = HttpUtil.createGet(sysJob.getExecutePath()); + request.execute(); + } + catch (Exception e) { + log.error("定时任务restTaskInvok异常,执行任务:{}", sysJob.getExecutePath()); + throw new TaskException("定时任务restTaskInvok业务执行失败,任务:" + sysJob.getExecutePath()); + } + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/SpringBeanTaskInvok.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/SpringBeanTaskInvok.java new file mode 100644 index 00000000..0ba538d9 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/SpringBeanTaskInvok.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.util; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pig.common.core.util.SpringContextHolder; +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.exception.TaskException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * 定时任务spring bean反射实现 + * + * @author 郑健楠 + */ +@Component("springBeanTaskInvok") +@Slf4j +public class SpringBeanTaskInvok implements ITaskInvok { + + @Override + public void invokMethod(SysJob sysJob) throws TaskException { + Object target; + Method method; + Object returnValue; + // 通过Spring上下文去找 也有可能找不到 + target = SpringContextHolder.getBean(sysJob.getClassName()); + try { + if (StrUtil.isNotEmpty(sysJob.getMethodParamsValue())) { + method = target.getClass().getDeclaredMethod(sysJob.getMethodName(), String.class); + ReflectionUtils.makeAccessible(method); + returnValue = method.invoke(target, sysJob.getMethodParamsValue()); + } + else { + method = target.getClass().getDeclaredMethod(sysJob.getMethodName()); + ReflectionUtils.makeAccessible(method); + returnValue = method.invoke(target); + } + if (StrUtil.isEmpty(returnValue.toString()) + || PigxQuartzEnum.JOB_LOG_STATUS_FAIL.getType().equals(returnValue.toString())) { + log.error("定时任务springBeanTaskInvok异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务springBeanTaskInvok业务执行失败,任务:" + sysJob.getClassName()); + } + } + catch (NoSuchMethodException e) { + log.error("定时任务spring bean反射异常方法未找到,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务spring bean反射异常方法未找到,执行任务:" + sysJob.getClassName()); + } + catch (IllegalAccessException e) { + log.error("定时任务spring bean反射异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务spring bean反射异常,执行任务:" + sysJob.getClassName()); + } + catch (InvocationTargetException e) { + log.error("定时任务spring bean反射执行异常,执行任务:{}", sysJob.getClassName()); + throw new TaskException("定时任务spring bean反射执行异常,执行任务:" + sysJob.getClassName()); + } + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskInvokFactory.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskInvokFactory.java new file mode 100644 index 00000000..0d0ae0df --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskInvokFactory.java @@ -0,0 +1,50 @@ +package com.pig4cloud.pig.daemon.quartz.util; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pig.common.core.util.SpringContextHolder; +import com.pig4cloud.pig.daemon.quartz.constants.JobTypeQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.exception.TaskException; +import lombok.extern.slf4j.Slf4j; + +/** + * @author Hccake + * @version 1.0 + * @date 2019/8/8 15:40 TaskInvok工厂类 + */ +@Slf4j +public class TaskInvokFactory { + + /** + * 根据对应jobType获取对应 invoker + * @param jobType + * @return + * @throws TaskException + */ + public static ITaskInvok getInvoker(String jobType) throws TaskException { + if (StrUtil.isBlank(jobType)) { + log.info("获取TaskInvok传递参数有误,jobType:{}", jobType); + throw new TaskException(""); + } + + ITaskInvok iTaskInvok = null; + if (JobTypeQuartzEnum.JAVA.getType().equals(jobType)) { + iTaskInvok = SpringContextHolder.getBean("javaClassTaskInvok"); + } + else if (JobTypeQuartzEnum.SPRING_BEAN.getType().equals(jobType)) { + iTaskInvok = SpringContextHolder.getBean("springBeanTaskInvok"); + } + else if (JobTypeQuartzEnum.REST.getType().equals(jobType)) { + iTaskInvok = SpringContextHolder.getBean("restTaskInvok"); + } + else if (JobTypeQuartzEnum.JAR.getType().equals(jobType)) { + iTaskInvok = SpringContextHolder.getBean("jarTaskInvok"); + } + else if (StrUtil.isBlank(jobType)) { + log.info("定时任务类型无对应反射方式,反射类型:{}", jobType); + throw new TaskException(""); + } + + return iTaskInvok; + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskInvokUtil.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskInvokUtil.java new file mode 100644 index 00000000..e71650bf --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskInvokUtil.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.util; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import com.pig4cloud.pig.daemon.quartz.entity.SysJobLog; +import com.pig4cloud.pig.daemon.quartz.event.SysJobLogEvent; +import com.pig4cloud.pig.daemon.quartz.service.SysJobService; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.quartz.CronTrigger; +import org.quartz.Trigger; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Component; + +import java.time.ZoneId; +import java.util.Date; + +/** + * 定时任务反射工具类 + * + * @author 郑健楠 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class TaskInvokUtil { + + private final ApplicationEventPublisher publisher; + + private final SysJobService sysJobService; + + @SneakyThrows + public void invokMethod(SysJob sysJob, Trigger trigger) { + + // 执行开始时间 + long startTime; + // 执行结束时间 + long endTime; + // 获取执行开始时间 + startTime = System.currentTimeMillis(); + // 更新定时任务表内的状态、执行时间、上次执行时间、下次执行时间等信息 + SysJob updateSysjob = new SysJob(); + updateSysjob.setJobId(sysJob.getJobId()); + // 日志 + SysJobLog sysJobLog = new SysJobLog(); + sysJobLog.setJobId(sysJob.getJobId()); + sysJobLog.setJobName(sysJob.getJobName()); + sysJobLog.setJobGroup(sysJob.getJobGroup()); + sysJobLog.setJobOrder(sysJob.getJobOrder()); + sysJobLog.setJobType(sysJob.getJobType()); + sysJobLog.setExecutePath(sysJob.getExecutePath()); + sysJobLog.setClassName(sysJob.getClassName()); + sysJobLog.setMethodName(sysJob.getMethodName()); + sysJobLog.setMethodParamsValue(sysJob.getMethodParamsValue()); + sysJobLog.setCronExpression(sysJob.getCronExpression()); + try { + // 执行任务 + ITaskInvok iTaskInvok = TaskInvokFactory.getInvoker(sysJob.getJobType()); + // 确保租户上下文有值,使得当前线程中的多租户特性生效。 + iTaskInvok.invokMethod(sysJob); + // 记录成功状态 + sysJobLog.setJobMessage(PigxQuartzEnum.JOB_LOG_STATUS_SUCCESS.getDescription()); + sysJobLog.setJobLogStatus(PigxQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType()); + // 任务表信息更新 + updateSysjob.setJobExecuteStatus(PigxQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType()); + } + catch (Throwable e) { + log.error("定时任务执行失败,任务名称:{};任务组名:{},cron执行表达式:{},执行时间:{}", sysJob.getJobName(), sysJob.getJobGroup(), + sysJob.getCronExpression(), new Date()); + // 记录失败状态 + sysJobLog.setJobMessage(PigxQuartzEnum.JOB_LOG_STATUS_FAIL.getDescription()); + sysJobLog.setJobLogStatus(PigxQuartzEnum.JOB_LOG_STATUS_FAIL.getType()); + sysJobLog.setExceptionInfo(StrUtil.sub(e.getMessage(), 0, 2000)); + // 任务表信息更新 + updateSysjob.setJobExecuteStatus(PigxQuartzEnum.JOB_LOG_STATUS_FAIL.getType()); + } + finally { + // 记录执行时间 立刻执行使用的是simpleTeigger + if (trigger instanceof CronTrigger) { + updateSysjob + .setStartTime(trigger.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); + updateSysjob.setPreviousTime( + trigger.getPreviousFireTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); + updateSysjob.setNextTime( + trigger.getNextFireTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); + } + // 记录执行时长 + endTime = System.currentTimeMillis(); + sysJobLog.setExecuteTime(String.valueOf(endTime - startTime)); + + publisher.publishEvent(new SysJobLogEvent(sysJobLog)); + sysJobService.updateById(updateSysjob); + } + } + +} diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskUtil.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskUtil.java new file mode 100644 index 00000000..34a02832 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/util/TaskUtil.java @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.daemon.quartz.util; + +import com.pig4cloud.pig.daemon.quartz.config.PigxQuartzFactory; +import com.pig4cloud.pig.daemon.quartz.constants.PigxQuartzEnum; +import com.pig4cloud.pig.daemon.quartz.entity.SysJob; +import lombok.extern.slf4j.Slf4j; +import org.quartz.*; +import org.springframework.stereotype.Component; + +/** + * 定时任务的工具类 + * + * @author 郑健楠 + */ +@Slf4j +@Component +public class TaskUtil { + + /** + * 获取定时任务的唯一key + * @param sysjob + * @return + */ + public static JobKey getJobKey(SysJob sysjob) { + return JobKey.jobKey(sysjob.getJobName(), sysjob.getJobGroup()); + } + + /** + * 获取定时任务触发器cron的唯一key + * @param sysjob + * @return + */ + public static TriggerKey getTriggerKey(SysJob sysjob) { + return TriggerKey.triggerKey(sysjob.getJobName(), sysjob.getJobGroup()); + } + + /** + * 添加或更新定时任务 + * @param sysjob + * @param scheduler + */ + public void addOrUpateJob(SysJob sysjob, Scheduler scheduler) { + CronTrigger trigger = null; + try { + JobKey jobKey = getJobKey(sysjob); + // 获得触发器 + TriggerKey triggerKey = getTriggerKey(sysjob); + trigger = (CronTrigger) scheduler.getTrigger(triggerKey); + // 判断触发器是否存在(如果存在说明之前运行过但是在当前被禁用了,如果不存在说明一次都没运行过) + if (trigger == null) { + // 新建一个工作任务 指定任务类型为串接进行的 + JobDetail jobDetail = JobBuilder.newJob(PigxQuartzFactory.class).withIdentity(jobKey).build(); + // 将任务信息添加到任务信息中 + jobDetail.getJobDataMap().put(PigxQuartzEnum.SCHEDULE_JOB_KEY.getType(), sysjob); + // 将cron表达式进行转换 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(sysjob.getCronExpression()); + cronScheduleBuilder = this.handleCronScheduleMisfirePolicy(sysjob, cronScheduleBuilder); + // 创建触发器并将cron表达式对象给塞入 + trigger = TriggerBuilder.newTrigger() + .withIdentity(triggerKey) + .withSchedule(cronScheduleBuilder) + .build(); + // 在调度器中将触发器和任务进行组合 + scheduler.scheduleJob(jobDetail, trigger); + } + else { + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(sysjob.getCronExpression()); + cronScheduleBuilder = this.handleCronScheduleMisfirePolicy(sysjob, cronScheduleBuilder); + // 按照新的规则进行 + trigger = trigger.getTriggerBuilder() + .withIdentity(triggerKey) + .withSchedule(cronScheduleBuilder) + .build(); + // 将任务信息更新到任务信息中 + trigger.getJobDataMap().put(PigxQuartzEnum.SCHEDULE_JOB_KEY.getType(), sysjob); + // 重启 + scheduler.rescheduleJob(triggerKey, trigger); + } + // 如任务状态为暂停 + if (sysjob.getJobStatus().equals(PigxQuartzEnum.JOB_STATUS_NOT_RUNNING.getType())) { + this.pauseJob(sysjob, scheduler); + } + } + catch (SchedulerException e) { + log.error("添加或更新定时任务,失败信息:{}", e.getMessage()); + } + } + + /** + * 立即执行一次任务 + */ + public static boolean runOnce(Scheduler scheduler, SysJob sysJob) { + try { + // 参数 + JobDataMap dataMap = new JobDataMap(); + dataMap.put(PigxQuartzEnum.SCHEDULE_JOB_KEY.getType(), sysJob); + + scheduler.triggerJob(getJobKey(sysJob), dataMap); + } + catch (SchedulerException e) { + log.error("立刻执行定时任务,失败信息:{}", e.getMessage()); + return false; + } + + return true; + } + + /** + * 暂停定时任务 + * @param sysjob + * @param scheduler + */ + public void pauseJob(SysJob sysjob, Scheduler scheduler) { + try { + if (scheduler != null) { + scheduler.pauseJob(getJobKey(sysjob)); + } + } + catch (SchedulerException e) { + log.error("暂停任务失败,失败信息:{}", e.getMessage()); + } + + } + + /** + * 恢复定时任务 + * @param sysjob + * @param scheduler + */ + public void resumeJob(SysJob sysjob, Scheduler scheduler) { + try { + if (scheduler != null) { + scheduler.resumeJob(getJobKey(sysjob)); + } + } + catch (SchedulerException e) { + log.error("恢复任务失败,失败信息:{}", e.getMessage()); + } + + } + + /** + * 移除定时任务 + * @param sysjob + * @param scheduler + */ + public void removeJob(SysJob sysjob, Scheduler scheduler) { + try { + if (scheduler != null) { + // 停止触发器 + scheduler.pauseTrigger(getTriggerKey(sysjob)); + // 移除触发器 + scheduler.unscheduleJob(getTriggerKey(sysjob)); + // 删除任务 + scheduler.deleteJob(getJobKey(sysjob)); + } + } + catch (Exception e) { + log.error("移除定时任务失败,失败信息:{}", e.getMessage()); + } + } + + /** + * 启动所有运行定时任务 + * @param scheduler + */ + public void startJobs(Scheduler scheduler) { + try { + if (scheduler != null) { + scheduler.resumeAll(); + } + } + catch (SchedulerException e) { + log.error("启动所有运行定时任务失败,失败信息:{}", e.getMessage()); + } + } + + /** + * 停止所有运行定时任务 + * @param scheduler + */ + public void pauseJobs(Scheduler scheduler) { + try { + if (scheduler != null) { + scheduler.pauseAll(); + } + } + catch (Exception e) { + log.error("暂停所有运行定时任务失败,失败信息:{}", e.getMessage()); + } + } + + /** + * 获取错失执行策略方法 + * @param sysJob + * @param cronScheduleBuilder + * @return + */ + private CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob sysJob, + CronScheduleBuilder cronScheduleBuilder) { + if (PigxQuartzEnum.MISFIRE_DEFAULT.getType().equals(sysJob.getMisfirePolicy())) { + return cronScheduleBuilder; + } + else if (PigxQuartzEnum.MISFIRE_IGNORE_MISFIRES.getType().equals(sysJob.getMisfirePolicy())) { + return cronScheduleBuilder.withMisfireHandlingInstructionIgnoreMisfires(); + } + else if (PigxQuartzEnum.MISFIRE_FIRE_AND_PROCEED.getType().equals(sysJob.getMisfirePolicy())) { + return cronScheduleBuilder.withMisfireHandlingInstructionFireAndProceed(); + } + else if (PigxQuartzEnum.MISFIRE_DO_NOTHING.getType().equals(sysJob.getMisfirePolicy())) { + return cronScheduleBuilder.withMisfireHandlingInstructionDoNothing(); + } + else { + return cronScheduleBuilder; + } + } + + /** + * 判断cron表达式是否正确 + * @param cronExpression + * @return + */ + public boolean isValidCron(String cronExpression) { + return CronExpression.isValidExpression(cronExpression); + } + +} diff --git a/pig-visual/pig-quartz/src/main/resources/application.yml b/pig-visual/pig-quartz/src/main/resources/application.yml new file mode 100644 index 00000000..8202ed48 --- /dev/null +++ b/pig-visual/pig-quartz/src/main/resources/application.yml @@ -0,0 +1,22 @@ +server: + port: 5007 + +spring: + application: + name: @artifactId@ + cloud: + nacos: + discovery: + server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848} + config: + server-addr: ${spring.cloud.nacos.discovery.server-addr} + config: + import: + - optional:nacos:application-@profiles.active@.yml + - optional:nacos:${spring.application.name}-@profiles.active@.yml + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: root + url: jdbc:mysql://pig-mysql:3306/pig_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true diff --git a/pig-visual/pig-quartz/src/main/resources/logback-spring.xml b/pig-visual/pig-quartz/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..08958f2b --- /dev/null +++ b/pig-visual/pig-quartz/src/main/resources/logback-spring.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${log.path}/debug.log + + ${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + + + + ${log.path}/error.log + + ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + ERROR + + + + + + + + + + + + + + + + + + diff --git a/pig-visual/pom.xml b/pig-visual/pom.xml index 634ec699..df384fe8 100755 --- a/pig-visual/pom.xml +++ b/pig-visual/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.6.4 + 3.7.0-SNAPSHOT pig-visual @@ -32,5 +32,6 @@ pig-codegen pig-monitor + pig-quartz diff --git a/pom.xml b/pom.xml index 547ebe59..cae1c44e 100755 --- a/pom.xml +++ b/pom.xml @@ -22,21 +22,23 @@ com.pig4cloud pig ${project.artifactId} - 3.6.4 + 3.7.0-SNAPSHOT pom https://www.pig4cloud.com - 3.1.0 - 2022.0.2 + 3.1.1 + 2022.0.3 2022.0.0.0-RC2 UTF-8 17 17 - 3.0.4 - 1.1.0 - 3.6.1 + 3.1.0 + 1.1.1 + 4.0.0 + 0.0.3 2.2.2 + 1.11.543 2.3 3.1 1.10 @@ -52,6 +54,7 @@ password 6.0.0 0.0.39 + 3.11.0 @@ -197,6 +200,17 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + false + + -parameters + + + io.github.git-commit-id