代码生成器 统一异常

v1.4.1
Parker 4 years ago
parent 37f6b62975
commit 0824ce86d3

@ -0,0 +1,37 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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);
}
}

@ -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: -

@ -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);
}
// 删除表

@ -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

@ -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

@ -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:

@ -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<TableColumnMapper, C
Integer count = mapper.uniqueVerificationByFieldName(entity);
if(count != null && count > 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<TableColumnMapper, C
Integer count = mapper.uniqueVerificationByFieldName(entity);
if(count != null && count > 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<TableColumnMapper, C
Integer count = mapper.uniqueVerificationByFieldName(entity);
if(count != null && count > 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);

@ -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<TableMapper, CreaterTable,
Integer count = mapper.uniqueVerificationByTableName(entity);
if(count != null && count > 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<TableMapper, CreaterTable,
Integer count = mapper.uniqueVerificationByTableName(entity);
if(count != null && count > 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<TableMapper, CreaterTable,
if(table == null){
String msg = StrUtil.format(CreaterMsg.EXCEPTION_IMPORT_TABLE_NULL.getMessage(), tableName);
// 暂无该表
throw new ServiceException(CreaterMsg.EXCEPTION_IMPORT_TABLE_NULL.getCode(), msg);
throw new CreaterException(CreaterMsg.EXCEPTION_IMPORT_TABLE_NULL.getCode(), msg);
}
// 获得表字段

@ -24,6 +24,7 @@ import org.opsli.common.annotation.EnableLog;
import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.concroller.BaseRestController;
import org.opsli.core.creater.exception.CreaterException;
import org.opsli.core.creater.msg.CreaterMsg;
import org.opsli.core.creater.strategy.sync.util.SQLSyncUtil;
import org.opsli.core.msg.CoreMsg;
@ -241,7 +242,7 @@ public class TableRestController extends BaseRestController<CreaterTable, Create
public ResultVo<?> 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("导入成功");

@ -1,9 +1,9 @@
# 排除表 防止代码生成器直接 非法删除关键表
opsli:
# 数据库类型 mysql oracle
# 数据库类型 mysql oracle 暂不支持)
db-type: mysql
# 数据库名
db-name: opsli-boot
# 排除表 防止代码生成器直接 非法删除关键表
exclude-tables:
- creater_table
- creater_table_column

Loading…
Cancel
Save