From 3950c58c18065d9b09df0cb5c200a380594063d5 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 28 Apr 2022 20:42:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Oracle=20Driver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-spring-boot-starter-mybatis/pom.xml | 5 ++ .../admin/codegen/CodegenController.java | 8 ++-- .../admin/config/vo/ConfigPageReqVO.java | 2 +- .../admin/db/vo/DataSourceConfigBaseVO.java | 4 +- .../infra/service/codegen/CodegenService.java | 4 +- .../service/codegen/CodegenServiceImpl.java | 9 +--- .../src/views/infra/codegen/importTable.vue | 48 ++++++++++--------- .../views/infra/dataSourceConfig/index.vue | 6 +-- 8 files changed, 47 insertions(+), 39 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml b/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml index db10906e9..bb394b0f3 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml @@ -38,6 +38,11 @@ mysql-connector-java ${mysql.version} + + com.oracle.database.jdbc + ojdbc8 + + com.alibaba druid-spring-boot-starter diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/CodegenController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/CodegenController.java index 40bd69271..2959dd511 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/CodegenController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/CodegenController.java @@ -50,15 +50,17 @@ public class CodegenController { @GetMapping("/db/table/list") @ApiOperation(value = "获得数据库自带的表定义列表", notes = "会过滤掉已经导入 Codegen 的表") @ApiImplicitParams({ - @ApiImplicitParam(name = "tableName", value = "表名,模糊匹配", required = true, example = "yudao", dataTypeClass = String.class), - @ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", required = true, example = "芋道", dataTypeClass = String.class) + @ApiImplicitParam(name = "dataSourceConfigId", value = "数据源配置的编号", required = true, example = "1", dataTypeClass = Long.class), + @ApiImplicitParam(name = "tableName", value = "表名,模糊匹配", example = "yudao", dataTypeClass = String.class), + @ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", example = "芋道", dataTypeClass = String.class) }) @PreAuthorize("@ss.hasPermission('infra:codegen:query')") public CommonResult> getSchemaTableList( + @RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId, @RequestParam(value = "tableName", required = false) String tableName, @RequestParam(value = "tableComment", required = false) String tableComment) { // 获得数据库自带的表定义列表 - List schemaTables = codegenService.getSchemaTableList(tableName, tableComment); + List schemaTables = codegenService.getSchemaTableList(dataSourceConfigId, tableName, tableComment); // 移除在 Codegen 中,已经存在的 Set existsTables = CollectionUtils.convertSet(codegenService.getCodeGenTableList(), CodegenTableDO::getTableName); schemaTables.removeIf(table -> existsTables.contains(table.getTableName())); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/vo/ConfigPageReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/vo/ConfigPageReqVO.java index 87d4ce928..3f2b1eb61 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/vo/ConfigPageReqVO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/vo/ConfigPageReqVO.java @@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ConfigPageReqVO extends PageParam { - @ApiModelProperty(value = "参数名称", example = "模糊匹配") + @ApiModelProperty(value = "数据源名称", example = "模糊匹配") private String name; @ApiModelProperty(value = "参数键名", example = "yunai.db.username", notes = "模糊匹配") diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/db/vo/DataSourceConfigBaseVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/db/vo/DataSourceConfigBaseVO.java index ae3d97dce..dbf25b75c 100755 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/db/vo/DataSourceConfigBaseVO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/db/vo/DataSourceConfigBaseVO.java @@ -12,8 +12,8 @@ import javax.validation.constraints.*; @Data public class DataSourceConfigBaseVO { - @ApiModelProperty(value = "参数名称", required = true, example = "test") - @NotNull(message = "参数名称不能为空") + @ApiModelProperty(value = "数据源名称", required = true, example = "test") + @NotNull(message = "数据源名称不能为空") private String name; @ApiModelProperty(value = "数据源连接", required = true, example = "jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro") diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenService.java index 7d3951afa..d02c6225d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenService.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenService.java @@ -115,10 +115,12 @@ public interface CodegenService { /** * 获得数据库自带的表定义列表 * + * + * @param dataSourceConfigId * @param tableName 表名称 * @param tableComment 表描述 * @return 表定义列表 */ - List getSchemaTableList(String tableName, String tableComment); + List getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java index cdeda9d67..29ae9c486 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java @@ -57,9 +57,6 @@ public class CodegenServiceImpl implements CodegenService { @Resource private CodegenEngine codegenEngine; - @Resource - private CodegenProperties codegenProperties; - private Long createCodegen0(Long userId, CodegenImportTypeEnum importType, DatabaseTableDO schemaTable, List schemaColumns) { // 校验导入的表和字段非空 @@ -103,8 +100,6 @@ public class CodegenServiceImpl implements CodegenService { @Override public Long createCodegen(Long userId, String tableName) { - // 获取当前schema - String tableSchema = codegenProperties.getDbSchemas().iterator().next(); // 从数据库中,获得数据库表结构 DatabaseTableDO schemaTable = databaseTableService.getTable(0L, tableName); List schemaColumns = databaseTableService.getColumnList(0L, tableName); @@ -252,8 +247,8 @@ public class CodegenServiceImpl implements CodegenService { } @Override - public List getSchemaTableList(String tableName, String tableComment) { - List tables = databaseTableService.getTableList(0L, tableName, tableComment); + public List getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment) { + List tables = databaseTableService.getTableList(dataSourceConfigId, tableName, tableComment); // TODO 强制移除 Quartz 的表,未来做成可配置 tables.removeIf(table -> table.getTableName().startsWith("QRTZ_")); tables.removeIf(table -> table.getTableName().startsWith("ACT_")); diff --git a/yudao-ui-admin/src/views/infra/codegen/importTable.vue b/yudao-ui-admin/src/views/infra/codegen/importTable.vue index 726a014e3..4ff51f3ba 100644 --- a/yudao-ui-admin/src/views/infra/codegen/importTable.vue +++ b/yudao-ui-admin/src/views/infra/codegen/importTable.vue @@ -1,24 +1,18 @@