增加 Oracle Driver

pull/2/head
YunaiV 2022-04-28 20:42:13 +08:00
parent d79549b48a
commit 3950c58c18
8 changed files with 47 additions and 39 deletions

View File

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

View File

@ -50,15 +50,17 @@ public class CodegenController {
@GetMapping("/db/table/list") @GetMapping("/db/table/list")
@ApiOperation(value = "获得数据库自带的表定义列表", notes = "会过滤掉已经导入 Codegen 的表") @ApiOperation(value = "获得数据库自带的表定义列表", notes = "会过滤掉已经导入 Codegen 的表")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名,模糊匹配", required = true, example = "yudao", dataTypeClass = String.class), @ApiImplicitParam(name = "dataSourceConfigId", value = "数据源配置的编号", required = true, example = "1", dataTypeClass = Long.class),
@ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", required = true, example = "芋道", dataTypeClass = String.class) @ApiImplicitParam(name = "tableName", value = "表名,模糊匹配", example = "yudao", dataTypeClass = String.class),
@ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", example = "芋道", dataTypeClass = String.class)
}) })
@PreAuthorize("@ss.hasPermission('infra:codegen:query')") @PreAuthorize("@ss.hasPermission('infra:codegen:query')")
public CommonResult<List<SchemaTableRespVO>> getSchemaTableList( public CommonResult<List<SchemaTableRespVO>> getSchemaTableList(
@RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId,
@RequestParam(value = "tableName", required = false) String tableName, @RequestParam(value = "tableName", required = false) String tableName,
@RequestParam(value = "tableComment", required = false) String tableComment) { @RequestParam(value = "tableComment", required = false) String tableComment) {
// 获得数据库自带的表定义列表 // 获得数据库自带的表定义列表
List<DatabaseTableDO> schemaTables = codegenService.getSchemaTableList(tableName, tableComment); List<DatabaseTableDO> schemaTables = codegenService.getSchemaTableList(dataSourceConfigId, tableName, tableComment);
// 移除在 Codegen 中,已经存在的 // 移除在 Codegen 中,已经存在的
Set<String> existsTables = CollectionUtils.convertSet(codegenService.getCodeGenTableList(), CodegenTableDO::getTableName); Set<String> existsTables = CollectionUtils.convertSet(codegenService.getCodeGenTableList(), CodegenTableDO::getTableName);
schemaTables.removeIf(table -> existsTables.contains(table.getTableName())); schemaTables.removeIf(table -> existsTables.contains(table.getTableName()));

View File

@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true) @ToString(callSuper = true)
public class ConfigPageReqVO extends PageParam { public class ConfigPageReqVO extends PageParam {
@ApiModelProperty(value = "数名称", example = "模糊匹配") @ApiModelProperty(value = "据源名称", example = "模糊匹配")
private String name; private String name;
@ApiModelProperty(value = "参数键名", example = "yunai.db.username", notes = "模糊匹配") @ApiModelProperty(value = "参数键名", example = "yunai.db.username", notes = "模糊匹配")

View File

@ -12,8 +12,8 @@ import javax.validation.constraints.*;
@Data @Data
public class DataSourceConfigBaseVO { public class DataSourceConfigBaseVO {
@ApiModelProperty(value = "数名称", required = true, example = "test") @ApiModelProperty(value = "据源名称", required = true, example = "test")
@NotNull(message = "数名称不能为空") @NotNull(message = "据源名称不能为空")
private String name; private String name;
@ApiModelProperty(value = "数据源连接", required = true, example = "jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro") @ApiModelProperty(value = "数据源连接", required = true, example = "jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro")

View File

@ -115,10 +115,12 @@ public interface CodegenService {
/** /**
* *
* *
*
* @param dataSourceConfigId
* @param tableName * @param tableName
* @param tableComment * @param tableComment
* @return * @return
*/ */
List<DatabaseTableDO> getSchemaTableList(String tableName, String tableComment); List<DatabaseTableDO> getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment);
} }

View File

@ -57,9 +57,6 @@ public class CodegenServiceImpl implements CodegenService {
@Resource @Resource
private CodegenEngine codegenEngine; private CodegenEngine codegenEngine;
@Resource
private CodegenProperties codegenProperties;
private Long createCodegen0(Long userId, CodegenImportTypeEnum importType, private Long createCodegen0(Long userId, CodegenImportTypeEnum importType,
DatabaseTableDO schemaTable, List<DatabaseColumnDO> schemaColumns) { DatabaseTableDO schemaTable, List<DatabaseColumnDO> schemaColumns) {
// 校验导入的表和字段非空 // 校验导入的表和字段非空
@ -103,8 +100,6 @@ public class CodegenServiceImpl implements CodegenService {
@Override @Override
public Long createCodegen(Long userId, String tableName) { public Long createCodegen(Long userId, String tableName) {
// 获取当前schema
String tableSchema = codegenProperties.getDbSchemas().iterator().next();
// 从数据库中,获得数据库表结构 // 从数据库中,获得数据库表结构
DatabaseTableDO schemaTable = databaseTableService.getTable(0L, tableName); DatabaseTableDO schemaTable = databaseTableService.getTable(0L, tableName);
List<DatabaseColumnDO> schemaColumns = databaseTableService.getColumnList(0L, tableName); List<DatabaseColumnDO> schemaColumns = databaseTableService.getColumnList(0L, tableName);
@ -252,8 +247,8 @@ public class CodegenServiceImpl implements CodegenService {
} }
@Override @Override
public List<DatabaseTableDO> getSchemaTableList(String tableName, String tableComment) { public List<DatabaseTableDO> getSchemaTableList(Long dataSourceConfigId, String tableName, String tableComment) {
List<DatabaseTableDO> tables = databaseTableService.getTableList(0L, tableName, tableComment); List<DatabaseTableDO> tables = databaseTableService.getTableList(dataSourceConfigId, tableName, tableComment);
// TODO 强制移除 Quartz 的表,未来做成可配置 // TODO 强制移除 Quartz 的表,未来做成可配置
tables.removeIf(table -> table.getTableName().startsWith("QRTZ_")); tables.removeIf(table -> table.getTableName().startsWith("QRTZ_"));
tables.removeIf(table -> table.getTableName().startsWith("ACT_")); tables.removeIf(table -> table.getTableName().startsWith("ACT_"));

View File

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

View File

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