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