From cb2570c086fac1c3e6f288da39579e87be376251 Mon Sep 17 00:00:00 2001 From: shanzhiliu <1350700145@qq.com> Date: Wed, 7 Apr 2021 18:58:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1?= =?UTF-8?q?=E5=9D=97,=E5=9F=BA=E4=BA=8EDB=E5=AF=BC=E5=85=A5=E6=97=B6,?= =?UTF-8?q?=E5=A4=9A=E4=B8=AAschema=E4=B8=8B=E6=9C=89=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E8=A1=A8,=E5=AF=BC=E5=85=A5=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/dal/mysql/codegen/ToolSchemaColumnMapper.java | 5 +++-- .../tool/dal/mysql/codegen/ToolSchemaTableMapper.java | 5 +++-- .../service/codegen/impl/ToolCodegenServiceImpl.java | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaColumnMapper.java b/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaColumnMapper.java index 438168bc4..0ddfe4db2 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaColumnMapper.java +++ b/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaColumnMapper.java @@ -10,9 +10,10 @@ import java.util.List; @Mapper public interface ToolSchemaColumnMapper extends BaseMapperX { - default List selectListByTableName(String tableName) { + default List selectListByTableName(String tableSchema,String tableName) { return selectList(new QueryWrapper().eq("table_name", tableName) - .orderByAsc("ordinal_position")); + .eq("table_schema", tableSchema) + .orderByAsc("ordinal_position")); } } diff --git a/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaTableMapper.java b/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaTableMapper.java index 20a775272..89821ae1c 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaTableMapper.java +++ b/src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/codegen/ToolSchemaTableMapper.java @@ -22,8 +22,9 @@ public interface ToolSchemaTableMapper extends BaseMapperX { return selectList(new QueryWrapper().eq("table_schema", tableSchema)); } - default ToolSchemaTableDO selectByTableName(String tableName) { - return selectOne(new QueryWrapper().eq("table_name", tableName)); + default ToolSchemaTableDO selectByTableName1(String tableSchema,String tableName) { + return selectOne(new QueryWrapper().eq("table_schema",tableSchema) + .eq("table_name", tableName)); } } diff --git a/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java index 5b746f6fd..cff4931b9 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java @@ -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 schemaColumns = schemaColumnMapper.selectListByTableName(tableName); + ToolSchemaTableDO schemaTable = schemaTableMapper.selectByTableName1(tableSchema,tableName); + List 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 schemaColumns = schemaColumnMapper.selectListByTableName(table.getTableName()); + List schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema,table.getTableName()); // 执行同步 this.syncCodegen0(tableId, schemaColumns);