数据库文档优化
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -63,6 +64,11 @@ public class DbDatasource implements Serializable {
|
||||
*/
|
||||
private Integer yn;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -141,4 +147,12 @@ public class DbDatasource implements Serializable {
|
||||
", yn=" + yn +
|
||||
"}";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,12 @@ public class DatabaseDocController {
|
||||
@PostMapping(value = "/getDataSourceList")
|
||||
public ResponseJson getDataSourceList() {
|
||||
List<DatabaseFactoryBean> factoryBeanList = databaseRegistrationBean.getDatabaseFactoryBeanList();
|
||||
Set<String> dataSourceList = factoryBeanList.stream().collect(Collectors.mapping(DatabaseFactoryBean::getHost, Collectors.toSet()));
|
||||
List<DatabaseFactoryBean> dataSourceList = factoryBeanList.stream().map(val -> {
|
||||
DatabaseFactoryBean bean = new DatabaseFactoryBean();
|
||||
bean.setCnName(val.getCnName());
|
||||
bean.setHost(val.getHost());
|
||||
return bean;
|
||||
}).collect(Collectors.toList());
|
||||
return DocDbResponseJson.ok(dataSourceList);
|
||||
}
|
||||
|
||||
@@ -90,14 +95,15 @@ public class DatabaseDocController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getTableAndColumnBySearch")
|
||||
public ResponseJson getTableAndColumnBySearch(String host, String dbName, String tableName, String searchText) {
|
||||
public ResponseJson getTableAndColumnBySearch(String host, String dbName, String searchText) {
|
||||
BaseMapper baseMapper = databaseRegistrationBean.getBaseMapper(host, dbName);
|
||||
if (baseMapper == null) {
|
||||
return DocDbResponseJson.warn("未找到对应的数据库连接");
|
||||
}
|
||||
if (StringUtils.isNotBlank(searchText)) {
|
||||
searchText = "%" + searchText + "%";
|
||||
if (StringUtils.isBlank(searchText)) {
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
searchText = "%" + searchText + "%";
|
||||
List<QueryTableColumnDescDto> columnDescDto = baseMapper.getTableAndColumnBySearch(dbName, searchText);
|
||||
return DocDbResponseJson.ok(columnDescDto);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,9 @@ public class DbDatasourceController {
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
public ResponseJson update(DbDatasource dbDatasource) {
|
||||
if (StringUtils.isBlank(dbDatasource.getDriverClassName())) {
|
||||
if (StringUtils.isBlank(dbDatasource.getName())) {
|
||||
return DocDbResponseJson.warn("名字必填");
|
||||
} else if (StringUtils.isBlank(dbDatasource.getDriverClassName())) {
|
||||
return DocDbResponseJson.warn("驱动类必选");
|
||||
} else if (StringUtils.isBlank(dbDatasource.getSourceUrl())) {
|
||||
return DocDbResponseJson.warn("地址必填");
|
||||
|
||||
@@ -79,6 +79,7 @@ public class DatasourceUtil {
|
||||
SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactoryBean.getObject());
|
||||
// 组装自定义的bean
|
||||
databaseFactoryBean.setId(dbDatasource.getId());
|
||||
databaseFactoryBean.setCnName(dbDatasource.getName());
|
||||
databaseFactoryBean.setDataSource(dataSource);
|
||||
databaseFactoryBean.setSqlSessionTemplate(sqlSessionTemplate);
|
||||
databaseFactoryBean.setUrl(dbUrl);
|
||||
|
||||
@@ -15,6 +15,7 @@ public class DatabaseFactoryBean {
|
||||
private String url;
|
||||
private String host;
|
||||
private String dbName;
|
||||
private String cnName;
|
||||
private DatabaseProduct databaseProduct;
|
||||
|
||||
public Long getId() {
|
||||
@@ -25,6 +26,14 @@ public class DatabaseFactoryBean {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCnName() {
|
||||
return cnName;
|
||||
}
|
||||
|
||||
public void setCnName(String cnName) {
|
||||
this.cnName = cnName;
|
||||
}
|
||||
|
||||
public static enum DatabaseProduct {
|
||||
MYSQL, SQLSERVER
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(n&&n(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=r(r.s=u[l]);return f};var t={},o={2:0};r.e=function(e){function n(){u.onerror=u.onload=null,clearTimeout(i);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=new Promise(function(r,n){o[e]=[r,n]});o[e][2]=t;var c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,r.nc&&u.setAttribute("nonce",r.nc),u.src=r.p+""+e+".js?"+{0:"7a0b1d53731cf2c22acc",1:"17e0ecc3b118c4297f8c"}[e];var i=setTimeout(n,12e4);return u.onerror=u.onload=n,c.appendChild(u),t},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r.oe=function(e){throw console.error(e),e}}([]);
|
||||
//# sourceMappingURL=doc-db-manifest.js.map?b952b0b2e8c047829f82
|
||||
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var a,i,f,l=0,s=[];l<t.length;l++)i=t[l],o[i]&&s.push(o[i][0]),o[i]=0;for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&(e[a]=c[a]);for(n&&n(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=r(r.s=u[l]);return f};var t={},o={2:0};r.e=function(e){function n(){u.onerror=u.onload=null,clearTimeout(a);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=new Promise(function(r,n){o[e]=[r,n]});o[e][2]=t;var c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,r.nc&&u.setAttribute("nonce",r.nc),u.src=r.p+""+e+".js?"+{0:"d65c66b35810c9f776c3",1:"911ef238eaa4f43bee2a"}[e];var a=setTimeout(n,12e4);return u.onerror=u.onload=n,c.appendChild(u),t},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r.oe=function(e){throw console.error(e),e}}([]);
|
||||
//# sourceMappingURL=doc-db-manifest.js.map?f2c814ab41481d96042e
|
||||
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="text/javascript" src="doc-db-manifest.js?b952b0b2e8c047829f82"></script><script type="text/javascript" src="doc-db-vendor.js?7a0b1d53731cf2c22acc"></script><script type="text/javascript" src="doc-db-index.js?17e0ecc3b118c4297f8c"></script></body>
|
||||
<script type="text/javascript" src="doc-db-manifest.js?f2c814ab41481d96042e"></script><script type="text/javascript" src="doc-db-vendor.js?d65c66b35810c9f776c3"></script><script type="text/javascript" src="doc-db-index.js?911ef238eaa4f43bee2a"></script></body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
var datasourceOptions = [];
|
||||
for (var i = 0; i < app.datasourceList.length; i++) {
|
||||
datasourceOptions.push({
|
||||
label: app.datasourceList[i], value: app.datasourceList[i]
|
||||
label: app.datasourceList[i].cnName, value: app.datasourceList[i].host
|
||||
});
|
||||
}
|
||||
app.datasourceOptions = datasourceOptions;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<el-button style="float: right;" v-on:click="addDatasource" type="primary" icon="el-icon-circle-plus-outline" size="small">新增</el-button>
|
||||
</div>
|
||||
<el-table :data="datasourceList" stripe border style="width: 100%; margin-bottom: 5px;">
|
||||
<el-table-column prop="name" label="名字" width="100"></el-table-column>
|
||||
<el-table-column prop="driverClassName" label="驱动类" width="200"></el-table-column>
|
||||
<el-table-column prop="sourceUrl" label="数据源URL"></el-table-column>
|
||||
<el-table-column prop="sourceName" label="账号"></el-table-column>
|
||||
@@ -30,6 +31,9 @@
|
||||
show-icon style="margin-bottom: 10px;">
|
||||
</el-alert>
|
||||
<el-form label-width="120px">
|
||||
<el-form-item label="名字:">
|
||||
<el-input v-model="newDatasource.name" placeholder="中文名字"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="驱动类:">
|
||||
<el-select v-model="newDatasource.driverClassName" placeholder="驱动类" style="width: 100%">
|
||||
<el-option label="com.mysql.jdbc.Driver" value="com.mysql.jdbc.Driver"></el-option>
|
||||
@@ -76,10 +80,10 @@
|
||||
methods: {
|
||||
addDatasource() {
|
||||
this.datasourceDialogVisible = true;
|
||||
this.newDatasource = {driverClassName: "", sourceUrl: "", sourceName: "", sourcePassword: ""};
|
||||
this.newDatasource = {name: "", driverClassName: "", sourceUrl: "", sourceName: "", sourcePassword: ""};
|
||||
},
|
||||
editDatasource(row) {
|
||||
this.newDatasource = row;
|
||||
this.newDatasource = JSON.parse(JSON.stringify(row));
|
||||
this.datasourceDialogVisible = true;
|
||||
},
|
||||
deleteDatasource(row) {
|
||||
|
||||
Reference in New Issue
Block a user