增加 Oracle Driver
parent
d79549b48a
commit
3950c58c18
|
@ -38,6 +38,11 @@
|
|||
<artifactId>mysql-connector-java</artifactId>
|
||||
<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>
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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 = "模糊匹配")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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_"));
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
/** 导入按钮操作 */
|
||||
|
|
|
@ -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" }],
|
||||
|
|
Loading…
Reference in New Issue