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
|
||||
|
||||
Reference in New Issue
Block a user