mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-10-15 06:10:23 +00:00
数据源管理 列表和新增页面 100%
This commit is contained in:
@@ -125,6 +125,13 @@ const constantRouter = new Router({
|
|||||||
icon: "el-icon-menu",
|
icon: "el-icon-menu",
|
||||||
hidden: true,
|
hidden: true,
|
||||||
component: () => import('@/views/connection/addDataSource1.vue')
|
component: () => import('@/views/connection/addDataSource1.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/connection/list/addDataSource2',
|
||||||
|
name: '接入数据源',
|
||||||
|
icon: "el-icon-menu",
|
||||||
|
hidden: true,
|
||||||
|
component: () => import('@/views/connection/addDataSource2.vue')
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@@ -38,7 +38,10 @@
|
|||||||
</el-collapse>
|
</el-collapse>
|
||||||
</el-main>
|
</el-main>
|
||||||
<el-footer>
|
<el-footer>
|
||||||
<button style="float: right">下一步</button>
|
<el-row>
|
||||||
|
<el-button type="primary" class="next" @click="next">下一步</el-button>
|
||||||
|
<el-button class="cancel" @click="cancel">取消</el-button>
|
||||||
|
</el-row>
|
||||||
</el-footer>
|
</el-footer>
|
||||||
</el-container>
|
</el-container>
|
||||||
</el-container>
|
</el-container>
|
||||||
@@ -53,6 +56,7 @@ export default {
|
|||||||
currentDate: new Date(),
|
currentDate: new Date(),
|
||||||
databaseType: [],
|
databaseType: [],
|
||||||
selectedIndex: -1,
|
selectedIndex: -1,
|
||||||
|
selectedDataSource: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -97,7 +101,20 @@ export default {
|
|||||||
},
|
},
|
||||||
selectDbDriver: function (value) {
|
selectDbDriver: function (value) {
|
||||||
this.selectedIndex = value.id - 1;
|
this.selectedIndex = value.id - 1;
|
||||||
console.log(JSON.stringify(value))
|
this.selectedDataSource = value;
|
||||||
|
},
|
||||||
|
next: function () {
|
||||||
|
if (Object.keys(this.selectedDataSource).length === 0) {
|
||||||
|
this.$message.error('请选择数据库!');
|
||||||
|
} else {
|
||||||
|
this.$router.push({
|
||||||
|
path: "/connection/list/addDataSource2", query:
|
||||||
|
this.selectedDataSource
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cancel: function () {
|
||||||
|
this.$router.push("/connection/list");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -187,4 +204,22 @@ export default {
|
|||||||
background-color: #eefff9;
|
background-color: #eefff9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cancel {
|
||||||
|
float: right;
|
||||||
|
padding: 6px 14px;
|
||||||
|
border: 1px solid #dcdcdd;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.next {
|
||||||
|
float: right;
|
||||||
|
margin-left: 20px;
|
||||||
|
padding: 6px 14px;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
background-color: #409EFF;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
402
dbswitch-admin-ui/src/views/connection/addDataSource2.vue
Normal file
402
dbswitch-admin-ui/src/views/connection/addDataSource2.vue
Normal file
@@ -0,0 +1,402 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-container>
|
||||||
|
<el-aside width="134px"></el-aside>
|
||||||
|
|
||||||
|
<el-container>
|
||||||
|
<el-header style="height: 80px">
|
||||||
|
<div style="display: inline-block;float: left">
|
||||||
|
<img title="DB" :src="require('@/assets/icons/' + this.selectedDataSource.name +'.png')" class="image">
|
||||||
|
</div>
|
||||||
|
<h3 style="font-family: 楷体;margin-left: 60px" class=".h-title">{{ this.selectedDataSource.name }}</h3>
|
||||||
|
</el-header>
|
||||||
|
<el-main>
|
||||||
|
|
||||||
|
<el-form ref="createform" :rules="rules" :model="createform" label-width="120px" label-position="right"
|
||||||
|
size="medium" status-icon>
|
||||||
|
<div class="f1">
|
||||||
|
|
||||||
|
<el-form-item label="支持版本">
|
||||||
|
<span v-for="(o, index) of connectionDriver" :key="index" :offset="1">
|
||||||
|
{{ o.driverVersion }}
|
||||||
|
<span v-if="index !== connectionDriver.length-1">
|
||||||
|
、
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item prop="name" label="数据源名称" style="width:40%">
|
||||||
|
<el-input v-model="createform.name" placeholder="请输入数据源名称" auto-complete="off"></el-input>
|
||||||
|
<label class="tips-style">数据源名称不能包含 &、<、>、"、'、(、) ,长度为1~200字符</label>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :required=true label="数据库类型">
|
||||||
|
<label v-model="createform.type">{{ this.selectedDataSource.name }}</label>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item prop="version" label="驱动版本">
|
||||||
|
<el-select v-model="createform.version" placeholder="请选择驱动版本">
|
||||||
|
<el-option v-for="(item,index) in this.connectionDriver"
|
||||||
|
:key="index"
|
||||||
|
:label="item.driverVersion"
|
||||||
|
:value="item.driverVersion"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="编码格式">
|
||||||
|
<label>utf8、utf8mb4</label>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="f1">
|
||||||
|
<el-form-item label="连接模式">
|
||||||
|
<el-radio-group v-model="createform.mode">
|
||||||
|
<el-radio :label=0>默认</el-radio>
|
||||||
|
<el-radio :disabled="true" :label=1>专业</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item prop="address" label="连接地址">
|
||||||
|
<el-input v-model="createform.address" auto-complete="off" @blur="changeUrl()" style="width:20%"
|
||||||
|
placeholder="请输入数据源连接地址"></el-input>
|
||||||
|
/
|
||||||
|
<el-input v-model="createform.port" auto-complete="off" @blur="changeUrl()" style="width:6%"
|
||||||
|
placeholder="Port"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item prop="databaseName" label="数据库名" style="width:24%">
|
||||||
|
<el-input v-model="createform.databaseName" auto-complete="off" @blur="changeUrl()"
|
||||||
|
placeholder="请输入数据库名"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="编码格式" style="width:24%">
|
||||||
|
<el-select v-model="createform.characterEncoding" placeholder="请选择编码格式">
|
||||||
|
<el-option label="utf8" value="utf8"></el-option>
|
||||||
|
<el-option label="utf8mb4" value="utf8mb4"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="用户名"
|
||||||
|
prop="username"
|
||||||
|
style="width:24%">
|
||||||
|
<el-input v-model="createform.username"
|
||||||
|
auto-complete="off"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="密码"
|
||||||
|
prop="password"
|
||||||
|
style="width:24%">
|
||||||
|
<el-input type="password"
|
||||||
|
v-model="createform.password"
|
||||||
|
auto-complete="off"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="JDBC连接串"
|
||||||
|
label-width="120px"
|
||||||
|
prop="url"
|
||||||
|
style="width:85%">
|
||||||
|
<el-tooltip placement="top">
|
||||||
|
<i class="el-icon-question">样例:</i>
|
||||||
|
<div slot="content">
|
||||||
|
{{ this.selectedDataSource.sample }}
|
||||||
|
</div>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-input type="textarea"
|
||||||
|
:rows="6"
|
||||||
|
:spellcheck="false"
|
||||||
|
placeholder="请输入"
|
||||||
|
v-model="createform.url"
|
||||||
|
auto-complete="off">
|
||||||
|
</el-input>
|
||||||
|
<label
|
||||||
|
class="tips-style">JDBC连接串(因数据库连接方式,连接参数差异较大所以需要手动拼接好),以便测试连接。</label>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</el-main>
|
||||||
|
<el-footer>
|
||||||
|
<el-row>
|
||||||
|
<el-button class="cancel" @click="cancel">取消</el-button>
|
||||||
|
<el-button type="primary" class="createDataSource" @click="createDataSource">创建</el-button>
|
||||||
|
<el-button type="success" class="startTest" @click="startTest">开始检测</el-button>
|
||||||
|
</el-row>
|
||||||
|
</el-footer>
|
||||||
|
</el-container>
|
||||||
|
</el-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
selectedDataSource: {},
|
||||||
|
connectionDriver: [],
|
||||||
|
databaseType: [],
|
||||||
|
createform: {
|
||||||
|
diver: "",
|
||||||
|
name: "",
|
||||||
|
type: "",
|
||||||
|
version: "",
|
||||||
|
mode: 0,
|
||||||
|
address: "",
|
||||||
|
port: "",
|
||||||
|
databaseName: "",
|
||||||
|
characterEncoding: "",
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
sample: "",
|
||||||
|
url: "",
|
||||||
|
oldUrl: "",
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
name: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "数据源名称不能为空",
|
||||||
|
trigger: "blur"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
type: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "数据库类型必须选择",
|
||||||
|
trigger: "change"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
version: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "驱动版本必须选择",
|
||||||
|
trigger: "change"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
address: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "连接地址不能为空",
|
||||||
|
trigger: "change"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
port: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "连接端口号不能为空",
|
||||||
|
trigger: "change"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
databaseName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "数据库名不能为空",
|
||||||
|
trigger: "change"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
url: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "Jdbc URL必须提供",
|
||||||
|
trigger: "blur"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
username: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "用户名不能为空",
|
||||||
|
trigger: "blur"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
password: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "密码不能为空",
|
||||||
|
trigger: "blur"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
selectChangedDriverVersion: function (value) {
|
||||||
|
this.connectionDriver = [];
|
||||||
|
this.$http.get(
|
||||||
|
"/dbswitch/admin/api/v1/connection/" + value + "/drivers"
|
||||||
|
).then(res => {
|
||||||
|
if (0 === res.data.code) {
|
||||||
|
this.connectionDriver = res.data.data;
|
||||||
|
let varDatabaseType = this.databaseType.find(
|
||||||
|
(item) => {
|
||||||
|
return item.type === value;
|
||||||
|
});
|
||||||
|
if (varDatabaseType) {
|
||||||
|
this.createform.sample = varDatabaseType.sample;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$message.error("查询数据库可用的驱动版本失败," + res.data.message);
|
||||||
|
this.connectionDriver = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
changeUrl: function () {
|
||||||
|
console.log('')
|
||||||
|
},
|
||||||
|
startTest: function () {
|
||||||
|
let driverClass = "";
|
||||||
|
if (this.connectionDriver.length > 0) {
|
||||||
|
for (let i = 0; i < this.connectionDriver.length; i++) {
|
||||||
|
if (this.connectionDriver[i].driverVersion == this.createform.version) {
|
||||||
|
driverClass = this.connectionDriver[i].driverClass;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$http({
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
url: "/dbswitch/admin/api/v1/connection/preTest",
|
||||||
|
data: JSON.stringify({
|
||||||
|
name: this.createform.name,
|
||||||
|
type: this.selectedDataSource.type,
|
||||||
|
version: this.createform.version,
|
||||||
|
driver: driverClass,
|
||||||
|
url: this.createform.url,
|
||||||
|
username: this.createform.username,
|
||||||
|
password: this.createform.password
|
||||||
|
})
|
||||||
|
}).then(res => {
|
||||||
|
if (0 === res.data.code) {
|
||||||
|
this.$message({
|
||||||
|
message: '测试连接成功!',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$message.error('测试连接失败!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
createDataSource: function () {
|
||||||
|
let driverClass = "";
|
||||||
|
if (this.connectionDriver.length > 0) {
|
||||||
|
for (let i = 0; i < this.connectionDriver.length; i++) {
|
||||||
|
if (this.connectionDriver[i].driverVersion == this.createform.version) {
|
||||||
|
driverClass = this.connectionDriver[i].driverClass;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$refs['createform'].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.$http({
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
url: "/dbswitch/admin/api/v1/connection/create",
|
||||||
|
data: JSON.stringify({
|
||||||
|
name: this.createform.name,
|
||||||
|
type: this.selectedDataSource.type,
|
||||||
|
version: this.createform.version,
|
||||||
|
driver: driverClass,
|
||||||
|
mode:0,
|
||||||
|
address:this.createform.address,
|
||||||
|
port:this.createform.port,
|
||||||
|
databaseName:this.createform.databaseName,
|
||||||
|
characterEncoding:this.createform.characterEncoding,
|
||||||
|
url: this.createform.url,
|
||||||
|
username: this.createform.username,
|
||||||
|
password: this.createform.password
|
||||||
|
})
|
||||||
|
}).then(res => {
|
||||||
|
if (0 === res.data.code) {
|
||||||
|
this.$message({
|
||||||
|
message: '添加连接信息成功!',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
this.$router.push("/connection/list")
|
||||||
|
} else {
|
||||||
|
alert("添加连接信息失败:" + res.data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("请检查输入");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cancel: function () {
|
||||||
|
this.$router.push("/connection/list")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.selectedDataSource = this.$route.query;
|
||||||
|
this.createform.url = this.selectedDataSource.sample;
|
||||||
|
this.selectChangedDriverVersion(this.selectedDataSource.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.el-header, .el-main, .el-footer {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h-title {
|
||||||
|
font-weight: bolder;
|
||||||
|
font-size: 20px;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.button {
|
||||||
|
padding: 0;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image {
|
||||||
|
//width: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
padding: 8px 10px 0px 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cancel {
|
||||||
|
float: right;
|
||||||
|
margin-left: 20px;
|
||||||
|
padding: 6px 14px;
|
||||||
|
border: 1px solid #dcdcdd;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.createDataSource {
|
||||||
|
float: right;
|
||||||
|
margin-left: 20px;
|
||||||
|
padding: 6px 14px;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
background-color: #409EFF;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.startTest {
|
||||||
|
float: right;
|
||||||
|
padding: 6px 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.f1 {
|
||||||
|
//border: 1px solid red;
|
||||||
|
margin: 14px 0px;
|
||||||
|
background-color: #eef0f4;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
|
||||||
|
padding: 4px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tips-style {
|
||||||
|
font-size: 10px;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
@@ -17,8 +17,14 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
icon="el-icon-document-add"
|
icon="el-icon-document-add"
|
||||||
@click="selectDataSource">接入数据源</el-button>
|
@click="selectDataSource">接入数据源</el-button>
|
||||||
<!-- @click="addConnection">接入数据源</el-button>-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="right-add-button-group">-->
|
||||||
|
<!-- <el-button type="primary"-->
|
||||||
|
<!-- size="mini"-->
|
||||||
|
<!-- icon="el-icon-document-add"-->
|
||||||
|
<!-- @click="addConnection">旧接入数据源</el-button>-->
|
||||||
|
<!-- </div>-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-table :header-cell-style="{background:'#eef1f6',color:'#606266'}"
|
<el-table :header-cell-style="{background:'#eef1f6',color:'#606266'}"
|
||||||
@@ -161,30 +167,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog title="接入数据源"
|
<!-- <el-dialog title="接入数据源"-->
|
||||||
:visible.sync="dataSourceCreateStep1"
|
<!-- :visible.sync="dataSourceCreateStep1"-->
|
||||||
:showClose="false"
|
<!-- :showClose="false"-->
|
||||||
:before-close="handleClose">
|
<!-- :before-close="handleClose">-->
|
||||||
|
|
||||||
|
|
||||||
<el-form :model="createform"
|
<!-- <el-form :model="createform"-->
|
||||||
size="mini"
|
<!-- size="mini"-->
|
||||||
status-icon
|
<!-- status-icon-->
|
||||||
:rules="rules"
|
<!-- :rules="rules"-->
|
||||||
ref="createform">
|
<!-- ref="createform">-->
|
||||||
<el-form-item label="数据库类型"
|
<!-- <el-form-item label="数据库类型"-->
|
||||||
label-width="120px"
|
<!-- label-width="120px"-->
|
||||||
:required=true
|
<!-- :required=true-->
|
||||||
prop="type">
|
<!-- prop="type">-->
|
||||||
<el-radio-group v-model="createform.type" @change="selectChangedDriverVersion">
|
<!-- <el-radio-group v-model="createform.type" @change="selectChangedDriverVersion">-->
|
||||||
<el-radio :label="item.type" :key="index" v-for="(item,index) in databaseType">{{ item.type }}</el-radio>
|
<!-- <el-radio :label="item.type" :key="index" v-for="(item,index) in databaseType">{{ item.type }}</el-radio>-->
|
||||||
</el-radio-group>
|
<!-- </el-radio-group>-->
|
||||||
</el-form-item>
|
<!-- </el-form-item>-->
|
||||||
|
|
||||||
</el-form>
|
<!-- </el-form>-->
|
||||||
|
|
||||||
|
|
||||||
</el-dialog>
|
<!-- </el-dialog>-->
|
||||||
|
|
||||||
<el-dialog title="添加数据源连接信息"
|
<el-dialog title="添加数据源连接信息"
|
||||||
:visible.sync="createFormVisible"
|
:visible.sync="createFormVisible"
|
||||||
@@ -533,9 +539,12 @@ export default {
|
|||||||
).then(res => {
|
).then(res => {
|
||||||
//console.log(res);
|
//console.log(res);
|
||||||
if (0 === res.data.code) {
|
if (0 === res.data.code) {
|
||||||
alert("测试连接成功!");
|
this.$message({
|
||||||
|
message: '测试连接成功!',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
alert("测试连接失败," + res.data.message);
|
this.$message.error("测试连接失败," + res.data.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -24,6 +24,11 @@ public class DbConnectionDetailConverter extends
|
|||||||
response.setType(databaseConnectionEntity.getType());
|
response.setType(databaseConnectionEntity.getType());
|
||||||
response.setVersion(databaseConnectionEntity.getVersion());
|
response.setVersion(databaseConnectionEntity.getVersion());
|
||||||
response.setDriver(databaseConnectionEntity.getDriver());
|
response.setDriver(databaseConnectionEntity.getDriver());
|
||||||
|
response.setMode(databaseConnectionEntity.getMode());
|
||||||
|
response.setAddress(databaseConnectionEntity.getAddress());
|
||||||
|
response.setPort(databaseConnectionEntity.getPort());
|
||||||
|
response.setDatabaseName(databaseConnectionEntity.getDatabaseName());
|
||||||
|
response.setCharacterEncoding(databaseConnectionEntity.getCharacterEncoding());
|
||||||
response.setUrl(databaseConnectionEntity.getUrl());
|
response.setUrl(databaseConnectionEntity.getUrl());
|
||||||
response.setUsername(databaseConnectionEntity.getUsername());
|
response.setUsername(databaseConnectionEntity.getUsername());
|
||||||
response.setPassword(databaseConnectionEntity.getPassword());
|
response.setPassword(databaseConnectionEntity.getPassword());
|
||||||
|
@@ -77,6 +77,13 @@ public class ConnectionController {
|
|||||||
return connectionService.test(id);
|
return connectionService.test(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TokenCheck
|
||||||
|
@ApiOperation(value = "预测试连接")
|
||||||
|
@PostMapping(value = "/preTest", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public Result preTest(@RequestBody DbConnectionCreateRequest request) {
|
||||||
|
return connectionService.preTest(request);
|
||||||
|
}
|
||||||
|
|
||||||
@TokenCheck
|
@TokenCheck
|
||||||
@ApiOperation(value = "查询连接的Schema列表")
|
@ApiOperation(value = "查询连接的Schema列表")
|
||||||
@GetMapping(value = "/schemas/get/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = "/schemas/get/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@@ -44,6 +44,21 @@ public class DatabaseConnectionEntity {
|
|||||||
@TableField("driver")
|
@TableField("driver")
|
||||||
private String driver;
|
private String driver;
|
||||||
|
|
||||||
|
@TableField("mode")
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
|
@TableField("address")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@TableField("port")
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
@TableField("database_name")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
@TableField("character_encoding")
|
||||||
|
private String characterEncoding;
|
||||||
|
|
||||||
@TableField("url")
|
@TableField("url")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
@@ -22,6 +22,11 @@ public class DbConnectionCreateRequest {
|
|||||||
private ProductTypeEnum type;
|
private ProductTypeEnum type;
|
||||||
private String version;
|
private String version;
|
||||||
private String driver;
|
private String driver;
|
||||||
|
private Integer mode;
|
||||||
|
private String address;
|
||||||
|
private String port;
|
||||||
|
private String databaseName;
|
||||||
|
private String characterEncoding;
|
||||||
private String url;
|
private String url;
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
@@ -33,6 +38,11 @@ public class DbConnectionCreateRequest {
|
|||||||
databaseConnectionEntity.setType(type);
|
databaseConnectionEntity.setType(type);
|
||||||
databaseConnectionEntity.setVersion(version.trim());
|
databaseConnectionEntity.setVersion(version.trim());
|
||||||
databaseConnectionEntity.setDriver(driver.trim());
|
databaseConnectionEntity.setDriver(driver.trim());
|
||||||
|
databaseConnectionEntity.setMode(0);
|
||||||
|
databaseConnectionEntity.setAddress(address.trim());
|
||||||
|
databaseConnectionEntity.setPort(port.trim());
|
||||||
|
databaseConnectionEntity.setDatabaseName(databaseName.trim());
|
||||||
|
databaseConnectionEntity.setCharacterEncoding(characterEncoding.trim());
|
||||||
databaseConnectionEntity.setUrl(url.trim());
|
databaseConnectionEntity.setUrl(url.trim());
|
||||||
databaseConnectionEntity.setUsername(username);
|
databaseConnectionEntity.setUsername(username);
|
||||||
databaseConnectionEntity.setPassword(password);
|
databaseConnectionEntity.setPassword(password);
|
||||||
|
@@ -34,4 +34,7 @@ public class DatabaseTypeDetailResponse {
|
|||||||
@ApiModelProperty("数据库名称")
|
@ApiModelProperty("数据库名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("数据库链接模板")
|
||||||
|
private String url;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -37,6 +37,21 @@ public class DbConnectionDetailResponse {
|
|||||||
@ApiModelProperty("驱动类")
|
@ApiModelProperty("驱动类")
|
||||||
private String driver;
|
private String driver;
|
||||||
|
|
||||||
|
@ApiModelProperty("连接模式:0默认 1专业")
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
|
@ApiModelProperty("连接地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@ApiModelProperty("连接端口号")
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
@ApiModelProperty("数据库名")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
@ApiModelProperty("编码格式")
|
||||||
|
private String characterEncoding;
|
||||||
|
|
||||||
@ApiModelProperty("URL连接串")
|
@ApiModelProperty("URL连接串")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
@@ -94,6 +94,7 @@ public class ConnectionService {
|
|||||||
detail.setDriver(type.getDriver());
|
detail.setDriver(type.getDriver());
|
||||||
detail.setSample(type.getSample());
|
detail.setSample(type.getSample());
|
||||||
detail.setName(type.getName());
|
detail.setName(type.getName());
|
||||||
|
detail.setUrl(type.getUrl()[0]);
|
||||||
lists.add(detail);
|
lists.add(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,4 +282,21 @@ public class ConnectionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result preTest(DbConnectionCreateRequest request) {
|
||||||
|
DatabaseConnectionEntity dbConn = new DatabaseConnectionEntity();
|
||||||
|
dbConn.setType(request.getType());
|
||||||
|
dbConn.setUsername(request.getUsername());
|
||||||
|
dbConn.setPassword(request.getPassword());
|
||||||
|
dbConn.setName(request.getName());
|
||||||
|
dbConn.setVersion(request.getVersion());
|
||||||
|
dbConn.setUrl(request.getUrl());
|
||||||
|
dbConn.setDriver(request.getDriver());
|
||||||
|
MetadataService metaDataService = getMetaDataCoreService(dbConn);
|
||||||
|
try {
|
||||||
|
metaDataService.testQuerySQL(dbConn.getType().getSql());
|
||||||
|
} finally {
|
||||||
|
metaDataService.close();
|
||||||
|
}
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,14 @@
|
|||||||
|
ALTER TABLE `DBSWITCH_DATABASE_CONNECTION`
|
||||||
|
ADD COLUMN `mode` varchar(20) not null default '0' comment '连接模式:0默认 1专业' AFTER `driver`;
|
||||||
|
|
||||||
|
ALTER TABLE `DBSWITCH_DATABASE_CONNECTION`
|
||||||
|
ADD COLUMN `address` varchar(200) not null default '' comment '连接地址' AFTER `mode`;
|
||||||
|
|
||||||
|
ALTER TABLE `DBSWITCH_DATABASE_CONNECTION`
|
||||||
|
ADD COLUMN `port` varchar(20) not null default '' comment '连接端口号' AFTER `address`;
|
||||||
|
|
||||||
|
ALTER TABLE `DBSWITCH_DATABASE_CONNECTION`
|
||||||
|
ADD COLUMN `database_name` varchar(200) not null default '' comment '数据库名' AFTER `port`;
|
||||||
|
|
||||||
|
ALTER TABLE `DBSWITCH_DATABASE_CONNECTION`
|
||||||
|
ADD COLUMN `character_encoding` varchar(20) not null default '' comment '编码格式' AFTER `database_name`;
|
@@ -30,7 +30,7 @@ public enum ProductTypeEnum {
|
|||||||
"/* ping */ SELECT 1",
|
"/* ping */ SELECT 1",
|
||||||
"jdbc:mysql://",
|
"jdbc:mysql://",
|
||||||
new String[]{"jdbc:mysql://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:mysql://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:mysql://172.17.2.10:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&tinyInt1isBit=false&rewriteBatchedStatements=true&useCompression=true"),
|
"jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&tinyInt1isBit=false&rewriteBatchedStatements=true&useCompression=true"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MariaDB数据库类型
|
* MariaDB数据库类型
|
||||||
@@ -39,7 +39,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:mariadb://",
|
"jdbc:mariadb://",
|
||||||
new String[]{"jdbc:mariadb://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:mariadb://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:mariadb://172.17.2.10:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&tinyInt1isBit=false&rewriteBatchedStatements=true&useCompression=true"),
|
"jdbc:mariadb://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&tinyInt1isBit=false&rewriteBatchedStatements=true&useCompression=true"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Oracle数据库类型
|
* Oracle数据库类型
|
||||||
@@ -49,7 +49,7 @@ public enum ProductTypeEnum {
|
|||||||
"jdbc:oracle:thin:@",
|
"jdbc:oracle:thin:@",
|
||||||
new String[]{"jdbc:oracle:thin:@{host}:{port}:{database}",
|
new String[]{"jdbc:oracle:thin:@{host}:{port}:{database}",
|
||||||
"jdbc:oracle:thin:@//{host}[:{port}]/{database}"},
|
"jdbc:oracle:thin:@//{host}[:{port}]/{database}"},
|
||||||
"jdbc:oracle:thin:@172.17.2.10:1521:ORCL"),
|
"jdbc:oracle:thin:@127.0.0.1:1521:ORCL"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Microsoft SQL Server数据库类型(>=2005)
|
* Microsoft SQL Server数据库类型(>=2005)
|
||||||
@@ -58,7 +58,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1+2 as a",
|
"SELECT 1+2 as a",
|
||||||
"jdbc:sqlserver://",
|
"jdbc:sqlserver://",
|
||||||
new String[]{"jdbc:sqlserver://{host}[:{port}][;DatabaseName={database}][;{params}]"},
|
new String[]{"jdbc:sqlserver://{host}[:{port}][;DatabaseName={database}][;{params}]"},
|
||||||
"jdbc:sqlserver://172.17.2.10:1433;DatabaseName=test"),
|
"jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PostgreSQL数据库类型
|
* PostgreSQL数据库类型
|
||||||
@@ -67,7 +67,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:postgresql://",
|
"jdbc:postgresql://",
|
||||||
new String[]{"jdbc:postgresql://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:postgresql://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:postgresql://172.17.2.10:5432/test"),
|
"jdbc:postgresql://127.0.0.1:5432/test"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB2数据库类型
|
* DB2数据库类型
|
||||||
@@ -76,7 +76,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1 FROM SYSIBM.SYSDUMMY1",
|
"SELECT 1 FROM SYSIBM.SYSDUMMY1",
|
||||||
"jdbc:db2://",
|
"jdbc:db2://",
|
||||||
new String[]{"jdbc:db2://{host}:{port}/{database}[:{params}]"},
|
new String[]{"jdbc:db2://{host}:{port}/{database}[:{params}]"},
|
||||||
"jdbc:db2://172.17.2.10:50000/testdb:driverType=4;fullyMaterializeLobData=true;fullyMaterializeInputStreams=true;progressiveStreaming=2;progresssiveLocators=2;"),
|
"jdbc:db2://127.0.0.1:50000/testdb:driverType=4;fullyMaterializeLobData=true;fullyMaterializeInputStreams=true;progressiveStreaming=2;progresssiveLocators=2;"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [国产] 达梦(DM)数据库类型
|
* [国产] 达梦(DM)数据库类型
|
||||||
@@ -85,7 +85,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 'Hello' from DUAL",
|
"SELECT 'Hello' from DUAL",
|
||||||
"jdbc:dm://",
|
"jdbc:dm://",
|
||||||
new String[]{"jdbc:dm://{host}:{port}[/{database}][\\?{params}]"},
|
new String[]{"jdbc:dm://{host}:{port}[/{database}][\\?{params}]"},
|
||||||
"jdbc:dm://172.17.2.10:5236"),
|
"jdbc:dm://127.0.0.1:5236"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [国产] 金仓(Kingbase)数据库类型
|
* [国产] 金仓(Kingbase)数据库类型
|
||||||
@@ -94,7 +94,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:kingbase8://",
|
"jdbc:kingbase8://",
|
||||||
new String[]{"jdbc:kingbase8://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:kingbase8://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:kingbase8://172.17.2.10:54321/test"),
|
"jdbc:kingbase8://127.0.0.1:54321/test"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [国产] 神通(Oscar)数据库类型
|
* [国产] 神通(Oscar)数据库类型
|
||||||
@@ -103,7 +103,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:oscar://",
|
"jdbc:oscar://",
|
||||||
new String[]{"jdbc:oscar://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:oscar://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:oscar://172.17.2.10:2003/OSCRDB"),
|
"jdbc:oscar://127.0.0.1:2003/OSCRDB"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [国产] 南大通用(GBase8A)数据库类型
|
* [国产] 南大通用(GBase8A)数据库类型
|
||||||
@@ -112,7 +112,7 @@ public enum ProductTypeEnum {
|
|||||||
"/* ping */ SELECT 1",
|
"/* ping */ SELECT 1",
|
||||||
"jdbc:gbase://",
|
"jdbc:gbase://",
|
||||||
new String[]{"jdbc:gbase://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:gbase://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:gbase://172.17.2.10:5258/test"),
|
"jdbc:gbase://127.0.0.1:5258/test"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highgo数据库类型:https://blog.csdn.net/weixin_39676699/article/details/134338598
|
* Highgo数据库类型:https://blog.csdn.net/weixin_39676699/article/details/134338598
|
||||||
@@ -121,7 +121,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:highgo://",
|
"jdbc:highgo://",
|
||||||
new String[]{"jdbc:highgo://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:highgo://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:highgo://172.17.2.10:5866/highgo"),
|
"jdbc:highgo://127.0.0.1:5866/highgo"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sybase 数据库类型
|
* Sybase 数据库类型
|
||||||
@@ -130,7 +130,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1+2 as a",
|
"SELECT 1+2 as a",
|
||||||
"jdbc:sybase:Tds:",
|
"jdbc:sybase:Tds:",
|
||||||
new String[]{"jdbc:sybase:Tds:{host}[:{port}][/{database}][\\?{params}]"},
|
new String[]{"jdbc:sybase:Tds:{host}[:{port}][/{database}][\\?{params}]"},
|
||||||
"jdbc:sybase:Tds:172.17.2.10:5000/test?charset=cp936"),
|
"jdbc:sybase:Tds:127.0.0.1:5000/test?charset=cp936"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hive 数据库类型
|
* Hive 数据库类型
|
||||||
@@ -158,7 +158,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:opengauss://",
|
"jdbc:opengauss://",
|
||||||
new String[]{"jdbc:opengauss://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:opengauss://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:opengauss://172.17.2.10:5866/test"),
|
"jdbc:opengauss://127.0.0.1:5866/test"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClickHouse数据库类型
|
* ClickHouse数据库类型
|
||||||
@@ -167,7 +167,7 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:clickhouse://",
|
"jdbc:clickhouse://",
|
||||||
new String[]{"jdbc:clickhouse://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:clickhouse://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:clickhouse://172.17.2.10:8123/default"),
|
"jdbc:clickhouse://127.0.0.1:8123/default"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MongoDB数据库类型
|
* MongoDB数据库类型
|
||||||
|
Reference in New Issue
Block a user