Przeglądaj źródła

增加 Oracle Driver

YunaiV 3 lat temu
rodzic
commit
3950c58c18

+ 5 - 0
yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml

@@ -39,6 +39,11 @@
             <version>${mysql.version}</version>
         </dependency>
         <dependency>
+            <groupId>com.oracle.database.jdbc</groupId>
+            <artifactId>ojdbc8</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
         </dependency>

+ 5 - 3
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<List<SchemaTableRespVO>> getSchemaTableList(
+            @RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId,
             @RequestParam(value = "tableName", required = false) String tableName,
             @RequestParam(value = "tableComment", required = false) String tableComment) {
         // 获得数据库自带的表定义列表
-        List<DatabaseTableDO> schemaTables = codegenService.getSchemaTableList(tableName, tableComment);
+        List<DatabaseTableDO> schemaTables = codegenService.getSchemaTableList(dataSourceConfigId, tableName, tableComment);
         // 移除在 Codegen 中,已经存在的
         Set<String> existsTables = CollectionUtils.convertSet(codegenService.getCodeGenTableList(), CodegenTableDO::getTableName);
         schemaTables.removeIf(table -> existsTables.contains(table.getTableName()));

+ 1 - 1
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 = "模糊匹配")

+ 2 - 2
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")

+ 3 - 1
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<DatabaseTableDO> getSchemaTableList(String tableName, String tableComment);
+    List<DatabaseTableDO> getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment);
 
 }

+ 2 - 7
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<DatabaseColumnDO> 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<DatabaseColumnDO> schemaColumns = databaseTableService.getColumnList(0L, tableName);
@@ -252,8 +247,8 @@ public class CodegenServiceImpl implements CodegenService {
     }
 
     @Override
-    public List<DatabaseTableDO> getSchemaTableList(String tableName, String tableComment) {
-        List<DatabaseTableDO> tables = databaseTableService.getTableList(0L, tableName, tableComment);
+    public List<DatabaseTableDO> getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment) {
+        List<DatabaseTableDO> tables = databaseTableService.getTableList(dataSourceConfigId, tableName, tableComment);
         // TODO 强制移除 Quartz 的表,未来做成可配置
         tables.removeIf(table -> table.getTableName().startsWith("QRTZ_"));
         tables.removeIf(table -> table.getTableName().startsWith("ACT_"));

+ 26 - 22
yudao-ui-admin/src/views/infra/codegen/importTable.vue

@@ -1,24 +1,18 @@
 <template>
   <!-- 导入表 -->
   <el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body>
-    <el-form :model="queryParams" ref="queryForm" :inline="true">
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
+      <el-form-item label="数据源" prop="dataSourceConfigId">
+        <el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable>
+          <el-option v-for="config in dataSourceConfigs"
+                     :key="config.id" :label="config.name" :value="config.id"/>
+        </el-select>
+      </el-form-item>
       <el-form-item label="表名称" prop="tableName">
-        <el-input
-          v-model="queryParams.tableName"
-          placeholder="请输入表名称"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable  @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item label="表描述" prop="tableComment">
-        <el-input
-          v-model="queryParams.tableComment"
-          placeholder="请输入表描述"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.tableComment" placeholder="请输入表描述" clearable @keyup.enter.native="handleQuery"/>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -27,10 +21,9 @@
     </el-form>
     <el-row>
       <el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
-        <el-table-column type="selection" width="55"></el-table-column>
-        <el-table-column prop="tableSchema" label="数据库" :show-overflow-tooltip="true"></el-table-column>
-        <el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column>
-        <el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
+        <el-table-column type="selection" width="55" />
+        <el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true" />
+        <el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true" />
         <el-table-column prop="createTime" label="创建时间">
           <template slot-scope="scope">
             <span>{{ parseTime(scope.row.createTime) }}</span>
@@ -47,6 +40,7 @@
 
 <script>
 import { getSchemaTableList, createCodegenListFromDB } from "@/api/infra/codegen";
+import {getDataSourceConfigList} from "@/api/infra/dataSourceConfig";
 export default {
   data() {
     return {
@@ -60,16 +54,25 @@ export default {
       dbTableList: [],
       // 查询参数
       queryParams: {
+        dataSourceConfigId: undefined,
         tableName: undefined,
-        tableComment: undefined
-      }
+        tableComment: undefined,
+      },
+      // 数据源列表
+      dataSourceConfigs: [],
     };
   },
   methods: {
     // 显示弹框
     show() {
-      this.getList();
       this.visible = true;
+      // 加载数据源
+      getDataSourceConfigList().then(response => {
+        this.dataSourceConfigs = response.data;
+        this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id;
+        // 加载表列表
+        this.getList();
+      });
     },
     clickRow(row) {
       this.$refs.table.toggleRowSelection(row);
@@ -91,6 +94,7 @@ export default {
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm");
+      this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id;
       this.handleQuery();
     },
     /** 导入按钮操作 */

+ 3 - 3
yudao-ui-admin/src/views/infra/dataSourceConfig/index.vue

@@ -11,7 +11,7 @@
     <!-- 列表 -->
     <el-table v-loading="loading" :data="list">
       <el-table-column label="主键编号" align="center" prop="id" />
-      <el-table-column label="数名称" align="center" prop="name" />
+      <el-table-column label="数据源名称" align="center" prop="name" />
       <el-table-column label="数据源连接" align="center" prop="url" />
       <el-table-column label="用户名" align="center" prop="username" />
       <el-table-column label="创建时间" align="center" prop="createTime" width="180">
@@ -32,7 +32,7 @@
     <!-- 对话框(添加 / 修改) -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="100px">
-        <el-form-item label="数名称" prop="name">
+        <el-form-item label="数据源名称" prop="name">
           <el-input v-model="form.name" placeholder="请输入参数名称" />
         </el-form-item>
         <el-form-item label="数据源连接" prop="url">
@@ -76,7 +76,7 @@ export default {
       form: {},
       // 表单校验
       rules: {
-        name: [{ required: true, message: "数名称不能为空", trigger: "blur" }],
+        name: [{ required: true, message: "数据源名称不能为空", trigger: "blur" }],
         url: [{ required: true, message: "数据源连接不能为空", trigger: "blur" }],
         username: [{ required: true, message: "用户名不能为空", trigger: "blur" }],
         password: [{ required: true, message: "密码不能为空", trigger: "blur" }],