DDL多数据源支持,虽然还没实现
This commit is contained in:
@@ -16,6 +16,7 @@ import com.zyplayer.doc.data.utils.CacheUtil;
|
||||
import com.zyplayer.doc.db.controller.vo.DatabaseExportVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo.TableInfoVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableDdlVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableStatusVo;
|
||||
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
@@ -110,8 +111,8 @@ public class DatabaseDocController {
|
||||
@PostMapping(value = "/getTableDdl")
|
||||
public ResponseJson getTableDdl(Long sourceId, String dbName, String tableName) {
|
||||
DbBaseService dbBaseService = dbBaseFactory.getDbBaseService(sourceId);
|
||||
String tableDdl = dbBaseService.getTableDdl(sourceId, dbName, tableName);
|
||||
return DocDbResponseJson.ok(tableDdl);
|
||||
TableDdlVo tableDdlVo = dbBaseService.getTableDdl(sourceId, dbName, tableName);
|
||||
return DocDbResponseJson.ok(tableDdlVo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getDatabaseList")
|
||||
@@ -200,8 +201,8 @@ public class DatabaseDocController {
|
||||
DbBaseService dbBaseService = dbBaseFactory.getDbBaseService(sourceId);
|
||||
Map<String, String> ddlSqlMap = new HashMap<>();
|
||||
for (String tableName : tableNameList) {
|
||||
String tableDdl = dbBaseService.getTableDdl(sourceId, dbName, tableName);
|
||||
ddlSqlMap.put(tableName, tableDdl);
|
||||
TableDdlVo tableDdlVo = dbBaseService.getTableDdl(sourceId, dbName, tableName);
|
||||
ddlSqlMap.put(tableName, tableDdlVo.getTableDDLByType());
|
||||
}
|
||||
try {
|
||||
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getOrCreateFactoryById(sourceId);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.zyplayer.doc.db.controller.vo;
|
||||
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class TableDdlVo {
|
||||
private String current;
|
||||
private String mysql;
|
||||
private String sqlserver;
|
||||
private String oracle;
|
||||
private String postgresql;
|
||||
|
||||
public String getTableDDLByType() {
|
||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.MYSQL.name().toLowerCase())) return mysql;
|
||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.SQLSERVER.name().toLowerCase())) return sqlserver;
|
||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.ORACLE.name().toLowerCase())) return oracle;
|
||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.POSTGRESQL.name().toLowerCase())) return postgresql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setCurrent(String current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public String getMysql() {
|
||||
return mysql;
|
||||
}
|
||||
|
||||
public void setMysql(String mysql) {
|
||||
this.mysql = mysql;
|
||||
}
|
||||
|
||||
public String getSqlserver() {
|
||||
return sqlserver;
|
||||
}
|
||||
|
||||
public void setSqlserver(String sqlserver) {
|
||||
this.sqlserver = sqlserver;
|
||||
}
|
||||
|
||||
public String getOracle() {
|
||||
return oracle;
|
||||
}
|
||||
|
||||
public void setOracle(String oracle) {
|
||||
this.oracle = oracle;
|
||||
}
|
||||
|
||||
public String getPostgresql() {
|
||||
return postgresql;
|
||||
}
|
||||
|
||||
public void setPostgresql(String postgresql) {
|
||||
this.postgresql = postgresql;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableDdlVo;
|
||||
import com.zyplayer.doc.db.controller.vo.TableStatusVo;
|
||||
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
@@ -66,7 +67,7 @@ public abstract class DbBaseService {
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月8日
|
||||
*/
|
||||
public String getTableDdl(Long sourceId, String dbName, String tableName) {
|
||||
public TableDdlVo getTableDdl(Long sourceId, String dbName, String tableName) {
|
||||
// 需要各数据服务自己实现,各数据库产品的实现都不一样
|
||||
throw new ConfirmException("暂未支持的数据库类型");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zyplayer.doc.db.service;
|
||||
|
||||
import com.zyplayer.doc.db.controller.vo.TableDdlVo;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
import com.zyplayer.doc.db.framework.db.dto.ColumnInfoDto;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
||||
@@ -19,10 +20,15 @@ public class MysqlServiceImpl extends DbBaseService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableDdl(Long sourceId, String dbName, String tableName) {
|
||||
public TableDdlVo getTableDdl(Long sourceId, String dbName, String tableName) {
|
||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||
Map<String, String> tableDdl = baseMapper.getTableDdl(dbName, tableName);
|
||||
return tableDdl.get("Create Table");
|
||||
TableDdlVo tableDdlVo = new TableDdlVo();
|
||||
tableDdlVo.setCurrent(DatabaseFactoryBean.DatabaseProduct.MYSQL.name().toLowerCase());
|
||||
tableDdlVo.setMysql(tableDdl.get("Create Table"));
|
||||
tableDdlVo.setOracle("// TODO 等待大佬来实现转换");
|
||||
// TODO 将建表语句转换为其他数据库的,还不知道怎么做,先这样留着,看有没大佬来实现
|
||||
return tableDdlVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
ENV = 'development'
|
||||
|
||||
# base api
|
||||
# VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
|
||||
VUE_APP_BASE_API = 'http://doc.zyplayer.com/zyplayer-doc-manage'
|
||||
VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
|
||||
# VUE_APP_BASE_API = 'http://doc.zyplayer.com/zyplayer-doc-manage'
|
||||
|
||||
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
||||
|
||||
|
||||
@@ -80,11 +80,30 @@
|
||||
<el-dialog :visible.sync="tableDDLInfoDialogVisible" :footer="null" width="760px">
|
||||
<div slot="title">
|
||||
<span style="margin-right: 15px;">DDL</span>
|
||||
<el-button size="small" icon="el-icon-document-copy" v-clipboard:copy="tableDDLInfo" v-clipboard:success="onCopySuccess" v-clipboard:error="onCopyError">复制</el-button>
|
||||
<el-button size="small" icon="el-icon-document-copy" v-clipboard:copy="tableDDLInfo[tableDDLInfoTab]" v-clipboard:success="onCopySuccess" v-clipboard:error="onCopyError">复制</el-button>
|
||||
</div>
|
||||
<div v-highlight>
|
||||
<pre><code v-html="tableDDLInfo"></code></pre>
|
||||
</div>
|
||||
<el-tabs v-model="tableDDLInfoTab">
|
||||
<el-tab-pane label="mysql" name="mysql" v-if="!!tableDDLInfo.mysql">
|
||||
<div v-highlight>
|
||||
<pre><code v-html="tableDDLInfo.mysql"></code></pre>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="sqlserver" name="sqlserver" v-if="!!tableDDLInfo.sqlserver">
|
||||
<div v-highlight>
|
||||
<pre><code v-html="tableDDLInfo.sqlserver"></code></pre>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="oracle" name="oracle" v-if="!!tableDDLInfo.oracle">
|
||||
<div v-highlight>
|
||||
<pre><code v-html="tableDDLInfo.oracle"></code></pre>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="postgresql" name="postgresql" v-if="!!tableDDLInfo.postgresql">
|
||||
<div v-highlight>
|
||||
<pre><code v-html="tableDDLInfo.postgresql"></code></pre>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -101,6 +120,7 @@
|
||||
columnList: [],
|
||||
tableInfo: {},
|
||||
nowExecutorId: 1,
|
||||
tableDDLInfoTab: '',
|
||||
tableDDLInfo: '',
|
||||
tableDDLInfoDialogVisible: false,
|
||||
};
|
||||
@@ -163,10 +183,12 @@
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
this.tableDDLInfoTab = '';
|
||||
this.tableDDLInfoDialogVisible = false;
|
||||
datasourceApi.queryTableDdl(param).then(res => {
|
||||
loading.close();
|
||||
this.tableDDLInfo = res.data || '获取失败';
|
||||
this.tableDDLInfo = res.data || {};
|
||||
this.tableDDLInfoTab = this.tableDDLInfo.current;
|
||||
setTimeout(() => this.tableDDLInfoDialogVisible = true, 0);
|
||||
}).catch(() => {
|
||||
loading.close();
|
||||
|
||||
Reference in New Issue
Block a user