Merge branch 'master' of https://gitee.com/youlaiorg/youlai-boot into feature/noticews
# Conflicts: # sql/mysql5/youlai_boot.sql # src/main/java/com/youlai/boot/module/websocket/service/MessageService.java # src/main/java/com/youlai/boot/module/websocket/service/WebsocketService.java # src/main/java/com/youlai/boot/module/websocket/service/impl/WebsocketServiceImpl.java # src/main/java/com/youlai/boot/system/service/impl/UserServiceImpl.java
This commit is contained in:
commit
fa77b5cb8c
71 files changed
+1040
-1066
No files matched your search
@@ -3,7 +3,7 @@
|
||||
<img alt="logo" width="100" height="100" src="https://foruda.gitee.com/images/1724259461244885014/4de96569_716974.png">
|
||||
<h2>youlai-boot</h2>
|
||||
<img alt="有来技术" src="https://img.shields.io/badge/Java -17-brightgreen.svg"/>
|
||||
<img alt="有来技术" src="https://img.shields.io/badge/SpringBoot-3.3.0-green.svg"/>
|
||||
<img alt="有来技术" src="https://img.shields.io/badge/SpringBoot-3.3.2-green.svg"/>
|
||||
<a href="https://gitee.com/youlaiorg/youlai-boot" target="_blank">
|
||||
<img alt="有来技术" src="https://gitee.com/youlaiorg/youlai-boot/badge/star.svg"/>
|
||||
</a>
|
||||
@@ -65,7 +65,7 @@ youlai-boot
|
||||
│ │ ├── WebMvcConfig # WebMvc 配置
|
||||
│ │ ├── WebSocketConfig # WebSocket 自动装配配置
|
||||
│ │ └── XxlJobConfig # XXL-JOB 自动装配配置
|
||||
│ ├── core # 核心功能模块
|
||||
│ ├── core # 核心功能
|
||||
│ │ ├── aspect # 切面
|
||||
│ │ │ ├── LogAspect # 日志切面
|
||||
│ │ │ └── RepeatSubmitAspect # 防重提交切面
|
||||
@@ -76,12 +76,12 @@ youlai-boot
|
||||
│ │ │ ├── MyDataPermissionHandler # 数据权限处理器
|
||||
│ │ │ └── MyMetaObjectHandler # 元对象字段填充处理器
|
||||
│ │ └── security # Security 安全中心
|
||||
│ ├── platform # 平台基础设施模块
|
||||
│ │ ├── auth # 授权
|
||||
│ │ ├── file # 文件处理
|
||||
│ │ ├── generator # 代码生成器
|
||||
│ │ ├── mail # 邮件处理
|
||||
│ │ └── sms # 短信处理
|
||||
│ ├── module # 公共模块
|
||||
│ │ ├── auth # 认证模块
|
||||
│ │ ├── file # 文件模块
|
||||
│ │ ├── generator # 代码生成模块
|
||||
│ │ ├── mail # 邮件模块
|
||||
│ │ └── sms # 短信模块
|
||||
│ ├── system # 系统模块
|
||||
│ │ ├── controller # 控制层
|
||||
│ │ ├── converter # MapStruct 转换器
|
||||
|
||||
@@ -109,11 +109,6 @@
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
||||
+235
-331
@@ -1,139 +1,61 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : 本地数据库
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 50744 (5.7.44)
|
||||
Source Host : localhost:3306
|
||||
Source Schema : youlai_boot
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 50744 (5.7.44)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 27/08/2024 16:44:13
|
||||
* youlai_boot 权限系统数据库(MySQL5.x)
|
||||
* @author youlai
|
||||
* @date 2024/06/24
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
-- ----------------------------
|
||||
-- 1. 创建数据库
|
||||
-- ----------------------------
|
||||
CREATE DATABASE IF NOT EXISTS youlai_boot DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- 2. 创建表 && 数据初始化
|
||||
-- ----------------------------
|
||||
use youlai_boot;
|
||||
|
||||
SET NAMES utf8;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for gen_config
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `gen_config`;
|
||||
CREATE TABLE `gen_config` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`table_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '表名',
|
||||
`module_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模块名',
|
||||
`package_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '包名',
|
||||
`business_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务名',
|
||||
`entity_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '实体类名',
|
||||
`author` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '作者',
|
||||
`parent_menu_id` bigint(20) NULL DEFAULT NULL COMMENT '上级菜单ID,对应sys_menu的id ',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_tablename_deleted`(`table_name`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '代码生成基础配置表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of gen_config
|
||||
-- ----------------------------
|
||||
INSERT INTO `gen_config` VALUES (1, 'sys_notice_status', 'system', 'com.youlai', '用户公告状态', 'NoticeStatus', 'youlaitech', 1, '2024-08-24 13:38:48', '2024-08-24 13:38:48');
|
||||
INSERT INTO `gen_config` VALUES (2, 'sys_notice', 'system', 'com.youlai', '通知公告', 'Notice', 'youlaitech', 1, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for gen_field_config
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `gen_field_config`;
|
||||
CREATE TABLE `gen_field_config` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`config_id` bigint(20) NOT NULL COMMENT '关联的配置ID',
|
||||
`column_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`column_type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`max_length` int(11) NULL DEFAULT NULL COMMENT '最大长度',
|
||||
`field_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字段名称',
|
||||
`field_type` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字段类型',
|
||||
`field_sort` int(11) NULL DEFAULT NULL COMMENT '字段排序',
|
||||
`field_comment` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字段描述',
|
||||
`is_required` tinyint(1) NULL DEFAULT NULL COMMENT '是否必填',
|
||||
`is_show_in_list` tinyint(1) NULL DEFAULT 0 COMMENT '是否在列表显示',
|
||||
`is_show_in_form` tinyint(1) NULL DEFAULT 0 COMMENT '是否在表单显示',
|
||||
`is_show_in_query` tinyint(1) NULL DEFAULT 0 COMMENT '是否在查询条件显示',
|
||||
`query_type` tinyint(4) NULL DEFAULT NULL COMMENT '查询方式',
|
||||
`form_type` tinyint(4) NULL DEFAULT NULL COMMENT '表单类型',
|
||||
`dict_type` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典类型(sys_dict表的code)',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '代码生成字段配置表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of gen_field_config
|
||||
-- ----------------------------
|
||||
INSERT INTO `gen_field_config` VALUES (1, 1, 'id', 'bigint', NULL, 'id', 'Long', 1, 'id', 0, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48');
|
||||
INSERT INTO `gen_field_config` VALUES (2, 1, 'notice_id', 'bigint', NULL, 'noticeId', 'Long', 2, '公共通知id', 0, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48');
|
||||
INSERT INTO `gen_field_config` VALUES (3, 1, 'user_id', 'int', NULL, 'userId', 'Integer', 3, '用户id', 0, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48');
|
||||
INSERT INTO `gen_field_config` VALUES (4, 1, 'read_status', 'bigint', NULL, 'readStatus', 'Long', 4, '读取状态,0未读,1已读取', 1, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48');
|
||||
INSERT INTO `gen_field_config` VALUES (5, 1, 'read_tiem', 'datetime', NULL, 'readTiem', 'LocalDateTime', 5, '用户阅读时间', 1, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48');
|
||||
INSERT INTO `gen_field_config` VALUES (6, 2, 'id', 'bigint', NULL, 'id', 'Long', 1, '', 0, 1, 1, 0, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (7, 2, 'title', 'varchar', 50, 'title', 'String', 2, '通知标题', 1, 1, 1, 1, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (8, 2, 'content', 'text', 65535, 'content', 'String', 3, '通知内容', 1, 1, 1, 1, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (9, 2, 'notice_type', 'int', NULL, 'noticeType', 'Integer', 4, '通知类型', 0, 1, 1, 1, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (10, 2, 'release', 'bigint', NULL, 'release', 'Long', 5, '发布人', 1, 1, 1, 1, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (11, 2, 'priority', 'tinyint', NULL, 'priority', 'Integer', 6, '优先级(0-低 1-中 2-高)', 0, 1, 1, 1, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (12, 2, 'tar_type', 'tinyint', NULL, 'tarType', 'Integer', 7, '目标类型(0-全体 1-指定)', 0, 1, 1, 1, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (13, 2, 'send_status', 'tinyint', NULL, 'sendStatus', 'Integer', 8, '发布状态(0-未发布 1已发布 2已撤回)', 0, 1, 1, 1, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (14, 2, 'send_time', 'datetime', NULL, 'sendTime', 'LocalDateTime', 9, '发布时间', 1, 1, 1, 1, 4, 9, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (15, 2, 'recall_time', 'datetime', NULL, 'recallTime', 'LocalDateTime', 10, '撤回时间', 1, 1, 1, 1, 4, 9, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (16, 2, 'create_by', 'bigint', NULL, 'createBy', 'Long', 11, '创建人ID', 0, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (17, 2, 'create_time', 'datetime', NULL, 'createTime', 'LocalDateTime', 12, '创建时间', 0, 1, 0, 0, 4, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (18, 2, 'update_by', 'bigint', NULL, 'updateBy', 'Long', 13, '更新人ID', 1, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (19, 2, 'update_time', 'datetime', NULL, 'updateTime', 'LocalDateTime', 14, '更新时间', 1, 1, 0, 0, 4, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
INSERT INTO `gen_field_config` VALUES (20, 2, 'is_delete', 'tinyint', NULL, 'isDelete', 'Integer', 15, '逻辑删除标识(0-未删除 1-已删除)', 0, 0, 0, 0, 1, 1, NULL, '2024-08-24 13:39:03', '2024-08-27 10:30:57');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_config
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_config`;
|
||||
CREATE TABLE `sys_config` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`config_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '配置名称',
|
||||
`config_key` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '配置key',
|
||||
`config_value` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '配置值',
|
||||
`remark` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述、备注',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`create_by` bigint(20) NOT NULL COMMENT '创建人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人ID',
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统配置' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_config
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_config` VALUES (1, 'IP请求限制QPS阈值', 'IP_QPS_THRESHOLD_LIMIT', '10', 'IP请求限制QPS阈值', '2024-08-10 14:31:34', 2, '2024-08-10 14:53:51', 2, 0);
|
||||
CREATE TABLE `sys_config` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`config_name` varchar(50) NOT NULL COMMENT '配置名称',
|
||||
`config_key` varchar(50) NOT NULL COMMENT '配置key',
|
||||
`config_value` varchar(100) NOT NULL COMMENT '配置值',
|
||||
`remark` varchar(200) DEFAULT NULL COMMENT '描述、备注',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`create_by` bigint NOT NULL COMMENT '创建人ID',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
|
||||
`is_deleted` tinyint(1) NOT NULL COMMENT '逻辑删除标识(0-未删除 1-已删除)',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB COMMENT='系统配置';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_dept
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_dept`;
|
||||
CREATE TABLE `sys_dept` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '部门名称',
|
||||
`code` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '部门编号',
|
||||
`parent_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '父节点id',
|
||||
`tree_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '父节点id路径',
|
||||
`sort` smallint(6) NULL DEFAULT 0 COMMENT '显示顺序',
|
||||
`status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态(1-正常 0-禁用)',
|
||||
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '修改人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(1-已删除 0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_code`(`code`) USING BTREE COMMENT '部门编号唯一索引'
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '部门名称',
|
||||
`code` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '部门编号',
|
||||
`parent_id` bigint NOT NULL DEFAULT 0 COMMENT '父节点id',
|
||||
`tree_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '父节点id路径',
|
||||
`sort` smallint NULL DEFAULT 0 COMMENT '显示顺序',
|
||||
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(1-正常 0-禁用)',
|
||||
`create_by` bigint NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` bigint NULL DEFAULT NULL COMMENT '修改人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(1-已删除 0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_code`(`code` ASC) USING BTREE COMMENT '部门编号唯一索引'
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '部门表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
@@ -148,17 +70,17 @@ INSERT INTO `sys_dept` VALUES (3, '测试部门', 'QA001', 1, '0,1', 1, 1, 2, NU
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_dict`;
|
||||
CREATE TABLE `sys_dict` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键 ',
|
||||
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型名称',
|
||||
`code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型编码',
|
||||
`status` tinyint(1) NULL DEFAULT 0 COMMENT '状态(0:正常;1:禁用)',
|
||||
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint(4) NULL DEFAULT 0 COMMENT '是否删除(1-删除,0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_code`(`code`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典类型表' ROW_FORMAT = DYNAMIC;
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键 ',
|
||||
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型名称',
|
||||
`code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '类型编码',
|
||||
`status` tinyint(1) NULL DEFAULT 0 COMMENT '状态(0:正常;1:禁用)',
|
||||
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint NULL DEFAULT 0 COMMENT '是否删除(1-删除,0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_code`(`code` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 89 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典类型表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_dict
|
||||
@@ -170,17 +92,17 @@ INSERT INTO `sys_dict` VALUES (1, '性别', 'gender', 1, NULL, '2019-12-06 19:03
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_dict_item`;
|
||||
CREATE TABLE `sys_dict_item` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`dict_id` bigint(20) NULL DEFAULT NULL COMMENT '字典ID',
|
||||
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项名称',
|
||||
`value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项值',
|
||||
`status` tinyint(4) NULL DEFAULT 0 COMMENT '状态(1-正常,0-禁用)',
|
||||
`sort` int(11) NULL DEFAULT 0 COMMENT '排序',
|
||||
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典数据表' ROW_FORMAT = DYNAMIC;
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`dict_id` bigint NULL DEFAULT NULL COMMENT '字典ID',
|
||||
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项名称',
|
||||
`value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项值',
|
||||
`status` tinyint NULL DEFAULT 0 COMMENT '状态(1-正常,0-禁用)',
|
||||
`sort` int NULL DEFAULT 0 COMMENT '排序',
|
||||
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 70 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典数据表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_dict_item
|
||||
@@ -194,82 +116,59 @@ INSERT INTO `sys_dict_item` VALUES (3, 1, '保密', '0', 1, 3, NULL, '2020-10-17
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_log`;
|
||||
CREATE TABLE `sys_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`module` enum('LOGIN','USER','ROLE','DEPT','MENU','DICT','OTHER') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '日志模块',
|
||||
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '日志内容',
|
||||
`request_uri` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求路径',
|
||||
`ip` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'IP地址',
|
||||
`province` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '省份',
|
||||
`city` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '城市',
|
||||
`execution_time` bigint(20) NULL DEFAULT NULL COMMENT '执行时间(ms)',
|
||||
`browser` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '浏览器',
|
||||
`browser_version` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '浏览器版本',
|
||||
`os` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '终端系统',
|
||||
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`is_deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(1-已删除 0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统日志表' ROW_FORMAT = DYNAMIC;
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`type` tinyint NULL DEFAULT NULL COMMENT '日志类型(1-操作日志 2-登录日志)',
|
||||
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '日志标题',
|
||||
`ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'IP地址',
|
||||
`content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '日志内容',
|
||||
`create_by` bigint NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` bigint NULL DEFAULT NULL COMMENT '修改人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(1-已删除 0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统日志' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_log
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_log` VALUES (1, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 176, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:38:33', 0);
|
||||
INSERT INTO `sys_log` VALUES (2, 'OTHER', '生成代码', '/api/v1/generator/sys_notice_status/config', '192.168.2.34', '0', '内网IP', 340, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:38:48', 0);
|
||||
INSERT INTO `sys_log` VALUES (3, 'OTHER', '预览生成代码', '/api/v1/generator/sys_notice_status/preview', '192.168.2.34', '0', '内网IP', 492, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:38:49', 0);
|
||||
INSERT INTO `sys_log` VALUES (4, 'OTHER', '生成代码', '/api/v1/generator/sys_notice/config', '192.168.2.34', '0', '内网IP', 234, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:39:03', 0);
|
||||
INSERT INTO `sys_log` VALUES (5, 'OTHER', '预览生成代码', '/api/v1/generator/sys_notice/preview', '192.168.2.34', '0', '内网IP', 66, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:39:04', 0);
|
||||
INSERT INTO `sys_log` VALUES (6, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 12, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:39:07', 0);
|
||||
INSERT INTO `sys_log` VALUES (7, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 7, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:39:15', 0);
|
||||
INSERT INTO `sys_log` VALUES (8, 'ROLE', '角色分页列表', '/api/v1/roles/page', '192.168.2.34', '0', '内网IP', 7, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:39:23', 0);
|
||||
INSERT INTO `sys_log` VALUES (9, 'ROLE', '角色分页列表', '/api/v1/roles/page', '192.168.2.34', '0', '内网IP', 7, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:39:33', 0);
|
||||
INSERT INTO `sys_log` VALUES (10, 'ROLE', '角色分页列表', '/api/v1/roles/page', '192.168.2.34', '0', '内网IP', 5, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 2, '2024-08-24 13:39:36', 0);
|
||||
INSERT INTO `sys_log` VALUES (11, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 44, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:52:17', 0);
|
||||
INSERT INTO `sys_log` VALUES (12, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 12, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:52:27', 0);
|
||||
INSERT INTO `sys_log` VALUES (13, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 14, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:52:29', 0);
|
||||
INSERT INTO `sys_log` VALUES (14, 'OTHER', '预览生成代码', '/api/v1/generator/sys_notice_status/preview', '192.168.2.34', '0', '内网IP', 624, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:52:32', 0);
|
||||
INSERT INTO `sys_log` VALUES (15, 'OTHER', '下载代码', '/api/v1/generator/sys_notice_status/download', '192.168.2.34', '0', '内网IP', 93, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:53:01', 0);
|
||||
INSERT INTO `sys_log` VALUES (16, 'OTHER', '预览生成代码', '/api/v1/generator/sys_notice/preview', '192.168.2.34', '0', '内网IP', 67, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:53:09', 0);
|
||||
INSERT INTO `sys_log` VALUES (17, 'OTHER', '下载代码', '/api/v1/generator/sys_notice/download', '192.168.2.34', '0', '内网IP', 51, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:53:11', 0);
|
||||
INSERT INTO `sys_log` VALUES (18, 'ROLE', '角色分页列表', '/api/v1/roles/page', '192.168.2.34', '0', '内网IP', 7, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:53:31', 0);
|
||||
INSERT INTO `sys_log` VALUES (19, 'ROLE', '角色分页列表', '/api/v1/roles/page', '192.168.2.34', '0', '内网IP', 6, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 09:53:40', 0);
|
||||
INSERT INTO `sys_log` VALUES (20, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 32, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:25:20', 0);
|
||||
INSERT INTO `sys_log` VALUES (21, 'OTHER', '预览生成代码', '/api/v1/generator/sys_notice/preview', '192.168.2.34', '0', '内网IP', 214, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:25:23', 0);
|
||||
INSERT INTO `sys_log` VALUES (22, 'LOGIN', '登录', '/api/v1/auth/login', '192.168.2.34', '0', '内网IP', 941, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:29:30', 0);
|
||||
INSERT INTO `sys_log` VALUES (23, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 43, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:29:31', 0);
|
||||
INSERT INTO `sys_log` VALUES (24, 'OTHER', '预览生成代码', '/api/v1/generator/sys_notice/preview', '192.168.2.34', '0', '内网IP', 211, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:29:36', 0);
|
||||
INSERT INTO `sys_log` VALUES (25, 'OTHER', '生成代码', '/api/v1/generator/sys_notice/config', '192.168.2.34', '0', '内网IP', 168, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:30:57', 0);
|
||||
INSERT INTO `sys_log` VALUES (26, 'OTHER', '预览生成代码', '/api/v1/generator/sys_notice/preview', '192.168.2.34', '0', '内网IP', 102, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:30:57', 0);
|
||||
INSERT INTO `sys_log` VALUES (27, 'OTHER', '下载代码', '/api/v1/generator/sys_notice/download', '192.168.2.34', '0', '内网IP', 68, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:31:05', 0);
|
||||
INSERT INTO `sys_log` VALUES (28, 'OTHER', '代码生成分页列表', '/api/v1/generator/table/page', '192.168.2.34', '0', '内网IP', 55, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 10:54:53', 0);
|
||||
INSERT INTO `sys_log` VALUES (29, 'LOGIN', '登录', '/api/v1/auth/login', '192.168.2.34', '0', '内网IP', 283, 'MSEdge', '128.0.0.0', 'Windows 10 or Windows Server 2016', 2, '2024-08-27 13:55:37', 0);
|
||||
INSERT INTO `sys_log` VALUES (30, 'LOGIN', '登录', '/api/v1/auth/login', '192.168.2.34', '0', '内网IP', 121, 'QQBrowser', '13.0.6069.400', 'Windows 10 or Windows Server 2016', 1, '2024-08-27 13:56:26', 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_menu
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_menu`;
|
||||
CREATE TABLE `sys_menu` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`parent_id` bigint(20) NOT NULL COMMENT '父菜单ID',
|
||||
`tree_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父节点ID路径',
|
||||
`name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '菜单名称',
|
||||
`type` tinyint(4) NOT NULL COMMENT '菜单类型(1-菜单 2-目录 3-外链 4-按钮)',
|
||||
`route_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '路由名称(Vue Router 中用于命名路由)',
|
||||
`route_path` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '路由路径(Vue Router 中定义的 URL 路径)',
|
||||
`component` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '组件路径(组件页面完整路径,相对于 src/views/,缺省后缀 .vue)',
|
||||
`perm` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '【按钮】权限标识',
|
||||
`always_show` tinyint(4) NULL DEFAULT NULL COMMENT '【目录】只有一个子路由是否始终显示(1-是 0-否)',
|
||||
`keep_alive` tinyint(4) NULL DEFAULT NULL COMMENT '【菜单】是否开启页面缓存(1-是 0-否)',
|
||||
`visible` tinyint(1) NOT NULL DEFAULT 1 COMMENT '显示状态(1-显示 0-隐藏)',
|
||||
`sort` int(11) NULL DEFAULT 0 COMMENT '排序',
|
||||
`icon` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '菜单图标',
|
||||
`redirect` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '跳转路径',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`params` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '路由参数',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 136 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '菜单管理' ROW_FORMAT = DYNAMIC;
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`parent_id` bigint NOT NULL COMMENT '父菜单ID',
|
||||
`tree_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父节点ID路径',
|
||||
`name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '菜单名称',
|
||||
`type` tinyint NOT NULL COMMENT '菜单类型(1-菜单 2-目录 3-外链 4-按钮)',
|
||||
`route_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '路由名称(Vue Router 中用于命名路由)',
|
||||
`route_path` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '路由路径(Vue Router 中定义的 URL 路径)',
|
||||
`component` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '组件路径(组件页面完整路径,相对于 src/views/,缺省后缀 .vue)',
|
||||
`perm` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '【按钮】权限标识',
|
||||
`always_show` tinyint NULL DEFAULT 0 COMMENT '【目录】只有一个子路由是否始终显示(1-是 0-否)',
|
||||
`keep_alive` tinyint NULL DEFAULT 0 COMMENT '【菜单】是否开启页面缓存(1-是 0-否)',
|
||||
`visible` tinyint(1) NOT NULL DEFAULT 1 COMMENT '显示状态(1-显示 0-隐藏)',
|
||||
`sort` int NULL DEFAULT 0 COMMENT '排序',
|
||||
`icon` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '菜单图标',
|
||||
`redirect` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '跳转路径',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`params` text NULL COMMENT '路由参数',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 117 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '菜单管理' ROW_FORMAT = DYNAMIC;
|
||||
`always_show` tinyint NULL DEFAULT 0 COMMENT '【目录】只有一个子路由是否始终显示(1-是 0-否)',
|
||||
`keep_alive` tinyint NULL DEFAULT 0 COMMENT '【菜单】是否开启页面缓存(1-是 0-否)',
|
||||
`visible` tinyint(1) NOT NULL DEFAULT 1 COMMENT '显示状态(1-显示 0-隐藏)',
|
||||
`sort` int NULL DEFAULT 0 COMMENT '排序',
|
||||
`icon` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '菜单图标',
|
||||
`redirect` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '跳转路径',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`params` text NULL COMMENT '路由参数',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 117 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '菜单管理' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_menu
|
||||
@@ -327,108 +226,49 @@ INSERT INTO `sys_menu` VALUES (110, 0, '0', '路由参数', 2, NULL, '/route-par
|
||||
INSERT INTO `sys_menu` VALUES (111, 110, '0,110', '参数(type=1)', 1, NULL, 'route-param-type1', 'demo/route-param', NULL, 0, 1, 1, 1, 'el-icon-Star', NULL, '2024-05-26 21:59:24', '2024-05-26 21:59:37', '{\"type\": \"1\"}');
|
||||
INSERT INTO `sys_menu` VALUES (112, 110, '0,110', '参数(type=2)', 1, NULL, 'route-param-type2', 'demo/route-param', NULL, 0, 1, 1, 2, 'el-icon-StarFilled', NULL, '2024-05-26 21:46:55', '2024-05-26 21:59:45', '{\"type\": \"2\"}');
|
||||
INSERT INTO `sys_menu` VALUES (117, 1, '0,1', '系统日志', 1, 'Log', 'log', 'system/log/index', NULL, 0, 1, 1, 6, 'document', NULL, '2024-06-28 07:43:16', '2024-06-28 07:43:16', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (118, 0, '0', '系统工具', 2, NULL, '/generator', 'Layout', NULL, 0, 1, 1, 2, 'menu', NULL, '2024-07-13 08:41:07', '2024-07-13 08:41:07', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (119, 118, '0,118', '代码生成(Alpha)', 1, 'Generator', 'generator', 'generator/index', NULL, 0, 1, 1, 1, 'code', NULL, '2024-07-13 08:44:51', '2024-07-13 08:44:51', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (120, 1, '0,1', '系统配置', 1, 'Config', 'config', 'system/config/index', NULL, 0, 1, 1, 7, 'setting', NULL, '2024-07-30 16:29:24', '2024-07-30 16:29:32', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (121, 120, '0,1,120', '查询系统配置', 4, NULL, '', NULL, 'sys:config:query', 0, 1, 1, 1, '', NULL, '2024-07-30 16:29:54', '2024-07-30 16:29:54', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (122, 120, '0,1,120', '新增系统配置', 4, NULL, '', NULL, 'sys:config:add', 0, 1, 1, 2, '', NULL, '2024-07-30 16:30:12', '2024-07-30 16:30:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (123, 120, '0,1,120', '修改系统配置', 4, NULL, '', NULL, 'sys:config:update', 0, 1, 1, 3, '', NULL, '2024-07-30 16:30:31', '2024-07-30 16:30:31', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (124, 120, '0,1,120', '删除系统配置', 4, NULL, '', NULL, 'sys:config:delete', 0, 1, 1, 4, '', NULL, '2024-07-30 16:31:07', '2024-07-30 16:31:07', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (125, 120, '0,1,120', '刷新系统配置', 4, NULL, '', NULL, 'sys:config:refresh', 0, 1, 1, 5, '', NULL, '2024-07-30 16:31:25', '2024-07-30 16:31:25', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (126, 1, '0,1', '用户公告状态', 1, 'NoticeStatus', 'notice-status', 'system/notice-status/index', NULL, NULL, NULL, 1, 8, '', NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (127, 126, '0,1,127', '查询', 4, NULL, '', NULL, 'system:noticeStatus:query', NULL, NULL, 1, 1, '', NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (128, 126, '0,1,128', '新增', 4, NULL, '', NULL, 'system:noticeStatus:add', NULL, NULL, 1, 2, '', NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (129, 126, '0,1,129', '编辑', 4, NULL, '', NULL, 'system:noticeStatus:edit', NULL, NULL, 1, 3, '', NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (130, 126, '0,1,130', '删除', 4, NULL, '', NULL, 'system:noticeStatus:delete', NULL, NULL, 1, 4, '', NULL, '2024-08-24 13:38:48', '2024-08-24 13:38:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (131, 1, '0,1', '通知公告', 1, 'Notice', 'notice', 'system/notice/index', NULL, NULL, NULL, 1, 9, '', NULL, '2024-08-24 13:39:03', '2024-08-24 13:39:03', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (132, 131, '0,1,132', '查询', 4, NULL, '', NULL, 'system:notice:query', NULL, NULL, 1, 1, '', NULL, '2024-08-24 13:39:03', '2024-08-24 13:39:03', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (133, 131, '0,1,133', '新增', 4, NULL, '', NULL, 'system:notice:add', NULL, NULL, 1, 2, '', NULL, '2024-08-24 13:39:03', '2024-08-24 13:39:03', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (134, 131, '0,1,134', '编辑', 4, NULL, '', NULL, 'system:notice:edit', NULL, NULL, 1, 3, '', NULL, '2024-08-24 13:39:03', '2024-08-24 13:39:03', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (135, 131, '0,1,135', '删除', 4, NULL, '', NULL, 'system:notice:delete', NULL, NULL, 1, 4, '', NULL, '2024-08-24 13:39:03', '2024-08-24 13:39:03', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (118, 0, '0', '系统工具', 2, NULL, '/codegen', 'Layout', NULL, 0, 1, 1, 2, 'menu', NULL, '2024-07-13 08:41:07', '2024-07-13 08:41:07', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (119, 118, '0,118', '代码生成', 1, 'Codegen', 'codegen', 'codegen/index', NULL, 0, 1, 1, 1, 'code', NULL, '2024-07-13 08:44:51', '2024-07-13 08:44:51', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (118, 0, '0', '系统工具', 2, NULL, '/codegen', 'Layout', NULL, 0, 1, 1, 2, 'menu', NULL, '2024-07-13 08:41:07', '2024-07-13 08:41:07', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (119, 118, '0,118', '代码生成', 1, 'Codegen', 'codegen', 'codegen/index', NULL, 0, 1, 1, 1, 'code', NULL, '2024-07-13 08:44:51', '2024-07-13 08:44:51', NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_message
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_message`;
|
||||
CREATE TABLE `sys_message` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '修改人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(1-已删除 0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统消息' ROW_FORMAT = DYNAMIC;
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`create_by` bigint NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` bigint NULL DEFAULT NULL COMMENT '修改人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(1-已删除 0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统消息' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_message
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_notice
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_notice`;
|
||||
CREATE TABLE `sys_notice` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通知标题',
|
||||
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '通知内容',
|
||||
`notice_type` int(11) NOT NULL COMMENT '通知类型',
|
||||
`release_by` bigint(20) NULL DEFAULT NULL COMMENT '发布人',
|
||||
`priority` tinyint(4) NOT NULL COMMENT '优先级(0-低 1-中 2-高)',
|
||||
`tar_type` tinyint(4) NOT NULL COMMENT '目标类型(0-全体 1-指定)',
|
||||
`send_status` tinyint(4) NOT NULL COMMENT '发布状态(0-未发布 1已发布 2已撤回)',
|
||||
`send_time` datetime NULL DEFAULT NULL COMMENT '发布时间',
|
||||
`recall_time` datetime NULL DEFAULT NULL COMMENT '撤回时间',
|
||||
`create_by` bigint(20) NOT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '通知公告' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_notice
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_notice` VALUES (1, '11', '1', 1, 2, 1, 1, 2, '2024-08-27 11:20:38', '2024-08-27 11:20:39', 2, '2024-08-27 11:22:03', 2, '2024-08-27 11:27:01', 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_notice_status
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_notice_status`;
|
||||
CREATE TABLE `sys_notice_status` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`notice_id` bigint(20) NOT NULL COMMENT '公共通知id',
|
||||
`user_id` int(11) NOT NULL COMMENT '用户id',
|
||||
`read_status` bigint(4) NULL DEFAULT NULL COMMENT '读取状态,0未读,1已读取',
|
||||
`read_tiem` datetime NULL DEFAULT NULL COMMENT '用户阅读时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户公告状态表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_notice_status
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_role
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_role`;
|
||||
CREATE TABLE `sys_role` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '角色名称',
|
||||
`code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色编码',
|
||||
`sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序',
|
||||
`status` tinyint(1) NULL DEFAULT 1 COMMENT '角色状态(1-正常 0-停用)',
|
||||
`data_scope` tinyint(4) NULL DEFAULT NULL COMMENT '数据权限(0-所有数据 1-部门及子部门数据 2-本部门数据3-本人数据)',
|
||||
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人 ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_name`(`name`) USING BTREE COMMENT '角色名称唯一索引',
|
||||
UNIQUE INDEX `uk_code`(`code`) USING BTREE COMMENT '角色编码唯一索引'
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色表' ROW_FORMAT = DYNAMIC;
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '角色名称',
|
||||
`code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色编码',
|
||||
`sort` int NULL DEFAULT NULL COMMENT '显示顺序',
|
||||
`status` tinyint(1) NULL DEFAULT 1 COMMENT '角色状态(1-正常 0-停用)',
|
||||
`data_scope` tinyint NULL DEFAULT NULL COMMENT '数据权限(0-所有数据 1-部门及子部门数据 2-本部门数据3-本人数据)',
|
||||
`create_by` bigint NULL DEFAULT NULL COMMENT '创建人 ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`update_by` bigint NULL DEFAULT NULL COMMENT '更新人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_name`(`name` ASC) USING BTREE COMMENT '角色名称唯一索引',
|
||||
UNIQUE INDEX `uk_code`(`code` ASC) USING BTREE COMMENT '角色编码唯一索引'
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 128 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_role
|
||||
@@ -451,9 +291,9 @@ INSERT INTO `sys_role` VALUES (12, '系统管理员9', 'ADMIN9', 12, 1, 1, NULL,
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_role_menu`;
|
||||
CREATE TABLE `sys_role_menu` (
|
||||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
`menu_id` bigint(20) NOT NULL COMMENT '菜单ID',
|
||||
UNIQUE INDEX `uk_roleid_menuid`(`role_id`, `menu_id`) USING BTREE COMMENT '角色菜单唯一索引'
|
||||
`role_id` bigint NOT NULL COMMENT '角色ID',
|
||||
`menu_id` bigint NOT NULL COMMENT '菜单ID',
|
||||
UNIQUE INDEX `uk_roleid_menuid`(`role_id` ASC, `menu_id` ASC) USING BTREE COMMENT '角色菜单唯一索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色和菜单关联表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
@@ -511,44 +351,35 @@ INSERT INTO `sys_role_menu` VALUES (2, 109);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 110);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 111);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 112);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 114);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 115);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 116);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 117);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 118);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 119);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 120);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 121);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 122);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 123);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 124);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 125);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 131);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 132);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 133);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 134);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 135);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_user
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_user`;
|
||||
CREATE TABLE `sys_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名',
|
||||
`nickname` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称',
|
||||
`gender` tinyint(1) NULL DEFAULT 1 COMMENT '性别((1-男 2-女 0-保密)',
|
||||
`password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
|
||||
`dept_id` int(11) NULL DEFAULT NULL COMMENT '部门ID',
|
||||
`avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户头像',
|
||||
`mobile` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系方式',
|
||||
`status` tinyint(1) NULL DEFAULT 1 COMMENT '状态((1-正常 0-禁用)',
|
||||
`email` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户邮箱',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '修改人ID',
|
||||
`is_deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `login_name`(`username`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名',
|
||||
`nickname` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称',
|
||||
`gender` tinyint(1) NULL DEFAULT 1 COMMENT '性别((1-男 2-女 0-保密)',
|
||||
`password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
|
||||
`dept_id` int NULL DEFAULT NULL COMMENT '部门ID',
|
||||
`avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户头像',
|
||||
`mobile` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系方式',
|
||||
`status` tinyint(1) NULL DEFAULT 1 COMMENT '状态((1-正常 0-禁用)',
|
||||
`email` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户邮箱',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`create_by` bigint NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`update_by` bigint NULL DEFAULT NULL COMMENT '修改人ID',
|
||||
`is_deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `login_name`(`username` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 288 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_user
|
||||
@@ -562,10 +393,10 @@ INSERT INTO `sys_user` VALUES (3, 'test', '测试小用户', 1, '$2a$10$xVWsNOhH
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_user_role`;
|
||||
CREATE TABLE `sys_user_role` (
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
PRIMARY KEY (`user_id`, `role_id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_userid_roleid`(`user_id`, `role_id`) USING BTREE COMMENT '用户角色唯一索引'
|
||||
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||||
`role_id` bigint NOT NULL COMMENT '角色ID',
|
||||
PRIMARY KEY (`user_id`, `role_id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_userid_roleid`(`user_id` ASC, `role_id` ASC) USING BTREE COMMENT '用户角色唯一索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户和角色关联表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
@@ -575,4 +406,77 @@ INSERT INTO `sys_user_role` VALUES (1, 1);
|
||||
INSERT INTO `sys_user_role` VALUES (2, 2);
|
||||
INSERT INTO `sys_user_role` VALUES (3, 3);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_log`;
|
||||
CREATE TABLE `sys_log` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`module` enum('LOGIN','USER','ROLE','DEPT','MENU','DICT','OTHER') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '日志模块',
|
||||
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '日志内容',
|
||||
`request_uri` varchar(255) COLLATE utf8_general_ci DEFAULT NULL COMMENT '请求路径',
|
||||
`ip` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'IP地址',
|
||||
`province` varchar(100) COLLATE utf8_general_ci DEFAULT NULL COMMENT '省份',
|
||||
`city` varchar(100) COLLATE utf8_general_ci DEFAULT NULL COMMENT '城市',
|
||||
`execution_time` bigint DEFAULT NULL COMMENT '执行时间(ms)',
|
||||
`browser` varchar(100) COLLATE utf8_general_ci DEFAULT NULL COMMENT '浏览器',
|
||||
`browser_version` varchar(100) COLLATE utf8_general_ci DEFAULT NULL COMMENT '浏览器版本',
|
||||
`os` varchar(100) COLLATE utf8_general_ci DEFAULT NULL COMMENT '终端系统',
|
||||
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT '逻辑删除标识(1-已删除 0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='系统日志表';
|
||||
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for gen_config
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `gen_config`;
|
||||
CREATE TABLE `gen_config` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`table_name` varchar(100) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '表名',
|
||||
`module_name` varchar(100) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '模块名',
|
||||
`package_name` varchar(255) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '包名',
|
||||
`business_name` varchar(100) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '业务名',
|
||||
`entity_name` varchar(100) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '实体类名',
|
||||
`author` varchar(50) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '作者',
|
||||
`parent_menu_id` bigint DEFAULT NULL COMMENT '上级菜单ID,对应sys_menu的id ',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_tablename` (`table_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='代码生成基础配置表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for gen_field_config
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `gen_field_config`;
|
||||
CREATE TABLE `gen_field_config` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`config_id` bigint NOT NULL COMMENT '关联的配置ID',
|
||||
`column_name` varchar(100) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
|
||||
`column_type` varchar(50) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
|
||||
`column_length` int DEFAULT NULL,
|
||||
`field_name` varchar(100) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '字段名称',
|
||||
`field_type` varchar(100) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '字段类型',
|
||||
`field_sort` int DEFAULT NULL COMMENT '字段排序',
|
||||
`field_comment` varchar(255) CHARACTER SET utf8 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '字段描述',
|
||||
`max_length` int NULL DEFAULT NULL,
|
||||
`is_required` tinyint(1) DEFAULT NULL COMMENT '是否必填',
|
||||
`is_show_in_list` tinyint(1) DEFAULT '0' COMMENT '是否在列表显示',
|
||||
`is_show_in_form` tinyint(1) DEFAULT '0' COMMENT '是否在表单显示',
|
||||
`is_show_in_query` tinyint(1) DEFAULT '0' COMMENT '是否在查询条件显示',
|
||||
`query_type` tinyint DEFAULT NULL COMMENT '查询方式',
|
||||
`form_type` tinyint DEFAULT NULL COMMENT '表单类型',
|
||||
`dict_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '字典类型',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `config_id` (`config_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='代码生成字段配置表';
|
||||
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -148,8 +148,8 @@ CREATE TABLE `sys_menu` (
|
||||
`route_path` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '路由路径(Vue Router 中定义的 URL 路径)',
|
||||
`component` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件路径(组件页面完整路径,相对于 src/views/,缺省后缀 .vue)',
|
||||
`perm` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '【按钮】权限标识',
|
||||
`always_show` tinyint NULL DEFAULT NULL COMMENT '【目录】只有一个子路由是否始终显示(1-是 0-否)',
|
||||
`keep_alive` tinyint NULL DEFAULT NULL COMMENT '【菜单】是否开启页面缓存(1-是 0-否)',
|
||||
`always_show` tinyint NULL DEFAULT 0 COMMENT '【目录】只有一个子路由是否始终显示(1-是 0-否)',
|
||||
`keep_alive` tinyint NULL DEFAULT 0 COMMENT '【菜单】是否开启页面缓存(1-是 0-否)',
|
||||
`visible` tinyint(1) NOT NULL DEFAULT 1 COMMENT '显示状态(1-显示 0-隐藏)',
|
||||
`sort` int NULL DEFAULT 0 COMMENT '排序',
|
||||
`icon` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '菜单图标',
|
||||
@@ -216,8 +216,8 @@ INSERT INTO `sys_menu` VALUES (110, 0, '0', '路由参数', 2, NULL, '/route-par
|
||||
INSERT INTO `sys_menu` VALUES (111, 110, '0,110', '参数(type=1)', 1, NULL, 'route-param-type1', 'demo/route-param', NULL, 0, 1, 1, 1, 'el-icon-Star', NULL, '2024-05-26 21:59:24', '2024-05-26 21:59:37', '{\"type\": \"1\"}');
|
||||
INSERT INTO `sys_menu` VALUES (112, 110, '0,110', '参数(type=2)', 1, NULL, 'route-param-type2', 'demo/route-param', NULL, 0, 1, 1, 2, 'el-icon-StarFilled', NULL, '2024-05-26 21:46:55', '2024-05-26 21:59:45', '{\"type\": \"2\"}');
|
||||
INSERT INTO `sys_menu` VALUES (117, 1, '0,1', '系统日志', 1, 'Log', 'log', 'system/log/index', NULL, 0, 1, 1, 6, 'document', NULL, '2024-06-28 07:43:16', '2024-06-28 07:43:16', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (118, 0, '0', '系统工具', 2, NULL, '/generator', 'Layout', NULL, 0, 1, 1, 2, 'menu', NULL, '2024-07-13 08:41:07', '2024-07-13 08:41:07', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (119, 118, '0,118', '代码生成(Alpha)', 1, 'Generator', 'generator', 'generator/index', NULL, 0, 1, 1, 1, 'code', NULL, '2024-07-13 08:44:51', '2024-07-13 08:44:51', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (118, 0, '0', '系统工具', 2, NULL, '/codegen', 'Layout', NULL, 0, 1, 1, 2, 'menu', NULL, '2024-07-13 08:41:07', '2024-07-13 08:41:07', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (119, 118, '0,118', '代码生成', 1, 'Codegen', 'codegen', 'codegen/index', NULL, 0, 1, 1, 1, 'code', NULL, '2024-07-13 08:44:51', '2024-07-13 08:44:51', NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_message
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 环境枚举
|
||||
*
|
||||
* @author Ray
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@Getter
|
||||
public enum EnvEnum implements IBaseEnum<String> {
|
||||
|
||||
DEV("dev", "开发环境"),
|
||||
PROD("prod", "生产环境");
|
||||
|
||||
private final String value;
|
||||
|
||||
private final String label;
|
||||
|
||||
EnvEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class CaptchaConfig {
|
||||
} else if ("random".equalsIgnoreCase(codeType)) {
|
||||
return new RandomGenerator(codeLength);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid captcha generator type: " + codeType);
|
||||
throw new IllegalArgumentException("Invalid captcha codegen type: " + codeType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -16,9 +16,9 @@ import java.util.Map;
|
||||
* @since 2.11.0
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "generator")
|
||||
@ConfigurationProperties(prefix = "codegen")
|
||||
@Data
|
||||
public class GeneratorProperties {
|
||||
public class CodegenProperties {
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ public class GeneratorProperties {
|
||||
public static class TemplateConfig {
|
||||
|
||||
/**
|
||||
* 模板路径 (e.g. /templates/generator/controller.java.vm)
|
||||
* 模板路径 (e.g. /templates/codegen/controller.java.vm)
|
||||
*/
|
||||
private String templatePath;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.youlai.boot.platform.auth.controller;
|
||||
package com.youlai.boot.module.auth.controller;
|
||||
|
||||
import com.youlai.boot.common.enums.LogModuleEnum;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.platform.auth.service.AuthService;
|
||||
import com.youlai.boot.module.auth.service.AuthService;
|
||||
import com.youlai.boot.system.model.dto.CaptchaResult;
|
||||
import com.youlai.boot.system.model.dto.LoginResult;
|
||||
import com.youlai.boot.common.annotation.Log;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.auth.service;
|
||||
package com.youlai.boot.module.auth.service;
|
||||
|
||||
import com.youlai.boot.system.model.dto.CaptchaResult;
|
||||
import com.youlai.boot.system.model.dto.LoginResult;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.auth.service.impl;
|
||||
package com.youlai.boot.module.auth.service.impl;
|
||||
|
||||
import cn.hutool.captcha.AbstractCaptcha;
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
@@ -10,7 +10,7 @@ import cn.hutool.jwt.JWTPayload;
|
||||
import cn.hutool.jwt.JWTUtil;
|
||||
import com.youlai.boot.common.constant.SecurityConstants;
|
||||
import com.youlai.boot.common.enums.CaptchaTypeEnum;
|
||||
import com.youlai.boot.platform.auth.service.AuthService;
|
||||
import com.youlai.boot.module.auth.service.AuthService;
|
||||
import com.youlai.boot.system.model.dto.CaptchaResult;
|
||||
import com.youlai.boot.system.model.dto.LoginResult;
|
||||
import com.youlai.boot.config.property.CaptchaProperties;
|
||||
+34
-27
@@ -1,22 +1,24 @@
|
||||
package com.youlai.boot.platform.generator.controller;
|
||||
package com.youlai.boot.module.codegen.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.common.result.PageResult;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.config.property.GeneratorProperties;
|
||||
import com.youlai.boot.config.property.CodegenProperties;
|
||||
import com.youlai.boot.common.enums.LogModuleEnum;
|
||||
import com.youlai.boot.platform.generator.service.GeneratorService;
|
||||
import com.youlai.boot.platform.generator.model.form.GenConfigForm;
|
||||
import com.youlai.boot.platform.generator.model.query.TablePageQuery;
|
||||
import com.youlai.boot.platform.generator.model.vo.GeneratorPreviewVO;
|
||||
import com.youlai.boot.platform.generator.model.vo.TablePageVO;
|
||||
import com.youlai.boot.module.codegen.service.CodegenService;
|
||||
import com.youlai.boot.module.codegen.model.form.GenConfigForm;
|
||||
import com.youlai.boot.module.codegen.model.query.TablePageQuery;
|
||||
import com.youlai.boot.module.codegen.model.vo.CodegenPreviewVO;
|
||||
import com.youlai.boot.module.codegen.model.vo.TablePageVO;
|
||||
import com.youlai.boot.common.annotation.Log;
|
||||
import com.youlai.boot.module.codegen.service.GenConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -32,12 +34,14 @@ import java.util.List;
|
||||
*/
|
||||
@Tag(name = "09.代码生成")
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/generator")
|
||||
@RequestMapping("/api/v1/codegen")
|
||||
@RequiredArgsConstructor
|
||||
public class GeneratorController {
|
||||
@Slf4j
|
||||
public class CodegenController {
|
||||
|
||||
private final GeneratorService generatorService;
|
||||
private final GeneratorProperties generatorProperties;
|
||||
private final CodegenService codegenService;
|
||||
private final GenConfigService genConfigService;
|
||||
private final CodegenProperties codegenProperties;
|
||||
|
||||
@Operation(summary = "获取数据表分页列表")
|
||||
@GetMapping("/table/page")
|
||||
@@ -45,7 +49,7 @@ public class GeneratorController {
|
||||
public PageResult<TablePageVO> getTablePage(
|
||||
TablePageQuery queryParams
|
||||
) {
|
||||
Page<TablePageVO> result = generatorService.getTablePage(queryParams);
|
||||
Page<TablePageVO> result = codegenService.getTablePage(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@@ -54,7 +58,7 @@ public class GeneratorController {
|
||||
public Result<GenConfigForm> getGenConfigFormData(
|
||||
@Parameter(description = "表名", example = "sys_user") @PathVariable String tableName
|
||||
) {
|
||||
GenConfigForm formData = generatorService.getGenConfigFormData(tableName);
|
||||
GenConfigForm formData = genConfigService.getGenConfigFormData(tableName);
|
||||
return Result.success(formData);
|
||||
}
|
||||
|
||||
@@ -62,7 +66,7 @@ public class GeneratorController {
|
||||
@PostMapping("/{tableName}/config")
|
||||
@Log(value = "生成代码", module = LogModuleEnum.OTHER)
|
||||
public Result<?> saveGenConfig(@RequestBody GenConfigForm formData) {
|
||||
generatorService.saveGenConfig(formData);
|
||||
genConfigService.saveGenConfig(formData);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@@ -71,32 +75,35 @@ public class GeneratorController {
|
||||
public Result<?> deleteGenConfig(
|
||||
@Parameter(description = "表名", example = "sys_user") @PathVariable String tableName
|
||||
) {
|
||||
generatorService.deleteGenConfig(tableName);
|
||||
genConfigService.deleteGenConfig(tableName);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取预览生成代码")
|
||||
@GetMapping("/{tableName}/preview")
|
||||
@Log(value = "预览生成代码", module = LogModuleEnum.OTHER)
|
||||
public Result<List<GeneratorPreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
||||
List<GeneratorPreviewVO> list = generatorService.getTablePreviewData(tableName);
|
||||
public Result<List<CodegenPreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
||||
List<CodegenPreviewVO> list = codegenService.getCodegenPreviewData(tableName);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "下载代码")
|
||||
@GetMapping("/{tableName}/download")
|
||||
@Log(value = "下载代码", module = LogModuleEnum.OTHER)
|
||||
public void downloadZip(HttpServletResponse response, @PathVariable String tableName) throws IOException {
|
||||
public void downloadZip(HttpServletResponse response, @PathVariable String tableName) {
|
||||
String[] tableNames = tableName.split(",");
|
||||
byte[] data = generatorService.downloadCode(tableNames);
|
||||
byte[] data = codegenService.downloadCode(tableNames);
|
||||
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(generatorProperties.getDownloadFileName(), StandardCharsets.UTF_8));
|
||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(codegenProperties.getDownloadFileName(), StandardCharsets.UTF_8));
|
||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||
response.setDateHeader("Expires", 0);
|
||||
IOUtils.write(data, response.getOutputStream());
|
||||
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
outputStream.write(data);
|
||||
outputStream.flush();
|
||||
} catch (IOException e) {
|
||||
log.error("Error while writing the zip file to response", e);
|
||||
throw new RuntimeException("Failed to write the zip file to response", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
package com.youlai.boot.platform.generator.converter;
|
||||
package com.youlai.boot.module.codegen.converter;
|
||||
|
||||
import com.youlai.boot.platform.generator.model.entity.GenConfig;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.platform.generator.model.form.GenConfigForm;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.module.codegen.model.form.GenConfigForm;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* @since 2.10.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface GenConfigConverter {
|
||||
public interface CodegenConverter {
|
||||
|
||||
@Mapping(source = "genConfig.tableName", target = "tableName")
|
||||
@Mapping(source = "genConfig.businessName", target = "businessName")
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
package com.youlai.boot.platform.generator.mapper;
|
||||
package com.youlai.boot.module.codegen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.platform.generator.model.bo.ColumnMetaData;
|
||||
import com.youlai.boot.platform.generator.model.bo.TableMetaData;
|
||||
import com.youlai.boot.platform.generator.model.query.TablePageQuery;
|
||||
import com.youlai.boot.platform.generator.model.vo.TablePageVO;
|
||||
import com.youlai.boot.module.codegen.model.bo.ColumnMetaData;
|
||||
import com.youlai.boot.module.codegen.model.bo.TableMetaData;
|
||||
import com.youlai.boot.module.codegen.model.query.TablePageQuery;
|
||||
import com.youlai.boot.module.codegen.model.vo.TablePageVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.platform.generator.mapper;
|
||||
package com.youlai.boot.module.codegen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.platform.generator.mapper;
|
||||
package com.youlai.boot.module.codegen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenFieldConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.generator.model.bo;
|
||||
package com.youlai.boot.module.codegen.model.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.generator.model.bo;
|
||||
package com.youlai.boot.module.codegen.model.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.generator.model.entity;
|
||||
package com.youlai.boot.module.codegen.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.generator.model.entity;
|
||||
package com.youlai.boot.module.codegen.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.generator.model.form;
|
||||
package com.youlai.boot.module.codegen.model.form;
|
||||
|
||||
import com.youlai.boot.common.enums.FormTypeEnum;
|
||||
import com.youlai.boot.common.enums.QueryTypeEnum;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.generator.model.query;
|
||||
package com.youlai.boot.module.codegen.model.query;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.youlai.boot.common.base.BasePageQuery;
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.youlai.boot.platform.generator.model.vo;
|
||||
package com.youlai.boot.module.codegen.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "代码生成代码预览VO")
|
||||
@Data
|
||||
public class GeneratorPreviewVO {
|
||||
public class CodegenPreviewVO {
|
||||
|
||||
@Schema(description = "生成文件路径")
|
||||
private String path;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.generator.model.vo;
|
||||
package com.youlai.boot.module.codegen.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.youlai.boot.module.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.module.codegen.model.form.GenConfigForm;
|
||||
import com.youlai.boot.module.codegen.model.query.TablePageQuery;
|
||||
import com.youlai.boot.module.codegen.model.vo.CodegenPreviewVO;
|
||||
import com.youlai.boot.module.codegen.model.vo.TablePageVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 代码生成配置接口
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
public interface CodegenService {
|
||||
|
||||
/**
|
||||
* 获取数据表分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<TablePageVO> getTablePage(TablePageQuery queryParams);
|
||||
|
||||
/**
|
||||
* 获取预览生成代码
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
List<CodegenPreviewVO> getCodegenPreviewData(String tableName);
|
||||
|
||||
/**
|
||||
* 下载代码
|
||||
* @param tableNames 表名
|
||||
* @return
|
||||
*/
|
||||
byte[] downloadCode(String[] tableNames);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.youlai.boot.module.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
import com.youlai.boot.module.codegen.model.form.GenConfigForm;
|
||||
|
||||
/**
|
||||
* 代码生成配置接口
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
public interface GenConfigService extends IService<GenConfig> {
|
||||
|
||||
/**
|
||||
* 获取代码生成配置
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
GenConfigForm getGenConfigFormData(String tableName);
|
||||
|
||||
/**
|
||||
* 保存代码生成配置
|
||||
*
|
||||
* @param formData 表单数据
|
||||
* @return
|
||||
*/
|
||||
void saveGenConfig(GenConfigForm formData);
|
||||
|
||||
/**
|
||||
* 删除代码生成配置
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
void deleteGenConfig(String tableName);
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.platform.generator.service;
|
||||
package com.youlai.boot.module.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenFieldConfig;
|
||||
|
||||
/**
|
||||
* 代码生成配置接口
|
||||
@@ -0,0 +1,316 @@
|
||||
package com.youlai.boot.module.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.template.Template;
|
||||
import cn.hutool.extra.template.TemplateConfig;
|
||||
import cn.hutool.extra.template.TemplateEngine;
|
||||
import cn.hutool.extra.template.TemplateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.common.enums.JavaTypeEnum;
|
||||
import com.youlai.boot.config.property.CodegenProperties;
|
||||
import com.youlai.boot.module.codegen.service.GenConfigService;
|
||||
import com.youlai.boot.module.codegen.service.GenFieldConfigService;
|
||||
import com.youlai.boot.module.codegen.service.CodegenService;
|
||||
import com.youlai.boot.module.codegen.converter.CodegenConverter;
|
||||
import com.youlai.boot.common.exception.BusinessException;
|
||||
import com.youlai.boot.module.codegen.mapper.DatabaseMapper;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.module.codegen.model.query.TablePageQuery;
|
||||
import com.youlai.boot.module.codegen.model.vo.CodegenPreviewVO;
|
||||
import com.youlai.boot.module.codegen.model.vo.TablePageVO;
|
||||
import com.youlai.boot.system.service.MenuService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 数据库服务实现类
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class CodegenServiceImpl implements CodegenService {
|
||||
|
||||
private final DatabaseMapper databaseMapper;
|
||||
private final CodegenProperties codegenProperties;
|
||||
private final GenConfigService genConfigService;
|
||||
private final GenFieldConfigService genFieldConfigService;
|
||||
|
||||
/**
|
||||
* 数据表分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
public Page<TablePageVO> getTablePage(TablePageQuery queryParams) {
|
||||
Page<TablePageVO> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
|
||||
// 设置排除的表
|
||||
List<String> excludeTables = codegenProperties.getExcludeTables();
|
||||
queryParams.setExcludeTables(excludeTables);
|
||||
|
||||
return databaseMapper.getTablePage(page, queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预览生成代码
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return 预览数据
|
||||
*/
|
||||
@Override
|
||||
public List<CodegenPreviewVO> getCodegenPreviewData(String tableName) {
|
||||
|
||||
List<CodegenPreviewVO> list = new ArrayList<>();
|
||||
|
||||
GenConfig genConfig = genConfigService.getOne(new LambdaQueryWrapper<GenConfig>()
|
||||
.eq(GenConfig::getTableName, tableName)
|
||||
);
|
||||
if (genConfig == null) {
|
||||
throw new BusinessException("未找到表生成配置");
|
||||
}
|
||||
|
||||
List<GenFieldConfig> fieldConfigs = genFieldConfigService.list(new LambdaQueryWrapper<GenFieldConfig>()
|
||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
||||
.orderByAsc(GenFieldConfig::getFieldSort)
|
||||
|
||||
);
|
||||
if (CollectionUtil.isEmpty(fieldConfigs)) {
|
||||
throw new BusinessException("未找到字段生成配置");
|
||||
}
|
||||
|
||||
// 遍历模板配置
|
||||
Map<String, CodegenProperties.TemplateConfig> templateConfigs = codegenProperties.getTemplateConfigs();
|
||||
for (Map.Entry<String, CodegenProperties.TemplateConfig> templateConfigEntry : templateConfigs.entrySet()) {
|
||||
CodegenPreviewVO previewVO = new CodegenPreviewVO();
|
||||
|
||||
CodegenProperties.TemplateConfig templateConfig = templateConfigEntry.getValue();
|
||||
|
||||
/* 1. 生成文件名 UserController */
|
||||
// User Role Menu Dept
|
||||
String entityName = genConfig.getEntityName();
|
||||
// Controller Service Mapper Entity
|
||||
String templateName = templateConfigEntry.getKey();
|
||||
// .java .ts .vue
|
||||
String extension = templateConfig.getExtension();
|
||||
|
||||
// 文件名 UserController.java
|
||||
String fileName = getFileName(entityName, templateName, extension);
|
||||
previewVO.setFileName(fileName);
|
||||
|
||||
/* 2. 生成文件路径 */
|
||||
// 包名:com.youlai.boot
|
||||
String packageName = genConfig.getPackageName();
|
||||
// 模块名:system
|
||||
String moduleName = genConfig.getModuleName();
|
||||
// 子包名:controller
|
||||
String subpackageName = templateConfig.getSubpackageName();
|
||||
// 组合成文件路径:src/main/java/com/youlai/boot/system/controller
|
||||
String filePath = getFilePath(templateName, moduleName, packageName, subpackageName, entityName);
|
||||
previewVO.setPath(filePath);
|
||||
|
||||
/* 3. 生成文件内容 */
|
||||
// 将模板文件中的变量替换为具体的值 生成代码内容
|
||||
String content = getCodeContent(templateConfig, genConfig, fieldConfigs);
|
||||
previewVO.setContent(content);
|
||||
|
||||
list.add(previewVO);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件名
|
||||
*
|
||||
* @param entityName 实体类名 UserController
|
||||
* @param templateName 模板名 Entity
|
||||
* @param extension 文件后缀 .java
|
||||
* @return 文件名
|
||||
*/
|
||||
private String getFileName(String entityName, String templateName, String extension) {
|
||||
if ("Entity".equals(templateName)) {
|
||||
return entityName + extension;
|
||||
} else if ("MapperXml".equals(templateName)) {
|
||||
return entityName + "Mapper" + extension;
|
||||
} else if ("API".equals(templateName)) {
|
||||
return StrUtil.toSymbolCase(entityName, '-') + extension;
|
||||
} else if ("VIEW".equals(templateName)) {
|
||||
return "index.vue";
|
||||
}
|
||||
return entityName + templateName + extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件路径
|
||||
*
|
||||
* @param templateName 模板名 Entity
|
||||
* @param moduleName 模块名 system
|
||||
* @param packageName 包名 com.youlai
|
||||
* @param subPackageName 子包名 controller
|
||||
* @param entityName 实体类名 UserController
|
||||
* @return 文件路径 src/main/java/com/youlai/system/controller
|
||||
*/
|
||||
private String getFilePath(String templateName, String moduleName, String packageName, String subPackageName, String entityName) {
|
||||
String path;
|
||||
if ("MapperXml".equals(templateName)) {
|
||||
path = (codegenProperties.getBackendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + "main" + File.separator + "resources"
|
||||
+ File.separator + subPackageName
|
||||
);
|
||||
} else if ("API".equals(templateName)) {
|
||||
path = (codegenProperties.getFrontendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + subPackageName
|
||||
);
|
||||
} else if ("VIEW".equals(templateName)) {
|
||||
path = (codegenProperties.getFrontendAppName()
|
||||
+ File.separator + "src"
|
||||
+ File.separator + subPackageName
|
||||
+ File.separator + moduleName
|
||||
+ File.separator + StrUtil.toSymbolCase(entityName, '-')
|
||||
);
|
||||
} else {
|
||||
path = (codegenProperties.getBackendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + "main" + File.separator + "java"
|
||||
+ File.separator + packageName
|
||||
+ File.separator + moduleName
|
||||
+ File.separator + subPackageName
|
||||
);
|
||||
}
|
||||
|
||||
// subPackageName = model.entity => model/entity
|
||||
path = path.replace(".", File.separator);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成代码内容
|
||||
*
|
||||
* @param templateConfig 模板配置
|
||||
* @param genConfig 生成配置
|
||||
* @param fieldConfigs 字段配置
|
||||
* @return 代码内容
|
||||
*/
|
||||
private String getCodeContent(CodegenProperties.TemplateConfig templateConfig, GenConfig genConfig, List<GenFieldConfig> fieldConfigs) {
|
||||
|
||||
Map<String, Object> bindMap = new HashMap<>();
|
||||
|
||||
String entityName = genConfig.getEntityName();
|
||||
|
||||
bindMap.put("packageName", genConfig.getPackageName());
|
||||
bindMap.put("moduleName", genConfig.getModuleName());
|
||||
bindMap.put("subpackageName", templateConfig.getSubpackageName());
|
||||
bindMap.put("date", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
||||
bindMap.put("entityName", entityName);
|
||||
bindMap.put("tableName", genConfig.getTableName());
|
||||
bindMap.put("author", genConfig.getAuthor());
|
||||
bindMap.put("lowerFirstEntityName", StrUtil.lowerFirst(entityName)); // UserTest → userTest
|
||||
bindMap.put("kebabCaseEntityName", StrUtil.toSymbolCase(entityName, '-')); // UserTest → user-test
|
||||
bindMap.put("businessName", genConfig.getBusinessName());
|
||||
bindMap.put("fieldConfigs", fieldConfigs);
|
||||
|
||||
boolean hasLocalDateTime = false;
|
||||
boolean hasBigDecimal = false;
|
||||
boolean hasRequiredField = false;
|
||||
|
||||
for (GenFieldConfig fieldConfig : fieldConfigs) {
|
||||
|
||||
if ("LocalDateTime".equals(fieldConfig.getFieldType())) {
|
||||
hasLocalDateTime = true;
|
||||
}
|
||||
if ("BigDecimal".equals(fieldConfig.getFieldType())) {
|
||||
hasBigDecimal = true;
|
||||
}
|
||||
if (ObjectUtil.equals(fieldConfig.getIsRequired(), 1)) {
|
||||
hasRequiredField = true;
|
||||
}
|
||||
fieldConfig.setTsType(JavaTypeEnum.getTsTypeByJavaType(fieldConfig.getFieldType()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
bindMap.put("hasLocalDateTime", hasLocalDateTime);
|
||||
bindMap.put("hasBigDecimal", hasBigDecimal);
|
||||
bindMap.put("hasRequiredField", hasRequiredField);
|
||||
|
||||
TemplateEngine templateEngine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
|
||||
Template template = templateEngine.getTemplate(templateConfig.getTemplatePath());
|
||||
|
||||
return template.render(bindMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载代码
|
||||
*
|
||||
* @param tableNames 表名数组,支持多张表。
|
||||
* @return 压缩文件字节数组
|
||||
*/
|
||||
@Override
|
||||
public byte[] downloadCode(String[] tableNames) {
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(outputStream)) {
|
||||
|
||||
// 遍历每个表名,生成对应的代码并压缩到 zip 文件中
|
||||
for (String tableName : tableNames) {
|
||||
generateAndZipCode(tableName, zip);
|
||||
}
|
||||
|
||||
return outputStream.toByteArray();
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Error while generating zip for code download", e);
|
||||
throw new RuntimeException("Failed to generate code zip file", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名生成代码并压缩到zip文件中
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param zip 压缩文件输出流
|
||||
*/
|
||||
private void generateAndZipCode(String tableName, ZipOutputStream zip) {
|
||||
List<CodegenPreviewVO> codePreviewList = getCodegenPreviewData(tableName);
|
||||
|
||||
for (CodegenPreviewVO codePreview : codePreviewList) {
|
||||
String fileName = codePreview.getFileName();
|
||||
String content = codePreview.getContent();
|
||||
String path = codePreview.getPath();
|
||||
|
||||
try {
|
||||
// 创建压缩条目
|
||||
ZipEntry zipEntry = new ZipEntry(path + File.separator + fileName);
|
||||
zip.putNextEntry(zipEntry);
|
||||
|
||||
// 写入文件内容
|
||||
zip.write(content.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 关闭当前压缩条目
|
||||
zip.closeEntry();
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Error while adding file {} to zip", fileName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package com.youlai.boot.module.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.YouLaiApplication;
|
||||
import com.youlai.boot.common.enums.EnvEnum;
|
||||
import com.youlai.boot.common.enums.FormTypeEnum;
|
||||
import com.youlai.boot.common.enums.JavaTypeEnum;
|
||||
import com.youlai.boot.common.enums.QueryTypeEnum;
|
||||
import com.youlai.boot.common.exception.BusinessException;
|
||||
import com.youlai.boot.config.property.CodegenProperties;
|
||||
import com.youlai.boot.module.codegen.converter.CodegenConverter;
|
||||
import com.youlai.boot.module.codegen.mapper.DatabaseMapper;
|
||||
import com.youlai.boot.module.codegen.mapper.GenConfigMapper;
|
||||
import com.youlai.boot.module.codegen.model.bo.ColumnMetaData;
|
||||
import com.youlai.boot.module.codegen.model.bo.TableMetaData;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.module.codegen.model.form.GenConfigForm;
|
||||
import com.youlai.boot.module.codegen.service.GenConfigService;
|
||||
import com.youlai.boot.module.codegen.service.GenFieldConfigService;
|
||||
import com.youlai.boot.system.service.MenuService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 数据库服务实现类
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenConfigServiceImpl extends ServiceImpl<GenConfigMapper, GenConfig> implements GenConfigService {
|
||||
|
||||
private final DatabaseMapper databaseMapper;
|
||||
private final CodegenProperties codegenProperties;
|
||||
private final GenFieldConfigService genFieldConfigService;
|
||||
private final CodegenConverter codegenConverter;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String springProfilesActive;
|
||||
|
||||
private final MenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取代码生成配置
|
||||
*
|
||||
* @param tableName 表名 eg: sys_user
|
||||
* @return 代码生成配置
|
||||
*/
|
||||
@Override
|
||||
public GenConfigForm getGenConfigFormData(String tableName) {
|
||||
// 查询表生成配置
|
||||
GenConfig genConfig = this.getOne(
|
||||
new LambdaQueryWrapper<>(GenConfig.class)
|
||||
.eq(GenConfig::getTableName, tableName)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
|
||||
// 是否有代码生成配置
|
||||
boolean hasGenConfig = genConfig != null;
|
||||
|
||||
// 如果没有代码生成配置,则根据表的元数据生成默认配置
|
||||
if (genConfig == null) {
|
||||
TableMetaData tableMetadata = databaseMapper.getTableMetadata(tableName);
|
||||
Assert.isTrue(tableMetadata != null, "未找到表元数据");
|
||||
|
||||
genConfig = new GenConfig();
|
||||
genConfig.setTableName(tableName);
|
||||
|
||||
String tableComment = tableMetadata.getTableComment();
|
||||
if (StrUtil.isNotBlank(tableComment)) {
|
||||
genConfig.setBusinessName(tableComment.replace("表", ""));
|
||||
}
|
||||
// 实体类名 = 表名去掉前缀后转驼峰,前缀默认为下划线分割的第一个元素
|
||||
String entityName = StrUtil.toCamelCase(StrUtil.removePrefix(tableName, tableName.split("_")[0]));
|
||||
genConfig.setEntityName(entityName);
|
||||
|
||||
genConfig.setPackageName(YouLaiApplication.class.getPackageName());
|
||||
genConfig.setModuleName(codegenProperties.getDefaultConfig().getModuleName()); // 默认模块名
|
||||
genConfig.setAuthor(codegenProperties.getDefaultConfig().getAuthor());
|
||||
}
|
||||
|
||||
// 根据表的列 + 已经存在的字段生成配置 得到 组合后的字段生成配置
|
||||
List<GenFieldConfig> genFieldConfigs = new ArrayList<>();
|
||||
|
||||
// 获取表的列
|
||||
List<ColumnMetaData> tableColumns = databaseMapper.getTableColumns(tableName);
|
||||
if (CollectionUtil.isNotEmpty(tableColumns)) {
|
||||
// 查询字段生成配置
|
||||
List<GenFieldConfig> fieldConfigList = genFieldConfigService.list(
|
||||
new LambdaQueryWrapper<GenFieldConfig>()
|
||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
||||
.orderByAsc(GenFieldConfig::getFieldSort)
|
||||
);
|
||||
Integer maxSort = fieldConfigList.stream()
|
||||
.map(GenFieldConfig::getFieldSort)
|
||||
.filter(Objects::nonNull) // 过滤掉空值
|
||||
.max(Integer::compareTo)
|
||||
.orElse(0);
|
||||
for (ColumnMetaData tableColumn : tableColumns) {
|
||||
// 根据列名获取字段生成配置
|
||||
String columnName = tableColumn.getColumnName();
|
||||
GenFieldConfig fieldConfig = fieldConfigList.stream()
|
||||
.filter(item -> StrUtil.equals(item.getColumnName(), columnName))
|
||||
.findFirst()
|
||||
.orElseGet(() -> createDefaultFieldConfig(tableColumn));
|
||||
if (fieldConfig.getFieldSort() == null) {
|
||||
fieldConfig.setFieldSort(++maxSort);
|
||||
}
|
||||
// 根据列类型设置字段类型
|
||||
String fieldType = fieldConfig.getFieldType();
|
||||
if (StrUtil.isBlank(fieldType)) {
|
||||
String javaType = JavaTypeEnum.getJavaTypeByColumnType(fieldConfig.getColumnType());
|
||||
fieldConfig.setFieldType(javaType);
|
||||
}
|
||||
// 如果没有代码生成配置,则默认展示在列表和表单
|
||||
if (!hasGenConfig) {
|
||||
fieldConfig.setIsShowInList(1);
|
||||
fieldConfig.setIsShowInForm(1);
|
||||
}
|
||||
genFieldConfigs.add(fieldConfig);
|
||||
}
|
||||
}
|
||||
//对genFieldConfigs按照fieldSort排序
|
||||
genFieldConfigs = genFieldConfigs.stream().sorted(Comparator.comparing(GenFieldConfig::getFieldSort)).toList();
|
||||
GenConfigForm genConfigForm = codegenConverter.toGenConfigForm(genConfig, genFieldConfigs);
|
||||
|
||||
genConfigForm.setFrontendAppName(codegenProperties.getFrontendAppName());
|
||||
genConfigForm.setBackendAppName(codegenProperties.getBackendAppName());
|
||||
return genConfigForm;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建默认字段配置
|
||||
*
|
||||
* @param columnMetaData 表字段元数据
|
||||
* @return
|
||||
*/
|
||||
private GenFieldConfig createDefaultFieldConfig(ColumnMetaData columnMetaData) {
|
||||
GenFieldConfig fieldConfig = new GenFieldConfig();
|
||||
fieldConfig.setColumnName(columnMetaData.getColumnName());
|
||||
fieldConfig.setColumnType(columnMetaData.getDataType());
|
||||
fieldConfig.setFieldComment(columnMetaData.getColumnComment());
|
||||
fieldConfig.setFieldName(StrUtil.toCamelCase(columnMetaData.getColumnName()));
|
||||
fieldConfig.setIsRequired("YES".equals(columnMetaData.getIsNullable()) ? 1 : 0);
|
||||
|
||||
if (fieldConfig.getColumnType().equals("date")) {
|
||||
fieldConfig.setFormType(FormTypeEnum.DATE);
|
||||
} else if (fieldConfig.getColumnType().equals("datetime")) {
|
||||
fieldConfig.setFormType(FormTypeEnum.DATE_TIME);
|
||||
} else {
|
||||
fieldConfig.setFormType(FormTypeEnum.INPUT);
|
||||
}
|
||||
|
||||
fieldConfig.setQueryType(QueryTypeEnum.EQ);
|
||||
fieldConfig.setMaxLength(columnMetaData.getCharacterMaximumLength());
|
||||
return fieldConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存代码生成配置
|
||||
*
|
||||
* @param formData 代码生成配置表单
|
||||
*/
|
||||
@Override
|
||||
public void saveGenConfig(GenConfigForm formData) {
|
||||
GenConfig genConfig = codegenConverter.toGenConfig(formData);
|
||||
this.saveOrUpdate(genConfig);
|
||||
|
||||
// 如果选择上级菜单且当前环境不是生产环境,则保存菜单
|
||||
Long parentMenuId = formData.getParentMenuId();
|
||||
if (parentMenuId != null && !EnvEnum.PROD.getValue().equals(springProfilesActive)) {
|
||||
menuService.addMenuForCodegen(parentMenuId, genConfig);
|
||||
}
|
||||
|
||||
List<GenFieldConfig> genFieldConfigs = codegenConverter.toGenFieldConfig(formData.getFieldConfigs());
|
||||
|
||||
if (CollectionUtil.isEmpty(genFieldConfigs)) {
|
||||
throw new BusinessException("字段配置不能为空");
|
||||
}
|
||||
genFieldConfigs.forEach(genFieldConfig -> {
|
||||
genFieldConfig.setConfigId(genConfig.getId());
|
||||
});
|
||||
genFieldConfigService.saveOrUpdateBatch(genFieldConfigs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除代码生成配置
|
||||
*
|
||||
* @param tableName 表名
|
||||
*/
|
||||
@Override
|
||||
public void deleteGenConfig(String tableName) {
|
||||
GenConfig genConfig = this.getOne(new LambdaQueryWrapper<GenConfig>()
|
||||
.eq(GenConfig::getTableName, tableName));
|
||||
|
||||
boolean result = this.remove(new LambdaQueryWrapper<GenConfig>()
|
||||
.eq(GenConfig::getTableName, tableName)
|
||||
);
|
||||
if (result) {
|
||||
genFieldConfigService.remove(new LambdaQueryWrapper<GenFieldConfig>()
|
||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
package com.youlai.boot.platform.generator.service.impl;
|
||||
package com.youlai.boot.module.codegen.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.platform.generator.mapper.GenFieldConfigMapper;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.platform.generator.service.GenFieldConfigService;
|
||||
import com.youlai.boot.module.codegen.mapper.GenFieldConfigMapper;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.module.codegen.service.GenFieldConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.platform.file.controller;
|
||||
package com.youlai.boot.module.file.controller;
|
||||
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.platform.file.service.FileService;
|
||||
import com.youlai.boot.module.file.service.FileService;
|
||||
import com.youlai.boot.system.model.dto.FileInfo;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.file.service;
|
||||
package com.youlai.boot.module.file.service;
|
||||
|
||||
import com.youlai.boot.system.model.dto.FileInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.file.service.impl;
|
||||
package com.youlai.boot.module.file.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
@@ -8,7 +8,7 @@ import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import com.youlai.boot.platform.file.service.FileService;
|
||||
import com.youlai.boot.module.file.service.FileService;
|
||||
import com.youlai.boot.system.model.dto.FileInfo;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.Data;
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.youlai.boot.platform.file.service.impl;
|
||||
package com.youlai.boot.module.file.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.youlai.boot.platform.file.service.FileService;
|
||||
import com.youlai.boot.module.file.service.FileService;
|
||||
import com.youlai.boot.system.model.dto.FileInfo;
|
||||
import io.minio.*;
|
||||
import io.minio.errors.*;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.mail.controller;
|
||||
package com.youlai.boot.module.mail.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.mail.service;
|
||||
package com.youlai.boot.module.mail.service;
|
||||
|
||||
/**
|
||||
* 邮件服务接口层
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.platform.mail.service.impl;
|
||||
package com.youlai.boot.module.mail.service.impl;
|
||||
|
||||
import com.youlai.boot.config.property.MailProperties;
|
||||
import com.youlai.boot.platform.mail.service.MailService;
|
||||
import com.youlai.boot.module.mail.service.MailService;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.youlai.boot.module.sms.controller;
|
||||
|
||||
/**
|
||||
* 短信控制层
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
public class SmsController {
|
||||
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.sms.service;
|
||||
package com.youlai.boot.module.sms.service;
|
||||
|
||||
/**
|
||||
* 短信服务接口层
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.sms.service.impl;
|
||||
package com.youlai.boot.module.sms.service.impl;
|
||||
|
||||
import com.aliyuncs.CommonRequest;
|
||||
import com.aliyuncs.CommonResponse;
|
||||
@@ -9,7 +9,7 @@ import com.aliyuncs.exceptions.ServerException;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.youlai.boot.config.property.AliyunSmsProperties;
|
||||
import com.youlai.boot.platform.sms.service.SmsService;
|
||||
import com.youlai.boot.module.sms.service.SmsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.websocket.controller;
|
||||
package com.youlai.boot.module.websocket.controller;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeTypeEnum;
|
||||
import com.youlai.boot.system.model.dto.ChatMessage;
|
||||
File renamed without changes.
@@ -0,0 +1,9 @@
|
||||
package com.youlai.boot.module.websocket.service;
|
||||
|
||||
public interface WebsocketService {
|
||||
|
||||
void addUser(String username);
|
||||
|
||||
void removeUser(String username) ;
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.platform.websocket.service.impl;
|
||||
package com.youlai.boot.module.websocket.service.impl;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeWayEnum;
|
||||
import com.youlai.boot.common.enums.NoticeTypeEnum;
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.youlai.boot.platform.generator.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenConfig;
|
||||
|
||||
/**
|
||||
* 代码生成配置接口
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
public interface GenConfigService extends IService<GenConfig> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.youlai.boot.platform.generator.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.platform.generator.model.form.GenConfigForm;
|
||||
import com.youlai.boot.platform.generator.model.query.TablePageQuery;
|
||||
import com.youlai.boot.platform.generator.model.vo.GeneratorPreviewVO;
|
||||
import com.youlai.boot.platform.generator.model.vo.TablePageVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 代码生成配置接口
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
public interface GeneratorService {
|
||||
|
||||
/**
|
||||
* 获取数据表分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<TablePageVO> getTablePage(TablePageQuery queryParams);
|
||||
|
||||
/**
|
||||
* 获取预览生成代码
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
List<GeneratorPreviewVO> getTablePreviewData(String tableName);
|
||||
|
||||
/**
|
||||
* 获取代码生成配置
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
GenConfigForm getGenConfigFormData(String tableName);
|
||||
|
||||
/**
|
||||
* 保存代码生成配置
|
||||
*
|
||||
* @param formData 表单数据
|
||||
* @return
|
||||
*/
|
||||
void saveGenConfig(GenConfigForm formData);
|
||||
|
||||
/**
|
||||
* 删除代码生成配置
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
void deleteGenConfig(String tableName);
|
||||
|
||||
/**
|
||||
* 下载代码
|
||||
* @param tableNames 表名
|
||||
* @return
|
||||
*/
|
||||
byte[] downloadCode(String[] tableNames);
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package com.youlai.boot.platform.generator.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.platform.generator.mapper.GenConfigMapper;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenConfig;
|
||||
import com.youlai.boot.platform.generator.service.GenConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 数据库服务实现类
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenConfigServiceImpl extends ServiceImpl<GenConfigMapper, GenConfig> implements GenConfigService {
|
||||
|
||||
}
|
||||
-475
@@ -1,475 +0,0 @@
|
||||
package com.youlai.boot.platform.generator.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.template.Template;
|
||||
import cn.hutool.extra.template.TemplateConfig;
|
||||
import cn.hutool.extra.template.TemplateEngine;
|
||||
import cn.hutool.extra.template.TemplateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.YouLaiApplication;
|
||||
import com.youlai.boot.common.enums.FormTypeEnum;
|
||||
import com.youlai.boot.common.enums.JavaTypeEnum;
|
||||
import com.youlai.boot.common.enums.QueryTypeEnum;
|
||||
import com.youlai.boot.config.property.GeneratorProperties;
|
||||
import com.youlai.boot.platform.generator.service.GenConfigService;
|
||||
import com.youlai.boot.platform.generator.service.GenFieldConfigService;
|
||||
import com.youlai.boot.platform.generator.service.GeneratorService;
|
||||
import com.youlai.boot.platform.generator.converter.GenConfigConverter;
|
||||
import com.youlai.boot.common.exception.BusinessException;
|
||||
import com.youlai.boot.platform.generator.mapper.DatabaseMapper;
|
||||
import com.youlai.boot.platform.generator.model.bo.ColumnMetaData;
|
||||
import com.youlai.boot.platform.generator.model.bo.TableMetaData;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenConfig;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.platform.generator.model.form.GenConfigForm;
|
||||
import com.youlai.boot.platform.generator.model.query.TablePageQuery;
|
||||
import com.youlai.boot.platform.generator.model.vo.GeneratorPreviewVO;
|
||||
import com.youlai.boot.platform.generator.model.vo.TablePageVO;
|
||||
import com.youlai.boot.system.service.MenuService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 数据库服务实现类
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GeneratorServiceImpl implements GeneratorService {
|
||||
|
||||
private final DatabaseMapper databaseMapper;
|
||||
private final GeneratorProperties generatorProperties;
|
||||
private final GenConfigService genConfigService;
|
||||
private final GenFieldConfigService genFieldConfigService;
|
||||
private final GenConfigConverter genConfigConverter;
|
||||
private final MenuService menuService;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String springProfilesActive;
|
||||
|
||||
/**
|
||||
* 数据表分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
public Page<TablePageVO> getTablePage(TablePageQuery queryParams) {
|
||||
Page<TablePageVO> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
|
||||
// 设置排除的表
|
||||
List<String> excludeTables = generatorProperties.getExcludeTables();
|
||||
queryParams.setExcludeTables(excludeTables);
|
||||
|
||||
return databaseMapper.getTablePage(page, queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代码生成配置
|
||||
*
|
||||
* @param tableName 表名 eg: sys_user
|
||||
* @return 代码生成配置
|
||||
*/
|
||||
@Override
|
||||
public GenConfigForm getGenConfigFormData(String tableName) {
|
||||
// 查询表生成配置
|
||||
GenConfig genConfig = genConfigService.getOne(
|
||||
new LambdaQueryWrapper<>(GenConfig.class)
|
||||
.eq(GenConfig::getTableName, tableName)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
|
||||
// 是否有代码生成配置
|
||||
boolean hasGenConfig = genConfig != null;
|
||||
|
||||
// 如果没有代码生成配置,则根据表的元数据生成默认配置
|
||||
if (genConfig == null) {
|
||||
TableMetaData tableMetadata = databaseMapper.getTableMetadata(tableName);
|
||||
Assert.isTrue(tableMetadata != null, "未找到表元数据");
|
||||
|
||||
genConfig = new GenConfig();
|
||||
genConfig.setTableName(tableName);
|
||||
|
||||
String tableComment = tableMetadata.getTableComment();
|
||||
if (StrUtil.isNotBlank(tableComment)) {
|
||||
genConfig.setBusinessName(tableComment.replace("表", ""));
|
||||
}
|
||||
// 实体类名 = 表名去掉前缀后转驼峰,前缀默认为下划线分割的第一个元素
|
||||
String entityName = StrUtil.toCamelCase(StrUtil.removePrefix(tableName, tableName.split("_")[0]));
|
||||
genConfig.setEntityName(entityName);
|
||||
|
||||
genConfig.setPackageName(YouLaiApplication.class.getPackageName());
|
||||
genConfig.setModuleName(generatorProperties.getDefaultConfig().getModuleName()); // 默认模块名
|
||||
genConfig.setAuthor(generatorProperties.getDefaultConfig().getAuthor());
|
||||
}
|
||||
|
||||
// 根据表的列 + 已经存在的字段生成配置 得到 组合后的字段生成配置
|
||||
List<GenFieldConfig> genFieldConfigs = new ArrayList<>();
|
||||
|
||||
// 获取表的列
|
||||
List<ColumnMetaData> tableColumns = databaseMapper.getTableColumns(tableName);
|
||||
if (CollectionUtil.isNotEmpty(tableColumns)) {
|
||||
// 查询字段生成配置
|
||||
List<GenFieldConfig> fieldConfigList = genFieldConfigService.list(
|
||||
new LambdaQueryWrapper<GenFieldConfig>()
|
||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
||||
.orderByAsc(GenFieldConfig::getFieldSort)
|
||||
);
|
||||
Integer maxSort = fieldConfigList.stream()
|
||||
.map(GenFieldConfig::getFieldSort)
|
||||
.filter(Objects::nonNull) // 过滤掉空值
|
||||
.max(Integer::compareTo)
|
||||
.orElse(0);
|
||||
for (ColumnMetaData tableColumn : tableColumns) {
|
||||
// 根据列名获取字段生成配置
|
||||
String columnName = tableColumn.getColumnName();
|
||||
GenFieldConfig fieldConfig = fieldConfigList.stream()
|
||||
.filter(item -> StrUtil.equals(item.getColumnName(), columnName))
|
||||
.findFirst()
|
||||
.orElseGet(() -> createDefaultFieldConfig(tableColumn));
|
||||
if (fieldConfig.getFieldSort() == null) {
|
||||
fieldConfig.setFieldSort(++maxSort);
|
||||
}
|
||||
// 根据列类型设置字段类型
|
||||
String fieldType = fieldConfig.getFieldType();
|
||||
if (StrUtil.isBlank(fieldType)) {
|
||||
String javaType = JavaTypeEnum.getJavaTypeByColumnType(fieldConfig.getColumnType());
|
||||
fieldConfig.setFieldType(javaType);
|
||||
}
|
||||
// 如果没有代码生成配置,则默认展示在列表和表单
|
||||
if (!hasGenConfig) {
|
||||
fieldConfig.setIsShowInList(1);
|
||||
fieldConfig.setIsShowInForm(1);
|
||||
}
|
||||
genFieldConfigs.add(fieldConfig);
|
||||
}
|
||||
}
|
||||
//对genFieldConfigs按照fieldSort排序
|
||||
genFieldConfigs = genFieldConfigs.stream().sorted(Comparator.comparing(GenFieldConfig::getFieldSort)).toList();
|
||||
GenConfigForm genConfigForm = genConfigConverter.toGenConfigForm(genConfig, genFieldConfigs);
|
||||
|
||||
genConfigForm.setFrontendAppName(generatorProperties.getFrontendAppName());
|
||||
genConfigForm.setBackendAppName(generatorProperties.getBackendAppName());
|
||||
return genConfigForm;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建默认字段配置
|
||||
*
|
||||
* @param columnMetaData 表字段元数据
|
||||
* @return
|
||||
*/
|
||||
private GenFieldConfig createDefaultFieldConfig(ColumnMetaData columnMetaData) {
|
||||
GenFieldConfig fieldConfig = new GenFieldConfig();
|
||||
fieldConfig.setColumnName(columnMetaData.getColumnName());
|
||||
fieldConfig.setColumnType(columnMetaData.getDataType());
|
||||
fieldConfig.setFieldComment(columnMetaData.getColumnComment());
|
||||
fieldConfig.setFieldName(StrUtil.toCamelCase(columnMetaData.getColumnName()));
|
||||
fieldConfig.setIsRequired("YES".equals(columnMetaData.getIsNullable()) ? 1 : 0);
|
||||
|
||||
if (fieldConfig.getColumnType().equals("date")) {
|
||||
fieldConfig.setFormType(FormTypeEnum.DATE);
|
||||
} else if (fieldConfig.getColumnType().equals("datetime")) {
|
||||
fieldConfig.setFormType(FormTypeEnum.DATE_TIME);
|
||||
} else {
|
||||
fieldConfig.setFormType(FormTypeEnum.INPUT);
|
||||
}
|
||||
|
||||
fieldConfig.setQueryType(QueryTypeEnum.EQ);
|
||||
fieldConfig.setMaxLength(columnMetaData.getCharacterMaximumLength());
|
||||
return fieldConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存代码生成配置
|
||||
*
|
||||
* @param formData 代码生成配置表单
|
||||
*/
|
||||
@Override
|
||||
public void saveGenConfig(GenConfigForm formData) {
|
||||
GenConfig genConfig = genConfigConverter.toGenConfig(formData);
|
||||
genConfigService.saveOrUpdate(genConfig);
|
||||
|
||||
// 如果选择上级菜单
|
||||
Long parentMenuId = formData.getParentMenuId();
|
||||
if (parentMenuId != null && springProfilesActive.equals("dev")) {
|
||||
menuService.saveMenu(parentMenuId, genConfig);
|
||||
}
|
||||
|
||||
List<GenFieldConfig> genFieldConfigs = genConfigConverter.toGenFieldConfig(formData.getFieldConfigs());
|
||||
|
||||
if (CollectionUtil.isEmpty(genFieldConfigs)) {
|
||||
throw new BusinessException("字段配置不能为空");
|
||||
}
|
||||
genFieldConfigs.forEach(genFieldConfig -> {
|
||||
genFieldConfig.setConfigId(genConfig.getId());
|
||||
});
|
||||
genFieldConfigService.saveOrUpdateBatch(genFieldConfigs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除代码生成配置
|
||||
*
|
||||
* @param tableName 表名
|
||||
*/
|
||||
@Override
|
||||
public void deleteGenConfig(String tableName) {
|
||||
GenConfig genConfig = genConfigService.getOne(new LambdaQueryWrapper<GenConfig>()
|
||||
.eq(GenConfig::getTableName, tableName));
|
||||
|
||||
boolean result = genConfigService.remove(new LambdaQueryWrapper<GenConfig>()
|
||||
.eq(GenConfig::getTableName, tableName)
|
||||
);
|
||||
if (result) {
|
||||
genFieldConfigService.remove(new LambdaQueryWrapper<GenFieldConfig>()
|
||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取预览生成代码
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return 预览数据
|
||||
*/
|
||||
@Override
|
||||
public List<GeneratorPreviewVO> getTablePreviewData(String tableName) {
|
||||
|
||||
List<GeneratorPreviewVO> list = new ArrayList<>();
|
||||
|
||||
GenConfig genConfig = genConfigService.getOne(new LambdaQueryWrapper<GenConfig>()
|
||||
.eq(GenConfig::getTableName, tableName)
|
||||
);
|
||||
if (genConfig == null) {
|
||||
throw new BusinessException("未找到表生成配置");
|
||||
}
|
||||
|
||||
List<GenFieldConfig> fieldConfigs = genFieldConfigService.list(new LambdaQueryWrapper<GenFieldConfig>()
|
||||
.eq(GenFieldConfig::getConfigId, genConfig.getId())
|
||||
.orderByAsc(GenFieldConfig::getFieldSort)
|
||||
|
||||
);
|
||||
if (CollectionUtil.isEmpty(fieldConfigs)) {
|
||||
throw new BusinessException("未找到字段生成配置");
|
||||
}
|
||||
|
||||
// 遍历模板配置
|
||||
Map<String, GeneratorProperties.TemplateConfig> templateConfigs = generatorProperties.getTemplateConfigs();
|
||||
for (Map.Entry<String, GeneratorProperties.TemplateConfig> templateConfigEntry : templateConfigs.entrySet()) {
|
||||
GeneratorPreviewVO previewVO = new GeneratorPreviewVO();
|
||||
|
||||
GeneratorProperties.TemplateConfig templateConfig = templateConfigEntry.getValue();
|
||||
|
||||
/* 1. 生成文件名 UserController */
|
||||
// User Role Menu Dept
|
||||
String entityName = genConfig.getEntityName();
|
||||
// Controller Service Mapper Entity
|
||||
String templateName = templateConfigEntry.getKey();
|
||||
// .java .ts .vue
|
||||
String extension = templateConfig.getExtension();
|
||||
|
||||
// 文件名 UserController.java
|
||||
String fileName = getFileName(entityName, templateName, extension);
|
||||
previewVO.setFileName(fileName);
|
||||
|
||||
/* 2. 生成文件路径 */
|
||||
// 包名:com.youlai.boot
|
||||
String packageName = genConfig.getPackageName();
|
||||
// 模块名:system
|
||||
String moduleName = genConfig.getModuleName();
|
||||
// 子包名:controller
|
||||
String subpackageName = templateConfig.getSubpackageName();
|
||||
// 组合成文件路径:src/main/java/com/youlai/boot/system/controller
|
||||
String filePath = getFilePath(templateName, moduleName, packageName, subpackageName, entityName);
|
||||
previewVO.setPath(filePath);
|
||||
|
||||
/* 3. 生成文件内容 */
|
||||
// 将模板文件中的变量替换为具体的值 生成代码内容
|
||||
String content = getCodeContent(templateConfig, genConfig, fieldConfigs);
|
||||
previewVO.setContent(content);
|
||||
|
||||
list.add(previewVO);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件名
|
||||
*
|
||||
* @param entityName 实体类名 UserController
|
||||
* @param templateName 模板名 Entity
|
||||
* @param extension 文件后缀 .java
|
||||
* @return 文件名
|
||||
*/
|
||||
private String getFileName(String entityName, String templateName, String extension) {
|
||||
if ("Entity".equals(templateName)) {
|
||||
return entityName + extension;
|
||||
} else if ("MapperXml".equals(templateName)) {
|
||||
return entityName + "Mapper" + extension;
|
||||
} else if ("API".equals(templateName)) {
|
||||
return StrUtil.toSymbolCase(entityName, '-') + extension;
|
||||
} else if ("VIEW".equals(templateName)) {
|
||||
return "index.vue";
|
||||
}
|
||||
return entityName + templateName + extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件路径
|
||||
*
|
||||
* @param templateName 模板名 Entity
|
||||
* @param moduleName 模块名 system
|
||||
* @param packageName 包名 com.youlai
|
||||
* @param subPackageName 子包名 controller
|
||||
* @param entityName 实体类名 UserController
|
||||
* @return 文件路径 src/main/java/com/youlai/system/controller
|
||||
*/
|
||||
private String getFilePath(String templateName, String moduleName, String packageName, String subPackageName, String entityName) {
|
||||
String path;
|
||||
if ("MapperXml".equals(templateName)) {
|
||||
path = (generatorProperties.getBackendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + "main" + File.separator + "resources"
|
||||
+ File.separator + subPackageName
|
||||
);
|
||||
} else if ("API".equals(templateName)) {
|
||||
path = (generatorProperties.getFrontendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + subPackageName
|
||||
);
|
||||
} else if ("VIEW".equals(templateName)) {
|
||||
path = (generatorProperties.getFrontendAppName()
|
||||
+ File.separator + "src"
|
||||
+ File.separator + subPackageName
|
||||
+ File.separator + moduleName
|
||||
+ File.separator + StrUtil.toSymbolCase(entityName, '-')
|
||||
);
|
||||
} else {
|
||||
path = (generatorProperties.getBackendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + "main" + File.separator + "java"
|
||||
+ File.separator + packageName
|
||||
+ File.separator + moduleName
|
||||
+ File.separator + subPackageName
|
||||
);
|
||||
}
|
||||
|
||||
// subPackageName = model.entity => model/entity
|
||||
path = path.replace(".", File.separator);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成代码内容
|
||||
*
|
||||
* @param templateConfig 模板配置
|
||||
* @param genConfig 生成配置
|
||||
* @param fieldConfigs 字段配置
|
||||
* @return 代码内容
|
||||
*/
|
||||
private String getCodeContent(GeneratorProperties.TemplateConfig templateConfig, GenConfig genConfig, List<GenFieldConfig> fieldConfigs) {
|
||||
|
||||
Map<String, Object> bindMap = new HashMap<>();
|
||||
|
||||
String entityName = genConfig.getEntityName();
|
||||
|
||||
bindMap.put("packageName", genConfig.getPackageName());
|
||||
bindMap.put("moduleName", genConfig.getModuleName());
|
||||
bindMap.put("subpackageName", templateConfig.getSubpackageName());
|
||||
bindMap.put("date", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
||||
bindMap.put("entityName", entityName);
|
||||
bindMap.put("tableName", genConfig.getTableName());
|
||||
bindMap.put("author", genConfig.getAuthor());
|
||||
bindMap.put("lowerFirstEntityName", StrUtil.lowerFirst(entityName)); // UserTest → userTest
|
||||
bindMap.put("kebabCaseEntityName", StrUtil.toSymbolCase(entityName, '-')); // UserTest → user-test
|
||||
bindMap.put("businessName", genConfig.getBusinessName());
|
||||
bindMap.put("fieldConfigs", fieldConfigs);
|
||||
|
||||
boolean hasLocalDateTime = false;
|
||||
boolean hasBigDecimal = false;
|
||||
boolean hasRequiredField = false;
|
||||
|
||||
for (GenFieldConfig fieldConfig : fieldConfigs) {
|
||||
|
||||
if ("LocalDateTime".equals(fieldConfig.getFieldType())) {
|
||||
hasLocalDateTime = true;
|
||||
}
|
||||
if ("BigDecimal".equals(fieldConfig.getFieldType())) {
|
||||
hasBigDecimal = true;
|
||||
}
|
||||
if (ObjectUtil.equals(fieldConfig.getIsRequired(), 1)) {
|
||||
hasRequiredField = true;
|
||||
}
|
||||
fieldConfig.setTsType(JavaTypeEnum.getTsTypeByJavaType(fieldConfig.getFieldType()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
bindMap.put("hasLocalDateTime", hasLocalDateTime);
|
||||
bindMap.put("hasBigDecimal", hasBigDecimal);
|
||||
bindMap.put("hasRequiredField", hasRequiredField);
|
||||
|
||||
TemplateEngine templateEngine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
|
||||
Template template = templateEngine.getTemplate(templateConfig.getTemplatePath());
|
||||
String content = template.render(bindMap);
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载代码
|
||||
*
|
||||
* @param tableNames 表名,可以支持多张表。
|
||||
* @return 压缩文件字节数组
|
||||
*/
|
||||
@Override
|
||||
public byte[] downloadCode(String[] tableNames) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||
for (String tableName : tableNames) {
|
||||
generatorCode(tableName, zip);
|
||||
}
|
||||
IOUtils.closeQuietly(zip);
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名生成代码并且压缩到zip文件中
|
||||
*
|
||||
* @param tableName 单个表名
|
||||
* @param zip 压缩文件
|
||||
*/
|
||||
private void generatorCode(String tableName, ZipOutputStream zip) {
|
||||
List<GeneratorPreviewVO> previewVOList = getTablePreviewData(tableName);
|
||||
for (GeneratorPreviewVO previewVO : previewVOList) {
|
||||
String fileName = previewVO.getFileName();
|
||||
String content = previewVO.getContent();
|
||||
String path = previewVO.getPath();
|
||||
try {
|
||||
zip.putNextEntry(new java.util.zip.ZipEntry(path + File.separator + fileName));
|
||||
zip.write(content.getBytes(StandardCharsets.UTF_8));
|
||||
zip.closeEntry();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.youlai.boot.platform.sms.controller;
|
||||
|
||||
import com.youlai.boot.platform.sms.service.SmsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 短信控制层
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.10.0
|
||||
*/
|
||||
public class SmsController {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import lombok.Data;
|
||||
* @author haoxr
|
||||
* @since 2022/10/28
|
||||
*/
|
||||
@Schema(description ="部门分页查询对象")
|
||||
@Schema(description ="菜单查询对象")
|
||||
@Data
|
||||
public class MenuQuery {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
import com.youlai.boot.system.model.form.MenuForm;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.system.model.entity.Menu;
|
||||
@@ -67,10 +67,10 @@ public interface MenuService extends IService<Menu> {
|
||||
boolean deleteMenu(Long id);
|
||||
|
||||
/**
|
||||
* 为代码生成添加菜单
|
||||
* 代码生成时添加菜单
|
||||
*
|
||||
* @param parentMenuId 父菜单ID
|
||||
* @param genConfig 实体名
|
||||
*/
|
||||
void saveMenu(Long parentMenuId, GenConfig genConfig);
|
||||
void addMenuForCodegen(Long parentMenuId, GenConfig genConfig);
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.youlai.boot.system.converter.MenuConverter;
|
||||
import com.youlai.boot.system.mapper.MenuMapper;
|
||||
import com.youlai.boot.system.model.bo.RouteBO;
|
||||
import com.youlai.boot.platform.generator.model.entity.GenConfig;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
import com.youlai.boot.system.model.entity.Menu;
|
||||
import com.youlai.boot.system.model.form.MenuForm;
|
||||
import com.youlai.boot.system.model.query.MenuQuery;
|
||||
@@ -362,13 +362,13 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
}
|
||||
|
||||
/**
|
||||
* 为代码生成添加菜单
|
||||
* 代码生成时添加菜单
|
||||
*
|
||||
* @param parentMenuId 父菜单ID
|
||||
* @param genConfig 实体名称
|
||||
*/
|
||||
@Override
|
||||
public void saveMenu(Long parentMenuId, GenConfig genConfig) {
|
||||
public void addMenuForCodegen(Long parentMenuId, GenConfig genConfig) {
|
||||
Menu parentMenu = this.getById(parentMenuId);
|
||||
Assert.notNull(parentMenu, "上级菜单不存在");
|
||||
|
||||
@@ -389,7 +389,6 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
sort = maxSortMenu.getSort() + 1;
|
||||
}
|
||||
|
||||
|
||||
Menu menu = new Menu();
|
||||
menu.setParentId(parentMenuId);
|
||||
menu.setName(genConfig.getBusinessName());
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.youlai.boot.common.enums.ContactType;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.platform.mail.service.MailService;
|
||||
import com.youlai.boot.platform.sms.service.SmsService;
|
||||
import com.youlai.boot.module.mail.service.MailService;
|
||||
import com.youlai.boot.module.sms.service.SmsService;
|
||||
import com.youlai.boot.system.model.entity.User;
|
||||
import com.youlai.boot.system.model.form.*;
|
||||
import com.youlai.boot.config.property.AliyunSmsProperties;
|
||||
|
||||
@@ -150,9 +150,9 @@ springdoc:
|
||||
paths-to-match: "/**"
|
||||
packages-to-scan:
|
||||
- com.youlai.boot.system.controller
|
||||
- com.youlai.boot.platform.auth.controller
|
||||
- com.youlai.boot.platform.file.controller
|
||||
- com.youlai.boot.platform.generator.controller
|
||||
- com.youlai.boot.module.auth.controller
|
||||
- com.youlai.boot.module.file.controller
|
||||
- com.youlai.boot.module.generator.controller
|
||||
default-flat-param-object: true
|
||||
|
||||
# knife4j 接口文档配置
|
||||
|
||||
@@ -134,9 +134,9 @@ springdoc:
|
||||
paths-to-match: "/**"
|
||||
packages-to-scan:
|
||||
- com.youlai.boot.system.controller
|
||||
- com.youlai.boot.platform.auth.controller
|
||||
- com.youlai.boot.platform.file.controller
|
||||
- com.youlai.boot.platform.generator.controller
|
||||
- com.youlai.boot.module.auth.controller
|
||||
- com.youlai.boot.module.file.controller
|
||||
- com.youlai.boot.module.generator.controller
|
||||
default-flat-param-object: true
|
||||
|
||||
# knife4j 接口文档配置
|
||||
|
||||
@@ -5,7 +5,7 @@ spring:
|
||||
active: dev
|
||||
|
||||
# 代码生成器配置
|
||||
generator:
|
||||
codegen:
|
||||
# 下载代码文件名称
|
||||
downloadFileName: youlai-admin-code.zip
|
||||
# 后端项目名称
|
||||
@@ -23,43 +23,43 @@ generator:
|
||||
## 模板配置
|
||||
templateConfigs:
|
||||
API:
|
||||
templatePath: generator/api.ts.vm
|
||||
templatePath: codegen/api.ts.vm
|
||||
subpackageName: api
|
||||
extension: .ts
|
||||
VIEW:
|
||||
templatePath: generator/index.vue.vm
|
||||
templatePath: codegen/index.vue.vm
|
||||
subpackageName: views
|
||||
extension: .vue
|
||||
Controller:
|
||||
templatePath: generator/controller.java.vm
|
||||
templatePath: codegen/controller.java.vm
|
||||
subpackageName: controller
|
||||
Service:
|
||||
templatePath: generator/service.java.vm
|
||||
templatePath: codegen/service.java.vm
|
||||
subpackageName: service
|
||||
ServiceImpl:
|
||||
templatePath: generator/serviceImpl.java.vm
|
||||
templatePath: codegen/serviceImpl.java.vm
|
||||
subpackageName: service.impl
|
||||
Mapper:
|
||||
templatePath: generator/mapper.java.vm
|
||||
templatePath: codegen/mapper.java.vm
|
||||
subpackageName: mapper
|
||||
MapperXml:
|
||||
templatePath: generator/mapper.xml.vm
|
||||
templatePath: codegen/mapper.xml.vm
|
||||
subpackageName: mapper
|
||||
extension: .xml
|
||||
Converter:
|
||||
templatePath: generator/converter.java.vm
|
||||
templatePath: codegen/converter.java.vm
|
||||
subpackageName: converter
|
||||
Query:
|
||||
templatePath: generator/query.java.vm
|
||||
templatePath: codegen/query.java.vm
|
||||
subpackageName: model.query
|
||||
Form:
|
||||
templatePath: generator/form.java.vm
|
||||
templatePath: codegen/form.java.vm
|
||||
subpackageName: model.form
|
||||
VO:
|
||||
templatePath: generator/vo.java.vm
|
||||
templatePath: codegen/vo.java.vm
|
||||
subpackageName: model.vo
|
||||
Entity:
|
||||
templatePath: generator/entity.java.vm
|
||||
templatePath: codegen/entity.java.vm
|
||||
subpackageName: model.entity
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.youlai.boot.platform.generator.mapper.DatabaseMapper">
|
||||
<mapper namespace="com.youlai.boot.module.codegen.mapper.DatabaseMapper">
|
||||
|
||||
<!-- 查询数据库表分页 -->
|
||||
<select id="getTablePage" resultType="com.youlai.boot.platform.generator.model.vo.TablePageVO">
|
||||
<select id="getTablePage" resultType="com.youlai.boot.module.codegen.model.vo.TablePageVO">
|
||||
SELECT
|
||||
t1.TABLE_NAME ,
|
||||
t1.TABLE_COMMENT ,
|
||||
@@ -33,7 +33,7 @@
|
||||
CREATE_TIME DESC
|
||||
</select>
|
||||
|
||||
<select id="getTableMetadata" resultType="com.youlai.boot.platform.generator.model.bo.TableMetaData">
|
||||
<select id="getTableMetadata" resultType="com.youlai.boot.module.codegen.model.bo.TableMetaData">
|
||||
SELECT
|
||||
TABLE_NAME ,
|
||||
TABLE_COMMENT ,
|
||||
@@ -47,7 +47,7 @@
|
||||
AND TABLE_NAME = #{tableName}
|
||||
</select>
|
||||
|
||||
<select id="getTableColumns" resultType="com.youlai.boot.platform.generator.model.bo.ColumnMetaData">
|
||||
<select id="getTableColumns" resultType="com.youlai.boot.module.codegen.model.bo.ColumnMetaData">
|
||||
SELECT
|
||||
COLUMN_NAME,
|
||||
DATA_TYPE,
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.youlai.boot.platform.generator.mapper.GenConfigMapper">
|
||||
<mapper namespace="com.youlai.boot.module.codegen.mapper.GenConfigMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.youlai.boot.platform.generator.mapper.GenFieldConfigMapper">
|
||||
<mapper namespace="com.youlai.boot.module.generator.mapper.GenFieldConfigMapper">
|
||||
|
||||
</mapper>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -48,12 +48,12 @@ public class FastAutoGeneratorTest {
|
||||
// 注入配置(设置扩展类的模板路径和包路径)
|
||||
.injectionConfig(consumer -> {
|
||||
List<CustomFile> customFiles = new ArrayList<>();
|
||||
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/generator/vo.java.vm").packageName("model.vo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("BO.java").templatePath("/templates/generator/bo.java.vm").packageName("model.bo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("PageQuery.java").templatePath("/templates/generator/query.java.vm").packageName("model.query").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("PageVO.java").templatePath("/templates/pageVO.java.vm").packageName("model.vo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("Form.java").templatePath("/templates/generator/form.java.vm").packageName("model.form").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("Converter.java").templatePath("/templates/generator/converter.java.vm").packageName("converter").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/codegen/vo.java.vm").packageName("model.vo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("BO.java").templatePath("/templates/codegen/bo.java.vm").packageName("model.bo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("PageQuery.java").templatePath("/templates/codegen/query.java.vm").packageName("model.query").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("PageVO.java").templatePath("/templates/codegen/pageVO.java.vm").packageName("model.vo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("Form.java").templatePath("/templates/codegen/form.java.vm").packageName("model.form").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("Converter.java").templatePath("/templates/codegen/converter.java.vm").packageName("converter").build());
|
||||
consumer.customFile(customFiles);
|
||||
consumer.beforeOutputFile((tableInfo, objectMap) -> {
|
||||
// 为每个表生成首字母小写的实体名
|
||||
|
||||
Reference in new issue
Block a user