mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
1.代码生成模块,基于DB导入时,多个schema下有相同的表,导入异常的问题处理.
This commit is contained in:
parent
8ac17b9241
commit
cb2570c086
@ -10,8 +10,9 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface ToolSchemaColumnMapper extends BaseMapperX<ToolSchemaColumnDO> {
|
||||
|
||||
default List<ToolSchemaColumnDO> selectListByTableName(String tableName) {
|
||||
default List<ToolSchemaColumnDO> selectListByTableName(String tableSchema,String tableName) {
|
||||
return selectList(new QueryWrapper<ToolSchemaColumnDO>().eq("table_name", tableName)
|
||||
.eq("table_schema", tableSchema)
|
||||
.orderByAsc("ordinal_position"));
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,9 @@ public interface ToolSchemaTableMapper extends BaseMapperX<ToolSchemaTableDO> {
|
||||
return selectList(new QueryWrapper<ToolSchemaTableDO>().eq("table_schema", tableSchema));
|
||||
}
|
||||
|
||||
default ToolSchemaTableDO selectByTableName(String tableName) {
|
||||
return selectOne(new QueryWrapper<ToolSchemaTableDO>().eq("table_name", tableName));
|
||||
default ToolSchemaTableDO selectByTableName1(String tableSchema,String tableName) {
|
||||
return selectOne(new QueryWrapper<ToolSchemaTableDO>().eq("table_schema",tableSchema)
|
||||
.eq("table_name", tableName));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -101,9 +101,11 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
|
||||
|
||||
@Override
|
||||
public Long createCodegen(String tableName) {
|
||||
//获取当前schema
|
||||
String tableSchema = codegenProperties.getDbSchemas().iterator().next();
|
||||
// 从数据库中,获得数据库表结构
|
||||
ToolSchemaTableDO schemaTable = schemaTableMapper.selectByTableName(tableName);
|
||||
List<ToolSchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(tableName);
|
||||
ToolSchemaTableDO schemaTable = schemaTableMapper.selectByTableName1(tableSchema,tableName);
|
||||
List<ToolSchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema,tableName);
|
||||
// 导入
|
||||
return this.createCodegen0(ToolCodegenImportTypeEnum.DB, schemaTable, schemaColumns);
|
||||
}
|
||||
@ -141,8 +143,9 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
|
||||
if (table == null) {
|
||||
throw exception(CODEGEN_TABLE_NOT_EXISTS);
|
||||
}
|
||||
String tableSchema = codegenProperties.getDbSchemas().iterator().next();
|
||||
// 从数据库中,获得数据库表结构
|
||||
List<ToolSchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(table.getTableName());
|
||||
List<ToolSchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema,table.getTableName());
|
||||
|
||||
// 执行同步
|
||||
this.syncCodegen0(tableId, schemaColumns);
|
||||
|
Loading…
Reference in New Issue
Block a user