diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/MssqlSysConfigData.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/MssqlSysConfigData.java new file mode 100644 index 000000000..c070ccf75 --- /dev/null +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/MssqlSysConfigData.java @@ -0,0 +1,34 @@ +package cn.stylefeng.roses.kernel.config.modular.data; + +import cn.hutool.db.Entity; +import cn.hutool.db.handler.EntityListHandler; +import cn.hutool.db.sql.SqlExecutor; +import cn.stylefeng.roses.kernel.config.api.SysConfigDataApi; +import cn.stylefeng.roses.kernel.rule.enums.StatusEnum; +import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +/** + * Mssql数据库的系统配置表获取 + * + * @author AndrewFeng + * @date 2021/5/14 21:18 + */ +@Slf4j +public class MssqlSysConfigData implements SysConfigDataApi { + + @Override + public List getConfigs(Connection conn) throws SQLException { + return SqlExecutor.query(conn, getConfigListSql(), new EntityListHandler(), StatusEnum.ENABLE.getCode(), YesOrNotEnum.N.getCode()); + } + + @Override + public String getConfigListSql() { + return "select config_code, config_value from sys_config where status_flag = ? and del_flag = ?"; + } + +} diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/OracleSysConfigData.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/OracleSysConfigData.java new file mode 100644 index 000000000..270c92b59 --- /dev/null +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/OracleSysConfigData.java @@ -0,0 +1,34 @@ +package cn.stylefeng.roses.kernel.config.modular.data; + +import cn.hutool.db.Entity; +import cn.hutool.db.handler.EntityListHandler; +import cn.hutool.db.sql.SqlExecutor; +import cn.stylefeng.roses.kernel.config.api.SysConfigDataApi; +import cn.stylefeng.roses.kernel.rule.enums.StatusEnum; +import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +/** + * Oracle数据库的系统配置表获取 + * + * @author AndrewFeng + * @date 2021/5/14 21:18 + */ +@Slf4j +public class OracleSysConfigData implements SysConfigDataApi { + + @Override + public List getConfigs(Connection conn) throws SQLException { + return SqlExecutor.query(conn, getConfigListSql(), new EntityListHandler(), StatusEnum.ENABLE.getCode(), YesOrNotEnum.N.getCode()); + } + + @Override + public String getConfigListSql() { + return "select config_code, config_value from sys_config where status_flag = ? and del_flag = ?"; + } + +} diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/PgsqlSysConfigData.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/PgsqlSysConfigData.java new file mode 100644 index 000000000..03bf1d802 --- /dev/null +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/data/PgsqlSysConfigData.java @@ -0,0 +1,34 @@ +package cn.stylefeng.roses.kernel.config.modular.data; + +import cn.hutool.db.Entity; +import cn.hutool.db.handler.EntityListHandler; +import cn.hutool.db.sql.SqlExecutor; +import cn.stylefeng.roses.kernel.config.api.SysConfigDataApi; +import cn.stylefeng.roses.kernel.rule.enums.StatusEnum; +import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +/** + * Pgsql数据库的系统配置表获取 + * + * @author AndrewFeng + * @date 2021/5/14 21:18 + */ +@Slf4j +public class PgsqlSysConfigData implements SysConfigDataApi { + + @Override + public List getConfigs(Connection conn) throws SQLException { + return SqlExecutor.query(conn, getConfigListSql(), new EntityListHandler(), StatusEnum.ENABLE.getCode(), YesOrNotEnum.N.getCode()); + } + + @Override + public String getConfigListSql() { + return "select config_code, config_value from sys_config where status_flag = ? and del_flag = ?"; + } + +} diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/factory/SysConfigDataFactory.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/factory/SysConfigDataFactory.java index d5c674406..059c069ef 100644 --- a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/factory/SysConfigDataFactory.java +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/factory/SysConfigDataFactory.java @@ -1,7 +1,10 @@ package cn.stylefeng.roses.kernel.config.modular.factory; import cn.stylefeng.roses.kernel.config.api.SysConfigDataApi; +import cn.stylefeng.roses.kernel.config.modular.data.MssqlSysConfigData; import cn.stylefeng.roses.kernel.config.modular.data.MysqlSysConfigData; +import cn.stylefeng.roses.kernel.config.modular.data.OracleSysConfigData; +import cn.stylefeng.roses.kernel.config.modular.data.PgsqlSysConfigData; import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum; import cn.stylefeng.roses.kernel.rule.util.DatabaseTypeUtil; @@ -24,11 +27,11 @@ public class SysConfigDataFactory { if (DbTypeEnum.MYSQL.equals(dbType)) { return new MysqlSysConfigData(); } else if (DbTypeEnum.PG_SQL.equals(dbType)) { - // todo + return new PgsqlSysConfigData(); } else if (DbTypeEnum.MS_SQL.equals(dbType)) { - // todo + return new MssqlSysConfigData(); } else if (DbTypeEnum.ORACLE.equals(dbType)) { - // todo + return new OracleSysConfigData(); } return new MysqlSysConfigData(); } diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/listener/ConfigInitListener.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/listener/ConfigInitListener.java index ea5b71d8b..df318bde4 100644 --- a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/listener/ConfigInitListener.java +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/listener/ConfigInitListener.java @@ -100,7 +100,7 @@ public class ConfigInitListener extends ContextInitializedListener implements Or entityList.forEach(sysConfig -> ConfigContext.me().putConfig(sysConfig.getStr("config_code"), sysConfig.getStr("config_value"))); } } catch (ClassNotFoundException e) { - log.error("初始化系统配置表失败,找不到com.mysql.cj.jdbc.Driver类", e); + log.error("初始化系统配置表失败,找不到{}类 : {}",driverClassName,e); throw new ConfigException(ConfigExceptionEnum.CLASS_NOT_FOUND_ERROR); } catch (SQLException sqlException) { log.error("初始化系统配置表失败,执行查询语句失败", sqlException); diff --git a/kernel-d-db/db-sdk-flyway/src/main/java/cn/stylefeng/roses/kernel/db/flyway/FlywayInitListener.java b/kernel-d-db/db-sdk-flyway/src/main/java/cn/stylefeng/roses/kernel/db/flyway/FlywayInitListener.java index d670af6d5..995dc8e0a 100644 --- a/kernel-d-db/db-sdk-flyway/src/main/java/cn/stylefeng/roses/kernel/db/flyway/FlywayInitListener.java +++ b/kernel-d-db/db-sdk-flyway/src/main/java/cn/stylefeng/roses/kernel/db/flyway/FlywayInitListener.java @@ -47,7 +47,7 @@ import org.springframework.jdbc.datasource.DriverManagerDataSource; @Slf4j public class FlywayInitListener extends ContextInitializedListener implements Ordered { - private static final String FLYWAY_LOCATIONS = "classpath:db/migration"; + private static final String FLYWAY_LOCATIONS = "classpath:db/migration/mysql"; @Override public void eventCallback(ApplicationContextInitializedEvent event) { @@ -55,10 +55,10 @@ public class FlywayInitListener extends ContextInitializedListener implements Or ConfigurableEnvironment environment = event.getApplicationContext().getEnvironment(); // 获取数据库连接配置 + String driverClassName = environment.getProperty("spring.datasource.driver-class-name"); String dataSourceUrl = environment.getProperty("spring.datasource.url"); String dataSourceUsername = environment.getProperty("spring.datasource.username"); String dataSourcePassword = environment.getProperty("spring.datasource.password"); - String driverClassName = environment.getProperty("spring.datasource.driver-class-name"); // flyway的配置 String enabledStr = environment.getProperty("spring.flyway.enabled"); diff --git a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/DataBaseInfoPersistence.java b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/DataBaseInfoPersistence.java index 139eaf5e5..999a0111d 100644 --- a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/DataBaseInfoPersistence.java +++ b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/DataBaseInfoPersistence.java @@ -104,6 +104,7 @@ public class DataBaseInfoPersistence { PreparedStatement preparedStatement = conn.prepareStatement(new AddDatabaseInfoSql().getSql(druidProperties.getUrl())); preparedStatement.setLong(1, IdWorker.getId()); + preparedStatement.setString(2, MASTER_DATASOURCE_NAME); preparedStatement.setString(3, druidProperties.getDriverClassName()); preparedStatement.setString(4, druidProperties.getUrl()); diff --git a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/AddDatabaseInfoSql.java b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/AddDatabaseInfoSql.java index fa22e783c..b815b1a8e 100644 --- a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/AddDatabaseInfoSql.java +++ b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/AddDatabaseInfoSql.java @@ -1,27 +1,3 @@ -/* - * Copyright [2020-2030] [https://www.stylefeng.cn] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: - * - * 1.请不要删除和修改根目录下的LICENSE文件。 - * 2.请不要删除和修改Guns源码头部的版权声明。 - * 3.请保留源码和相关描述文件的项目出处,作者声明等。 - * 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns - * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns - * 6.若您的项目无法满足以上几点,可申请商业授权 - */ package cn.stylefeng.roses.kernel.dsctn.persist.sqls; import lombok.Getter; @@ -47,11 +23,11 @@ public class AddDatabaseInfoSql extends AbstractSql { @Override protected String pgSql() { - return "INSERT INTO sys_database_info(db_id, db_name, jdbc_driver, jdbc_url, username, password, remarks, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, to_timestamp(?,'YYYY-MM-DD HH24:MI:SS'))"; + return "INSERT INTO sys_database_info(db_id, db_name, jdbc_driver, jdbc_url, username, password, remarks, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, to_timestamp(?,'YYYY-MM-DD HH24:MI:SS'))"; } @Override protected String oracle() { - return "INSERT INTO sys_database_info VALUES (?, ?, ?, ?, ?, ?, ?, to_date(?, 'yyyy-mm-dd hh24:mi:ss'))"; + return "INSERT INTO sys_database_info(db_id, db_name, jdbc_driver, jdbc_url, username, password, remarks, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, to_date(?, 'yyyy-mm-dd hh24:mi:ss'))"; } } diff --git a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/CreateDatabaseSql.java b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/CreateDatabaseSql.java index 35269cd5f..11b99e831 100644 --- a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/CreateDatabaseSql.java +++ b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/CreateDatabaseSql.java @@ -42,16 +42,18 @@ public class CreateDatabaseSql extends AbstractSql { @Override protected String sqlServer() { - return ""; + return "if not exists (select * from sysobjects where name=? and xtype='U')\n" + + " create table ? ;" + + "go"; } @Override protected String pgSql() { - return ""; + return "CREATE DATABASE ?;"; } @Override protected String oracle() { - return ""; + return "create tablespace ? datafile '/opt/oracle/guns.dbf' size 500m autoextend on next 5m maxsize unlimited;"; } } diff --git a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/DropDatabaseSql.java b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/DropDatabaseSql.java index 95a3c6a2a..beaf85821 100644 --- a/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/DropDatabaseSql.java +++ b/kernel-d-ds-container/ds-container-sdk/src/main/java/cn/stylefeng/roses/kernel/dsctn/persist/sqls/DropDatabaseSql.java @@ -42,16 +42,16 @@ public class DropDatabaseSql extends AbstractSql { @Override protected String sqlServer() { - return ""; + return "DROP DATABASE ?;"; } @Override protected String pgSql() { - return ""; + return "DROP DATABASE ?;"; } @Override protected String oracle() { - return ""; + return "DROP DATASPACE ?;"; } } diff --git a/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/listener/TaskRunListener.java b/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/listener/TaskRunListener.java index 5303a75f9..6eac50c5a 100644 --- a/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/listener/TaskRunListener.java +++ b/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/listener/TaskRunListener.java @@ -57,6 +57,7 @@ public class TaskRunListener extends ApplicationStartedListener implements Order // 获取数据库所有开启状态的任务 SysTimersParam sysTimersParam = new SysTimersParam(); + sysTimersParam.setDelFlag("N"); sysTimersParam.setJobStatus(TimerJobStatusEnum.RUNNING.getCode()); List list = sysTimersService.findList(sysTimersParam); diff --git a/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/param/SysTimersParam.java b/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/param/SysTimersParam.java index 4783deefc..3f36fdc76 100644 --- a/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/param/SysTimersParam.java +++ b/kernel-d-timer/timer-business/src/main/java/cn/stylefeng/roses/kernel/timer/modular/param/SysTimersParam.java @@ -81,6 +81,11 @@ public class SysTimersParam extends BaseRequest { */ private String remark; + /** + * 是否删除标记 + */ + private String delFlag; + /** * 启用定时任务 */ diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictInitializer.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictInitializer.java index 21bd2643b..240de5cc0 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictInitializer.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictInitializer.java @@ -33,31 +33,32 @@ import org.springframework.stereotype.Component; * * @author majianguo * @date 2020/12/9 上午11:02 + * @see cn.stylefeng.roses.kernel.dsctn.persist.sqls.AbstractSql */ @Component public class DictInitializer extends DbInitializer { @Override protected String getTableInitSql() { - return "CREATE TABLE `sys_dict` (\n" + - " `dict_id` bigint(20) NOT NULL COMMENT '字典id',\n" + - " `dict_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典编码',\n" + - " `dict_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典名称',\n" + - " `dict_name_pinyin` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典名称首字母',\n" + - " `dict_encode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典编码',\n" + - " `dict_type_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典类型的编码',\n" + - " `dict_short_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典简称',\n" + - " `dict_short_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典简称的编码',\n" + - " `dict_parent_id` bigint(20) NOT NULL COMMENT '上级字典的id(如果没有上级字典id,则为-1)',\n" + - " `status_flag` tinyint(4) NOT NULL COMMENT '状态:(1-启用,2-禁用),参考 StatusEnum',\n" + - " `dict_sort` decimal(10, 2) NULL DEFAULT NULL COMMENT '排序,带小数点',\n" + - " `dict_pids` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '父id集合',\n" + - " `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' COMMENT '是否删除,Y-被删除,N-未删除',\n" + - " `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',\n" + - " `create_user` bigint(20) NULL DEFAULT NULL COMMENT '创建用户id',\n" + - " `update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',\n" + - " `update_user` bigint(20) NULL DEFAULT NULL COMMENT '修改用户id',\n" + - " PRIMARY KEY (`dict_id`) USING BTREE\n" + + return "CREATE TABLE sys_dict (\n" + + " dict_id bigint(20) NOT NULL COMMENT '字典id',\n" + + " dict_code varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典编码',\n" + + " dict_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典名称',\n" + + " dict_name_pinyin varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典名称首字母',\n" + + " dict_encode varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典编码',\n" + + " dict_type_code varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典类型的编码',\n" + + " dict_short_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典简称',\n" + + " dict_short_code varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典简称的编码',\n" + + " dict_parent_id bigint(20) NOT NULL COMMENT '上级字典的id(如果没有上级字典id,则为-1)',\n" + + " status_flag tinyint(4) NOT NULL COMMENT '状态:(1-启用,2-禁用),参考 StatusEnum',\n" + + " dict_sort decimal(10, 2) NULL DEFAULT NULL COMMENT '排序,带小数点',\n" + + " dict_pids varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '父id集合',\n" + + " del_flag char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' COMMENT '是否删除,Y-被删除,N-未删除',\n" + + " create_time datetime(0) NULL DEFAULT NULL COMMENT '创建时间',\n" + + " create_user bigint(20) NULL DEFAULT NULL COMMENT '创建用户id',\n" + + " update_time datetime(0) NULL DEFAULT NULL COMMENT '修改时间',\n" + + " update_user bigint(20) NULL DEFAULT NULL COMMENT '修改用户id',\n" + + " PRIMARY KEY (dict_id) USING BTREE\n" + ") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典表' ROW_FORMAT = Dynamic;"; } diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictTypeInitializer.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictTypeInitializer.java index 2f583aa50..810f938d7 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictTypeInitializer.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/db/init/DictTypeInitializer.java @@ -33,28 +33,29 @@ import org.springframework.stereotype.Component; * * @author majianguo * @date 2020/12/9 上午11:02 + * @see cn.stylefeng.roses.kernel.dsctn.persist.sqls.AbstractSql */ @Component public class DictTypeInitializer extends DbInitializer { @Override protected String getTableInitSql() { - return "CREATE TABLE `sys_dict_type` (\n" + - " `dict_type_id` bigint(20) NOT NULL COMMENT '字典类型id',\n" + - " `dict_type_class` int(2) NULL DEFAULT NULL COMMENT '字典类型: 1-业务类型,2-系统类型,参考 DictTypeClassEnum',\n" + - " `dict_type_bus_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型业务编码',\n" + - " `dict_type_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型编码',\n" + - " `dict_type_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型名称',\n" + - " `dict_type_name_pinyin` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型名称首字母拼音',\n" + - " `dict_type_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型描述',\n" + - " `status_flag` tinyint(4) NULL DEFAULT NULL COMMENT '字典类型的状态:1-启用,2-禁用,参考 StatusEnum',\n" + - " `dict_type_sort` decimal(10, 2) NULL DEFAULT NULL COMMENT '排序,带小数点',\n" + - " `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' COMMENT '是否删除:Y-被删除,N-未删除',\n" + - " `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',\n" + - " `create_user` bigint(20) NULL DEFAULT NULL COMMENT '创建用户id',\n" + - " `update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',\n" + - " `update_user` bigint(20) NULL DEFAULT NULL COMMENT '修改用户id',\n" + - " PRIMARY KEY (`dict_type_id`) USING BTREE\n" + + return "CREATE TABLE sys_dict_type (\n" + + " dict_type_id bigint(20) NOT NULL COMMENT '字典类型id',\n" + + " dict_type_class int(2) NULL DEFAULT NULL COMMENT '字典类型: 1-业务类型,2-系统类型,参考 DictTypeClassEnum',\n" + + " dict_type_bus_code varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型业务编码',\n" + + " dict_type_code varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型编码',\n" + + " dict_type_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型名称',\n" + + " dict_type_name_pinyin varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型名称首字母拼音',\n" + + " dict_type_desc varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '字典类型描述',\n" + + " status_flag tinyint(4) NULL DEFAULT NULL COMMENT '字典类型的状态:1-启用,2-禁用,参考 StatusEnum',\n" + + " dict_type_sort decimal(10, 2) NULL DEFAULT NULL COMMENT '排序,带小数点',\n" + + " del_flag char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' COMMENT '是否删除:Y-被删除,N-未删除',\n" + + " create_time datetime(0) NULL DEFAULT NULL COMMENT '创建时间',\n" + + " create_user bigint(20) NULL DEFAULT NULL COMMENT '创建用户id',\n" + + " update_time datetime(0) NULL DEFAULT NULL COMMENT '修改时间',\n" + + " update_user bigint(20) NULL DEFAULT NULL COMMENT '修改用户id',\n" + + " PRIMARY KEY (dict_type_id) USING BTREE\n" + ") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表,一个字典类型下有多个字典' ROW_FORMAT = Dynamic;"; }