Commit 3950c58c18065d9b09df0cb5c200a380594063d5
1 parent
d79549b4
增加 Oracle Driver
Showing
8 changed files
with
47 additions
and
39 deletions
yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml
| ... | ... | @@ -39,6 +39,11 @@ |
| 39 | 39 | <version>${mysql.version}</version> |
| 40 | 40 | </dependency> |
| 41 | 41 | <dependency> |
| 42 | + <groupId>com.oracle.database.jdbc</groupId> | |
| 43 | + <artifactId>ojdbc8</artifactId> | |
| 44 | + </dependency> | |
| 45 | + | |
| 46 | + <dependency> | |
| 42 | 47 | <groupId>com.alibaba</groupId> |
| 43 | 48 | <artifactId>druid-spring-boot-starter</artifactId> |
| 44 | 49 | </dependency> | ... | ... |
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 { |
| 50 | 50 | @GetMapping("/db/table/list") |
| 51 | 51 | @ApiOperation(value = "获得数据库自带的表定义列表", notes = "会过滤掉已经导入 Codegen 的表") |
| 52 | 52 | @ApiImplicitParams({ |
| 53 | - @ApiImplicitParam(name = "tableName", value = "表名,模糊匹配", required = true, example = "yudao", dataTypeClass = String.class), | |
| 54 | - @ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", required = true, example = "芋道", dataTypeClass = String.class) | |
| 53 | + @ApiImplicitParam(name = "dataSourceConfigId", value = "数据源配置的编号", required = true, example = "1", dataTypeClass = Long.class), | |
| 54 | + @ApiImplicitParam(name = "tableName", value = "表名,模糊匹配", example = "yudao", dataTypeClass = String.class), | |
| 55 | + @ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", example = "芋道", dataTypeClass = String.class) | |
| 55 | 56 | }) |
| 56 | 57 | @PreAuthorize("@ss.hasPermission('infra:codegen:query')") |
| 57 | 58 | public CommonResult<List<SchemaTableRespVO>> getSchemaTableList( |
| 59 | + @RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId, | |
| 58 | 60 | @RequestParam(value = "tableName", required = false) String tableName, |
| 59 | 61 | @RequestParam(value = "tableComment", required = false) String tableComment) { |
| 60 | 62 | // 获得数据库自带的表定义列表 |
| 61 | - List<DatabaseTableDO> schemaTables = codegenService.getSchemaTableList(tableName, tableComment); | |
| 63 | + List<DatabaseTableDO> schemaTables = codegenService.getSchemaTableList(dataSourceConfigId, tableName, tableComment); | |
| 62 | 64 | // 移除在 Codegen 中,已经存在的 |
| 63 | 65 | Set<String> existsTables = CollectionUtils.convertSet(codegenService.getCodeGenTableList(), CodegenTableDO::getTableName); |
| 64 | 66 | schemaTables.removeIf(table -> existsTables.contains(table.getTableName())); | ... | ... |
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_ |
| 18 | 18 | @ToString(callSuper = true) |
| 19 | 19 | public class ConfigPageReqVO extends PageParam { |
| 20 | 20 | |
| 21 | - @ApiModelProperty(value = "参数名称", example = "模糊匹配") | |
| 21 | + @ApiModelProperty(value = "数据源名称", example = "模糊匹配") | |
| 22 | 22 | private String name; |
| 23 | 23 | |
| 24 | 24 | @ApiModelProperty(value = "参数键名", example = "yunai.db.username", notes = "模糊匹配") | ... | ... |
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.*; |
| 12 | 12 | @Data |
| 13 | 13 | public class DataSourceConfigBaseVO { |
| 14 | 14 | |
| 15 | - @ApiModelProperty(value = "参数名称", required = true, example = "test") | |
| 16 | - @NotNull(message = "参数名称不能为空") | |
| 15 | + @ApiModelProperty(value = "数据源名称", required = true, example = "test") | |
| 16 | + @NotNull(message = "数据源名称不能为空") | |
| 17 | 17 | private String name; |
| 18 | 18 | |
| 19 | 19 | @ApiModelProperty(value = "数据源连接", required = true, example = "jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro") | ... | ... |
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 { |
| 115 | 115 | /** |
| 116 | 116 | * 获得数据库自带的表定义列表 |
| 117 | 117 | * |
| 118 | + * | |
| 119 | + * @param dataSourceConfigId | |
| 118 | 120 | * @param tableName 表名称 |
| 119 | 121 | * @param tableComment 表描述 |
| 120 | 122 | * @return 表定义列表 |
| 121 | 123 | */ |
| 122 | - List<DatabaseTableDO> getSchemaTableList(String tableName, String tableComment); | |
| 124 | + List<DatabaseTableDO> getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment); | |
| 123 | 125 | |
| 124 | 126 | } | ... | ... |
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 { |
| 57 | 57 | @Resource |
| 58 | 58 | private CodegenEngine codegenEngine; |
| 59 | 59 | |
| 60 | - @Resource | |
| 61 | - private CodegenProperties codegenProperties; | |
| 62 | - | |
| 63 | 60 | private Long createCodegen0(Long userId, CodegenImportTypeEnum importType, |
| 64 | 61 | DatabaseTableDO schemaTable, List<DatabaseColumnDO> schemaColumns) { |
| 65 | 62 | // 校验导入的表和字段非空 |
| ... | ... | @@ -103,8 +100,6 @@ public class CodegenServiceImpl implements CodegenService { |
| 103 | 100 | |
| 104 | 101 | @Override |
| 105 | 102 | public Long createCodegen(Long userId, String tableName) { |
| 106 | - // 获取当前schema | |
| 107 | - String tableSchema = codegenProperties.getDbSchemas().iterator().next(); | |
| 108 | 103 | // 从数据库中,获得数据库表结构 |
| 109 | 104 | DatabaseTableDO schemaTable = databaseTableService.getTable(0L, tableName); |
| 110 | 105 | List<DatabaseColumnDO> schemaColumns = databaseTableService.getColumnList(0L, tableName); |
| ... | ... | @@ -252,8 +247,8 @@ public class CodegenServiceImpl implements CodegenService { |
| 252 | 247 | } |
| 253 | 248 | |
| 254 | 249 | @Override |
| 255 | - public List<DatabaseTableDO> getSchemaTableList(String tableName, String tableComment) { | |
| 256 | - List<DatabaseTableDO> tables = databaseTableService.getTableList(0L, tableName, tableComment); | |
| 250 | + public List<DatabaseTableDO> getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment) { | |
| 251 | + List<DatabaseTableDO> tables = databaseTableService.getTableList(dataSourceConfigId, tableName, tableComment); | |
| 257 | 252 | // TODO 强制移除 Quartz 的表,未来做成可配置 |
| 258 | 253 | tables.removeIf(table -> table.getTableName().startsWith("QRTZ_")); |
| 259 | 254 | tables.removeIf(table -> table.getTableName().startsWith("ACT_")); | ... | ... |
yudao-ui-admin/src/views/infra/codegen/importTable.vue
| 1 | 1 | <template> |
| 2 | 2 | <!-- 导入表 --> |
| 3 | 3 | <el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body> |
| 4 | - <el-form :model="queryParams" ref="queryForm" :inline="true"> | |
| 4 | + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"> | |
| 5 | + <el-form-item label="数据源" prop="dataSourceConfigId"> | |
| 6 | + <el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable> | |
| 7 | + <el-option v-for="config in dataSourceConfigs" | |
| 8 | + :key="config.id" :label="config.name" :value="config.id"/> | |
| 9 | + </el-select> | |
| 10 | + </el-form-item> | |
| 5 | 11 | <el-form-item label="表名称" prop="tableName"> |
| 6 | - <el-input | |
| 7 | - v-model="queryParams.tableName" | |
| 8 | - placeholder="请输入表名称" | |
| 9 | - clearable | |
| 10 | - size="small" | |
| 11 | - @keyup.enter.native="handleQuery" | |
| 12 | - /> | |
| 12 | + <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable @keyup.enter.native="handleQuery" /> | |
| 13 | 13 | </el-form-item> |
| 14 | 14 | <el-form-item label="表描述" prop="tableComment"> |
| 15 | - <el-input | |
| 16 | - v-model="queryParams.tableComment" | |
| 17 | - placeholder="请输入表描述" | |
| 18 | - clearable | |
| 19 | - size="small" | |
| 20 | - @keyup.enter.native="handleQuery" | |
| 21 | - /> | |
| 15 | + <el-input v-model="queryParams.tableComment" placeholder="请输入表描述" clearable @keyup.enter.native="handleQuery"/> | |
| 22 | 16 | </el-form-item> |
| 23 | 17 | <el-form-item> |
| 24 | 18 | <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
| ... | ... | @@ -27,10 +21,9 @@ |
| 27 | 21 | </el-form> |
| 28 | 22 | <el-row> |
| 29 | 23 | <el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px"> |
| 30 | - <el-table-column type="selection" width="55"></el-table-column> | |
| 31 | - <el-table-column prop="tableSchema" label="数据库" :show-overflow-tooltip="true"></el-table-column> | |
| 32 | - <el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column> | |
| 33 | - <el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column> | |
| 24 | + <el-table-column type="selection" width="55" /> | |
| 25 | + <el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true" /> | |
| 26 | + <el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true" /> | |
| 34 | 27 | <el-table-column prop="createTime" label="创建时间"> |
| 35 | 28 | <template slot-scope="scope"> |
| 36 | 29 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| ... | ... | @@ -47,6 +40,7 @@ |
| 47 | 40 | |
| 48 | 41 | <script> |
| 49 | 42 | import { getSchemaTableList, createCodegenListFromDB } from "@/api/infra/codegen"; |
| 43 | +import {getDataSourceConfigList} from "@/api/infra/dataSourceConfig"; | |
| 50 | 44 | export default { |
| 51 | 45 | data() { |
| 52 | 46 | return { |
| ... | ... | @@ -60,16 +54,25 @@ export default { |
| 60 | 54 | dbTableList: [], |
| 61 | 55 | // 查询参数 |
| 62 | 56 | queryParams: { |
| 57 | + dataSourceConfigId: undefined, | |
| 63 | 58 | tableName: undefined, |
| 64 | - tableComment: undefined | |
| 65 | - } | |
| 59 | + tableComment: undefined, | |
| 60 | + }, | |
| 61 | + // 数据源列表 | |
| 62 | + dataSourceConfigs: [], | |
| 66 | 63 | }; |
| 67 | 64 | }, |
| 68 | 65 | methods: { |
| 69 | 66 | // 显示弹框 |
| 70 | 67 | show() { |
| 71 | - this.getList(); | |
| 72 | 68 | this.visible = true; |
| 69 | + // 加载数据源 | |
| 70 | + getDataSourceConfigList().then(response => { | |
| 71 | + this.dataSourceConfigs = response.data; | |
| 72 | + this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id; | |
| 73 | + // 加载表列表 | |
| 74 | + this.getList(); | |
| 75 | + }); | |
| 73 | 76 | }, |
| 74 | 77 | clickRow(row) { |
| 75 | 78 | this.$refs.table.toggleRowSelection(row); |
| ... | ... | @@ -91,6 +94,7 @@ export default { |
| 91 | 94 | /** 重置按钮操作 */ |
| 92 | 95 | resetQuery() { |
| 93 | 96 | this.resetForm("queryForm"); |
| 97 | + this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id; | |
| 94 | 98 | this.handleQuery(); |
| 95 | 99 | }, |
| 96 | 100 | /** 导入按钮操作 */ | ... | ... |
yudao-ui-admin/src/views/infra/dataSourceConfig/index.vue
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | <!-- 列表 --> |
| 12 | 12 | <el-table v-loading="loading" :data="list"> |
| 13 | 13 | <el-table-column label="主键编号" align="center" prop="id" /> |
| 14 | - <el-table-column label="参数名称" align="center" prop="name" /> | |
| 14 | + <el-table-column label="数据源名称" align="center" prop="name" /> | |
| 15 | 15 | <el-table-column label="数据源连接" align="center" prop="url" /> |
| 16 | 16 | <el-table-column label="用户名" align="center" prop="username" /> |
| 17 | 17 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | <!-- 对话框(添加 / 修改) --> |
| 33 | 33 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| 34 | 34 | <el-form ref="form" :model="form" :rules="rules" label-width="100px"> |
| 35 | - <el-form-item label="参数名称" prop="name"> | |
| 35 | + <el-form-item label="数据源名称" prop="name"> | |
| 36 | 36 | <el-input v-model="form.name" placeholder="请输入参数名称" /> |
| 37 | 37 | </el-form-item> |
| 38 | 38 | <el-form-item label="数据源连接" prop="url"> |
| ... | ... | @@ -76,7 +76,7 @@ export default { |
| 76 | 76 | form: {}, |
| 77 | 77 | // 表单校验 |
| 78 | 78 | rules: { |
| 79 | - name: [{ required: true, message: "参数名称不能为空", trigger: "blur" }], | |
| 79 | + name: [{ required: true, message: "数据源名称不能为空", trigger: "blur" }], | |
| 80 | 80 | url: [{ required: true, message: "数据源连接不能为空", trigger: "blur" }], |
| 81 | 81 | username: [{ required: true, message: "用户名不能为空", trigger: "blur" }], |
| 82 | 82 | password: [{ required: true, message: "密码不能为空", trigger: "blur" }], | ... | ... |