From 0824ce86d3b3d2c7f44df4cdb0769112204e1ef1 Mon Sep 17 00:00:00 2001 From: Parker Date: Fri, 20 Nov 2020 10:57:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8?= =?UTF-8?q?=20=E7=BB=9F=E4=B8=80=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../creater/exception/CreaterException.java | 37 +++++++++++++++++++ .../opsli/core/creater/msg/CreaterMsg.java | 2 +- .../strategy/sync/MySQLSyncBuilder.java | 10 ++--- .../sync/mysql/entity/FieldTypeAttribute.java | 2 +- .../sync/mysql/enums/MySQLSyncColumnType.java | 2 +- .../strategy/sync/util/SQLSyncUtil.java | 2 +- .../service/impl/TableColumnServiceImpl.java | 7 ++-- .../table/service/impl/TableServiceImpl.java | 7 ++-- .../table/web/TableRestController.java | 3 +- .../src/main/resources/creater.yaml | 4 +- 10 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/exception/CreaterException.java diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/exception/CreaterException.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/exception/CreaterException.java new file mode 100644 index 0000000..cbb7ba1 --- /dev/null +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/exception/CreaterException.java @@ -0,0 +1,37 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.opsli.core.creater.exception; + +import org.opsli.common.base.msg.BaseMsg; +import org.opsli.common.exception.ServiceException; + +/** + * @BelongsProject: opsli-boot + * @BelongsPackage: org.opsli.core.creater.exception + * @Author: Parker + * @CreateTime: 2020-09-14 18:44 + * @Description: 代码生成器 异常 + */ +public class CreaterException extends ServiceException { + + public CreaterException(Integer code, String errorMessage) { + super(code, errorMessage); + } + + public CreaterException(BaseMsg msg) { + super(msg); + } +} diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/msg/CreaterMsg.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/msg/CreaterMsg.java index eea080f..4842b59 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/msg/CreaterMsg.java +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/msg/CreaterMsg.java @@ -19,7 +19,7 @@ import org.opsli.common.base.msg.BaseMsg; /** * @BelongsProject: opsli-boot - * @BelongsPackage: org.opsli.core.msg + * @BelongsPackage: org.opsli.core.creater.msg * @Author: Parker * @CreateTime: 2020-09-13 19:36 * @Description: 代码生成器 - 消息 diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/MySQLSyncBuilder.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/MySQLSyncBuilder.java index a7f29bd..310e10f 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/MySQLSyncBuilder.java +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/MySQLSyncBuilder.java @@ -1,9 +1,8 @@ package org.opsli.core.creater.strategy.sync; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.opsli.common.exception.ServiceException; import org.opsli.common.utils.Props; +import org.opsli.core.creater.exception.CreaterException; import org.opsli.core.creater.msg.CreaterMsg; import org.opsli.core.creater.strategy.sync.mysql.entity.FieldTypeAttribute; import org.opsli.core.creater.strategy.sync.mysql.enums.MySQLSyncColumnType; @@ -17,12 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.List; /** * @BelongsProject: opsli-boot - * @BelongsPackage: org.opsli.modulars.creater.strategy.sync.mysql + * @BelongsPackage: org.opsli.modulars.creater.strategy.sync * @Author: Parker * @CreateTime: 2020-11-18 13:21 * @Description: MySQL 同步构建器 @@ -71,13 +69,13 @@ public class MySQLSyncBuilder implements SyncStrategy { CreaterTableModel currTable = iTableService.get(model.getId()); if(currTable == null){ // 同步表失败,暂无该表 - throw new ServiceException(CreaterMsg.EXCEPTION_SYNC_NULL); + throw new CreaterException(CreaterMsg.EXCEPTION_SYNC_NULL); } // 排查该表 是否是 在排除外的表, 如果是则不允许同步 if(EXCLUDE_TABLES.contains(currTable.getOldTableName()) || EXCLUDE_TABLES.contains(currTable.getTableName())){ // 同步表失败 系统核心关键表不允许同步 - throw new ServiceException(CreaterMsg.EXCEPTION_SYNC_CORE); + throw new CreaterException(CreaterMsg.EXCEPTION_SYNC_CORE); } // 删除表 diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/entity/FieldTypeAttribute.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/entity/FieldTypeAttribute.java index 7fd8938..bc53bc6 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/entity/FieldTypeAttribute.java +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/entity/FieldTypeAttribute.java @@ -6,7 +6,7 @@ import lombok.Data; /** * @BelongsProject: opsli-boot - * @BelongsPackage: org.opsli.modulars.creater.strategy.sync.mysql + * @BelongsPackage: org.opsli.core.creater.strategy.sync.mysql.entity * @Author: Parker * @CreateTime: 2020-11-18 13:21 * @Description: MySQL 字段类型 属性 diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/enums/MySQLSyncColumnType.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/enums/MySQLSyncColumnType.java index 5eff425..52fd562 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/enums/MySQLSyncColumnType.java +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/mysql/enums/MySQLSyncColumnType.java @@ -9,7 +9,7 @@ import java.util.Map; /** * @BelongsProject: opsli-boot - * @BelongsPackage: org.opsli.modulars.creater.strategy.sync.mysql + * @BelongsPackage: org.opsli.core.creater.strategy.sync.mysql.enums * @Author: Parker * @CreateTime: 2020-11-18 13:21 * @Description: MySQL 字段类型 判断 diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/util/SQLSyncUtil.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/util/SQLSyncUtil.java index c0536f8..d47d2ea 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/util/SQLSyncUtil.java +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/core/creater/strategy/sync/util/SQLSyncUtil.java @@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentMap; /** * @BelongsProject: opsli-boot - * @BelongsPackage: org.opsli.plugins.redis.entity + * @BelongsPackage: org.opsli.core.creater.strategy.sync.util * @Author: Parker * @CreateTime: 2020-09-15 14:50 * @Description: 数据库同步策略 工具类 diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/column/service/impl/TableColumnServiceImpl.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/column/service/impl/TableColumnServiceImpl.java index ef7e6fa..70ce671 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/column/service/impl/TableColumnServiceImpl.java +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/column/service/impl/TableColumnServiceImpl.java @@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils; import org.opsli.api.utils.ValidationUtil; import org.opsli.common.exception.ServiceException; import org.opsli.core.base.service.impl.CrudServiceImpl; +import org.opsli.core.creater.exception.CreaterException; import org.opsli.core.creater.msg.CreaterMsg; import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.QueryBuilder; @@ -60,7 +61,7 @@ public class TableColumnServiceImpl extends CrudServiceImpl 0){ // 重复 - throw new ServiceException(CreaterMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); + throw new CreaterException(CreaterMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); } return super.insert(model); @@ -87,7 +88,7 @@ public class TableColumnServiceImpl extends CrudServiceImpl 0){ // 重复 - throw new ServiceException(CreaterMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); + throw new CreaterException(CreaterMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); } // 默认清空 创建人和修改人 @@ -119,7 +120,7 @@ public class TableColumnServiceImpl extends CrudServiceImpl 0){ // 重复 - throw new ServiceException(CreaterMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); + throw new CreaterException(CreaterMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); } return super.update(model); diff --git a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/table/service/impl/TableServiceImpl.java b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/table/service/impl/TableServiceImpl.java index 51a0a06..8feb1ae 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/table/service/impl/TableServiceImpl.java +++ b/opsli-modulars/opsli-modulars-creater/src/main/java/org/opsli/modulars/creater/table/service/impl/TableServiceImpl.java @@ -20,6 +20,7 @@ import org.opsli.common.enums.DictType; import org.opsli.common.exception.ServiceException; import org.opsli.common.utils.WrapperUtil; import org.opsli.core.base.service.impl.CrudServiceImpl; +import org.opsli.core.creater.exception.CreaterException; import org.opsli.core.creater.msg.CreaterMsg; import org.opsli.modulars.creater.column.service.ITableColumnService; import org.opsli.modulars.creater.column.wrapper.CreaterTableColumnModel; @@ -65,7 +66,7 @@ public class TableServiceImpl extends CrudServiceImpl 0){ // 重复 - throw new ServiceException(CreaterMsg.EXCEPTION_TABLE_NAME_REPEAT); + throw new CreaterException(CreaterMsg.EXCEPTION_TABLE_NAME_REPEAT); } if(!model.getIzApi()){ @@ -90,7 +91,7 @@ public class TableServiceImpl extends CrudServiceImpl 0){ // 重复 - throw new ServiceException(CreaterMsg.EXCEPTION_TABLE_NAME_REPEAT); + throw new CreaterException(CreaterMsg.EXCEPTION_TABLE_NAME_REPEAT); } CreaterTableModel oldModel = this.get(model.getId()); @@ -195,7 +196,7 @@ public class TableServiceImpl extends CrudServiceImpl importTables(String[] tableNames) { if(tableNames == null){ // 未选中表,无法导入 - throw new ServiceException(CreaterMsg.EXCEPTION_IMPORT_NULL); + throw new CreaterException(CreaterMsg.EXCEPTION_IMPORT_NULL); } IService.importTables(tableNames); return ResultVo.success("导入成功"); diff --git a/opsli-modulars/opsli-modulars-creater/src/main/resources/creater.yaml b/opsli-modulars/opsli-modulars-creater/src/main/resources/creater.yaml index 30ab981..c697abd 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/resources/creater.yaml +++ b/opsli-modulars/opsli-modulars-creater/src/main/resources/creater.yaml @@ -1,9 +1,9 @@ -# 排除表 防止代码生成器直接 非法删除关键表 opsli: - # 数据库类型 mysql oracle + # 数据库类型 mysql (oracle 暂不支持) db-type: mysql # 数据库名 db-name: opsli-boot + # 排除表 防止代码生成器直接 非法删除关键表 exclude-tables: - creater_table - creater_table_column