轻轻的优化了一下数据库框架
This commit is contained in:
@@ -15,7 +15,7 @@ zyplayer-doc是一款在线文档工具,现有swagger 文档、dubbo文档、
|
|||||||
2. 集成了本项目内的各个子模块功能,是各模块的协调管理模块。
|
2. 集成了本项目内的各个子模块功能,是各模块的协调管理模块。
|
||||||
|
|
||||||
### 二、zyplayer-doc-db 数据库文档
|
### 二、zyplayer-doc-db 数据库文档
|
||||||
1. 支持MySQL、SQLServer、Oracle、PostgreSQL数据库。
|
1. 支持MySQL、SQLServer、Oracle、PostgreSQL、Hive、Impala数据源。
|
||||||
2. 支持数据库表、字段文档查看修改,表文档导出、建表语句DDL导出。
|
2. 支持数据库表、字段文档查看修改,表文档导出、建表语句DDL导出。
|
||||||
3. 支持SQL执行、表数据预览、不同数据库之间的数据互导,支持多数据源管理。
|
3. 支持SQL执行、表数据预览、不同数据库之间的数据互导,支持多数据源管理。
|
||||||
4. 支持按人员、按数据源对用户授权,可给用户 库表注释查看、注释修改、SQL执行、函数修改等粒度的授权。
|
4. 支持按人员、按数据源对用户授权,可给用户 库表注释查看、注释修改、SQL执行、函数修改等粒度的授权。
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import com.zyplayer.doc.db.controller.vo.TableDdlVo;
|
|||||||
import com.zyplayer.doc.db.controller.vo.TableStatusVo;
|
import com.zyplayer.doc.db.controller.vo.TableStatusVo;
|
||||||
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean.DatabaseProduct;
|
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||||
import com.zyplayer.doc.db.framework.db.dto.*;
|
import com.zyplayer.doc.db.framework.db.dto.*;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||||
import com.zyplayer.doc.db.framework.utils.PoiUtil;
|
import com.zyplayer.doc.db.framework.utils.PoiUtil;
|
||||||
import com.zyplayer.doc.db.service.DbBaseFactory;
|
import com.zyplayer.doc.db.service.DbBaseFactory;
|
||||||
@@ -206,7 +206,7 @@ public class DatabaseDocController {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getOrCreateFactoryById(sourceId);
|
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getOrCreateFactoryById(sourceId);
|
||||||
DatabaseProduct databaseProduct = databaseFactoryBean.getDatabaseProduct();
|
DatabaseProductEnum databaseProduct = databaseFactoryBean.getDatabaseProduct();
|
||||||
PoiUtil.exportByDdl(ddlSqlMap, dbName, databaseProduct.name(), response);
|
PoiUtil.exportByDdl(ddlSqlMap, dbName, databaseProduct.name(), response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||||
|
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||||
import com.zyplayer.doc.core.json.ResponseJson;
|
import com.zyplayer.doc.core.json.ResponseJson;
|
||||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||||
@@ -70,7 +71,7 @@ public class DbDatasourceController {
|
|||||||
Set<String> groupNameSet = datasourceList.stream().map(DbDatasource::getGroupName).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
Set<String> groupNameSet = datasourceList.stream().map(DbDatasource::getGroupName).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
||||||
return DocDbResponseJson.ok(groupNameSet);
|
return DocDbResponseJson.ok(groupNameSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/test")
|
@PostMapping(value = "/test")
|
||||||
public ResponseJson test(DbDatasource dbDatasource) {
|
public ResponseJson test(DbDatasource dbDatasource) {
|
||||||
// 验证新的数据源
|
// 验证新的数据源
|
||||||
@@ -83,10 +84,9 @@ public class DbDatasourceController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource, true);
|
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource, true);
|
||||||
if (databaseFactoryBean == null) {
|
|
||||||
return DocDbResponseJson.warn("获取数据源失败,请检查配置是否正确");
|
|
||||||
}
|
|
||||||
databaseFactoryBean.getDataSource().close();
|
databaseFactoryBean.getDataSource().close();
|
||||||
|
} catch (ConfirmException e) {
|
||||||
|
return DocDbResponseJson.warn(e.getMessage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return DocDbResponseJson.warn(ExceptionUtils.getFullStackTrace(e));
|
return DocDbResponseJson.warn(ExceptionUtils.getFullStackTrace(e));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.zyplayer.doc.db.controller.vo;
|
package com.zyplayer.doc.db.controller.vo;
|
||||||
|
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -13,11 +13,11 @@ public class TableDdlVo {
|
|||||||
private String hive;
|
private String hive;
|
||||||
|
|
||||||
public String getTableDDLByType() {
|
public String getTableDDLByType() {
|
||||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.MYSQL.name().toLowerCase())) return mysql;
|
if (Objects.equals(current, DatabaseProductEnum.MYSQL.name().toLowerCase())) return mysql;
|
||||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.SQLSERVER.name().toLowerCase())) return sqlserver;
|
if (Objects.equals(current, DatabaseProductEnum.SQLSERVER.name().toLowerCase())) return sqlserver;
|
||||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.ORACLE.name().toLowerCase())) return oracle;
|
if (Objects.equals(current, DatabaseProductEnum.ORACLE.name().toLowerCase())) return oracle;
|
||||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.POSTGRESQL.name().toLowerCase())) return postgresql;
|
if (Objects.equals(current, DatabaseProductEnum.POSTGRESQL.name().toLowerCase())) return postgresql;
|
||||||
if (Objects.equals(current, DatabaseFactoryBean.DatabaseProduct.HIVE.name().toLowerCase())) return hive;
|
if (Objects.equals(current, DatabaseProductEnum.HIVE.name().toLowerCase())) return hive;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,83 +1,42 @@
|
|||||||
package com.zyplayer.doc.db.framework.configuration;
|
package com.zyplayer.doc.db.framework.configuration;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
|
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
|
||||||
import com.zyplayer.doc.data.utils.DruidDataSourceUtil;
|
import com.zyplayer.doc.data.utils.DruidDataSourceUtil;
|
||||||
|
import com.zyplayer.doc.db.framework.configuration.analysis.*;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import com.zyplayer.doc.db.framework.db.interceptor.SqlLogInterceptor;
|
import com.zyplayer.doc.db.framework.db.interceptor.SqlLogInterceptor;
|
||||||
import org.apache.ibatis.plugin.Interceptor;
|
import org.apache.ibatis.plugin.Interceptor;
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class DatasourceUtil {
|
public class DatasourceUtil {
|
||||||
private static SqlLogInterceptor sqlLogInterceptor = new SqlLogInterceptor();
|
private static final SqlLogInterceptor sqlLogInterceptor = new SqlLogInterceptor();
|
||||||
|
// url解析
|
||||||
|
private static final Map<String, AnalysisApi> analysisApiMap = new HashMap<String, AnalysisApi>() {{
|
||||||
|
put(DatabaseProductEnum.MYSQL.getDriverClassName(), new MysqlAnalysis());
|
||||||
|
put(DatabaseProductEnum.HIVE.getDriverClassName(), new HiveAnalysis());
|
||||||
|
put(DatabaseProductEnum.ORACLE.getDriverClassName(), new OracleAnalysis());
|
||||||
|
put(DatabaseProductEnum.POSTGRESQL.getDriverClassName(), new PostgresqlAnalysis());
|
||||||
|
put(DatabaseProductEnum.SQLSERVER.getDriverClassName(), new SqlserverAnalysis());
|
||||||
|
}};
|
||||||
|
|
||||||
public static DatabaseFactoryBean createDatabaseFactoryBean(DbDatasource dbDatasource, boolean breakAfterAcquireFailure) throws Exception {
|
public static DatabaseFactoryBean createDatabaseFactoryBean(DbDatasource dbDatasource, boolean breakAfterAcquireFailure) throws Exception {
|
||||||
Resource[] resources = null;
|
|
||||||
// 描述连接信息的对象
|
// 描述连接信息的对象
|
||||||
DatabaseFactoryBean databaseFactoryBean = new DatabaseFactoryBean();
|
DatabaseFactoryBean databaseFactoryBean = new DatabaseFactoryBean();
|
||||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
|
||||||
String dbUrl = dbDatasource.getSourceUrl();
|
String dbUrl = dbDatasource.getSourceUrl();
|
||||||
if (dbUrl.contains("mysql")) {
|
String driverClassName = dbDatasource.getDriverClassName();
|
||||||
// jdbc:mysql://192.168.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
|
AnalysisApi analysisApi = analysisApiMap.get(driverClassName);
|
||||||
String[] urlParamArr = dbUrl.split("\\?");
|
if (analysisApi == null) {
|
||||||
String[] urlDbNameArr = urlParamArr[0].split("/");
|
throw new ConfirmException("暂未支持的数据源类型");
|
||||||
if (urlDbNameArr.length >= 2) {
|
|
||||||
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
|
||||||
//databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 2]);
|
|
||||||
}
|
|
||||||
databaseFactoryBean.setDatabaseProduct(DatabaseFactoryBean.DatabaseProduct.MYSQL);
|
|
||||||
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/mysql/*.xml");
|
|
||||||
} else if (dbUrl.contains("hive")) {
|
|
||||||
// jdbc:hive2://127.0.0.1:21050/ads_data;auth=noSasl
|
|
||||||
String[] urlParamArr = dbUrl.split(";");
|
|
||||||
String[] urlDbNameArr = urlParamArr[0].split("/");
|
|
||||||
if (urlDbNameArr.length >= 2) {
|
|
||||||
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
|
||||||
}
|
|
||||||
databaseFactoryBean.setDatabaseProduct(DatabaseFactoryBean.DatabaseProduct.HIVE);
|
|
||||||
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/hive/*.xml");
|
|
||||||
} else if (dbUrl.contains("postgresql")) {
|
|
||||||
// jdbc:mysql://192.168.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
|
|
||||||
String[] urlParamArr = dbUrl.split("\\?");
|
|
||||||
String[] urlDbNameArr = urlParamArr[0].split("/");
|
|
||||||
if (urlDbNameArr.length >= 2) {
|
|
||||||
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
|
||||||
//databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 2]);
|
|
||||||
}
|
|
||||||
databaseFactoryBean.setDatabaseProduct(DatabaseFactoryBean.DatabaseProduct.POSTGRESQL);
|
|
||||||
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/postgresql/*.xml");
|
|
||||||
} else if (dbUrl.contains("sqlserver")) {
|
|
||||||
// jdbc:jtds:sqlserver://192.168.0.1:33434;socketTimeout=60;DatabaseName=user_info;
|
|
||||||
String[] urlParamArr = dbUrl.split(";");
|
|
||||||
//String[] urlDbNameArr = urlParamArr[0].split("/");
|
|
||||||
//databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 1]);
|
|
||||||
for (String urlParam : urlParamArr) {
|
|
||||||
String[] keyValArr = urlParam.split("=");
|
|
||||||
if (keyValArr.length >= 2 && keyValArr[0].equalsIgnoreCase("DatabaseName")) {
|
|
||||||
databaseFactoryBean.setDbName(keyValArr[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
databaseFactoryBean.setDatabaseProduct(DatabaseFactoryBean.DatabaseProduct.SQLSERVER);
|
|
||||||
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/sqlserver/*.xml");
|
|
||||||
} else if (dbUrl.contains("oracle")) {
|
|
||||||
// jdbc:oracle:thin:@127.0.0.1:1521:user_info
|
|
||||||
// jdbc:oracle:thin:@127.0.0.1:1521/user_info
|
|
||||||
// 代码是写好的,但还没有oracle的库让我测试过~
|
|
||||||
String[] urlParamArr = dbUrl.split("\\?")[0].split("@");
|
|
||||||
String[] urlDbNameArr = urlParamArr[0].split("/");
|
|
||||||
if (urlDbNameArr.length <= 1) {
|
|
||||||
urlDbNameArr = urlParamArr[0].split(":");
|
|
||||||
}
|
|
||||||
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
|
||||||
databaseFactoryBean.setDatabaseProduct(DatabaseFactoryBean.DatabaseProduct.ORACLE);
|
|
||||||
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/oracle/*.xml");
|
|
||||||
}
|
|
||||||
if (resources == null) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
Resource[] resources = analysisApi.process(dbUrl, databaseFactoryBean);
|
||||||
// 数据源配置
|
// 数据源配置
|
||||||
DruidDataSource dataSource = DruidDataSourceUtil.createDataSource(dbDatasource.getDriverClassName(), dbDatasource.getSourceUrl(), dbDatasource.getSourceName(), dbDatasource.getSourcePassword(), false);
|
DruidDataSource dataSource = DruidDataSourceUtil.createDataSource(dbDatasource.getDriverClassName(), dbDatasource.getSourceUrl(), dbDatasource.getSourceName(), dbDatasource.getSourcePassword(), false);
|
||||||
if (breakAfterAcquireFailure) {
|
if (breakAfterAcquireFailure) {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.zyplayer.doc.db.framework.configuration.analysis;
|
||||||
|
|
||||||
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
|
public interface AnalysisApi {
|
||||||
|
|
||||||
|
Resource[] process(String dbUrl, DatabaseFactoryBean databaseFactoryBean) throws Exception;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.zyplayer.doc.db.framework.configuration.analysis;
|
||||||
|
|
||||||
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
|
public class HiveAnalysis implements AnalysisApi {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resource[] process(String dbUrl, DatabaseFactoryBean databaseFactoryBean) throws Exception {
|
||||||
|
// jdbc:hive2://127.0.0.1:21050/ads_data;auth=noSasl
|
||||||
|
String[] urlParamArr = dbUrl.split(";");
|
||||||
|
String[] urlDbNameArr = urlParamArr[0].split("/");
|
||||||
|
if (urlDbNameArr.length >= 2) {
|
||||||
|
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
||||||
|
}
|
||||||
|
databaseFactoryBean.setDatabaseProduct(DatabaseProductEnum.HIVE);
|
||||||
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
return resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/hive/*.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.zyplayer.doc.db.framework.configuration.analysis;
|
||||||
|
|
||||||
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
|
public class MysqlAnalysis implements AnalysisApi {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resource[] process(String dbUrl, DatabaseFactoryBean databaseFactoryBean) throws Exception {
|
||||||
|
// jdbc:mysql://192.168.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
|
||||||
|
String[] urlParamArr = dbUrl.split("\\?");
|
||||||
|
String[] urlDbNameArr = urlParamArr[0].split("/");
|
||||||
|
if (urlDbNameArr.length >= 2) {
|
||||||
|
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
||||||
|
//databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 2]);
|
||||||
|
}
|
||||||
|
databaseFactoryBean.setDatabaseProduct(DatabaseProductEnum.MYSQL);
|
||||||
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
return resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/mysql/*.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.zyplayer.doc.db.framework.configuration.analysis;
|
||||||
|
|
||||||
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
|
public class OracleAnalysis implements AnalysisApi {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resource[] process(String dbUrl, DatabaseFactoryBean databaseFactoryBean) throws Exception {
|
||||||
|
// jdbc:oracle:thin:@127.0.0.1:1521:user_info
|
||||||
|
// 代码是写好的,但还没有oracle的库让我测试过~
|
||||||
|
String[] urlParamArr = dbUrl.split("\\?")[0].split("@");
|
||||||
|
String[] urlDbNameArr = urlParamArr[0].split("/");
|
||||||
|
if (urlDbNameArr.length <= 1) {
|
||||||
|
urlDbNameArr = urlParamArr[0].split(":");
|
||||||
|
}
|
||||||
|
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
||||||
|
databaseFactoryBean.setDatabaseProduct(DatabaseProductEnum.ORACLE);
|
||||||
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
return resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/oracle/*.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.zyplayer.doc.db.framework.configuration.analysis;
|
||||||
|
|
||||||
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
|
public class PostgresqlAnalysis implements AnalysisApi {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resource[] process(String dbUrl, DatabaseFactoryBean databaseFactoryBean) throws Exception {
|
||||||
|
// jdbc:mysql://192.168.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
|
||||||
|
String[] urlParamArr = dbUrl.split("\\?");
|
||||||
|
String[] urlDbNameArr = urlParamArr[0].split("/");
|
||||||
|
if (urlDbNameArr.length >= 2) {
|
||||||
|
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
|
||||||
|
//databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 2]);
|
||||||
|
}
|
||||||
|
databaseFactoryBean.setDatabaseProduct(DatabaseProductEnum.POSTGRESQL);
|
||||||
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
return resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/postgresql/*.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.zyplayer.doc.db.framework.configuration.analysis;
|
||||||
|
|
||||||
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
|
public class SqlserverAnalysis implements AnalysisApi {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resource[] process(String dbUrl, DatabaseFactoryBean databaseFactoryBean) throws Exception {
|
||||||
|
// jdbc:jtds:sqlserver://192.168.0.1:33434;socketTimeout=60;DatabaseName=user_info;
|
||||||
|
String[] urlParamArr = dbUrl.split(";");
|
||||||
|
//String[] urlDbNameArr = urlParamArr[0].split("/");
|
||||||
|
//databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 1]);
|
||||||
|
for (String urlParam : urlParamArr) {
|
||||||
|
String[] keyValArr = urlParam.split("=");
|
||||||
|
if (keyValArr.length >= 2 && keyValArr[0].equalsIgnoreCase("DatabaseName")) {
|
||||||
|
databaseFactoryBean.setDbName(keyValArr[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
databaseFactoryBean.setDatabaseProduct(DatabaseProductEnum.SQLSERVER);
|
||||||
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
return resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/sqlserver/*.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.zyplayer.doc.db.framework.db.bean;
|
package com.zyplayer.doc.db.framework.db.bean;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述连接信息的对象
|
* 描述连接信息的对象
|
||||||
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月8日
|
* @since 2018年8月8日
|
||||||
*/
|
*/
|
||||||
@@ -16,12 +18,7 @@ public class DatabaseFactoryBean {
|
|||||||
private String dbName;
|
private String dbName;
|
||||||
private String cnName;
|
private String cnName;
|
||||||
private String groupName;
|
private String groupName;
|
||||||
private DatabaseProduct databaseProduct;
|
private DatabaseProductEnum databaseProduct;
|
||||||
|
|
||||||
public static enum DatabaseProduct {
|
|
||||||
MYSQL, SQLSERVER, ORACLE, POSTGRESQL, HIVE
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -50,41 +47,41 @@ public class DatabaseFactoryBean {
|
|||||||
public DruidDataSource getDataSource() {
|
public DruidDataSource getDataSource() {
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataSource(DruidDataSource dataSource) {
|
public void setDataSource(DruidDataSource dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(String url) {
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDbName() {
|
public String getDbName() {
|
||||||
return dbName;
|
return dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDbName(String dbName) {
|
public void setDbName(String dbName) {
|
||||||
this.dbName = dbName;
|
this.dbName = dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatabaseProduct getDatabaseProduct() {
|
public DatabaseProductEnum getDatabaseProduct() {
|
||||||
return databaseProduct;
|
return databaseProduct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDatabaseProduct(DatabaseProduct databaseProduct) {
|
public void setDatabaseProduct(DatabaseProductEnum databaseProduct) {
|
||||||
this.databaseProduct = databaseProduct;
|
this.databaseProduct = databaseProduct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSessionTemplate getSqlSessionTemplate() {
|
public SqlSessionTemplate getSqlSessionTemplate() {
|
||||||
return sqlSessionTemplate;
|
return sqlSessionTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
|
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
|
||||||
this.sqlSessionTemplate = sqlSessionTemplate;
|
this.sqlSessionTemplate = sqlSessionTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class DatabaseRegistrationBean {
|
|||||||
DbDatasourceService dbDatasourceService;
|
DbDatasourceService dbDatasourceService;
|
||||||
|
|
||||||
// 描述连接信息的对象列表
|
// 描述连接信息的对象列表
|
||||||
private Map<Long, DatabaseFactoryBean> databaseFactoryBeanMap = new ConcurrentHashMap<>();
|
private final Map<Long, DatabaseFactoryBean> databaseFactoryBeanMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取BaseMapper
|
* 获取BaseMapper
|
||||||
@@ -113,9 +113,6 @@ public class DatabaseRegistrationBean {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource, false);
|
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource, false);
|
||||||
if (databaseFactoryBean == null) {
|
|
||||||
throw new ConfirmException("获取数据源失败");
|
|
||||||
}
|
|
||||||
databaseFactoryBeanMap.put(sourceId, databaseFactoryBean);
|
databaseFactoryBeanMap.put(sourceId, databaseFactoryBean);
|
||||||
return databaseFactoryBean;
|
return databaseFactoryBean;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.zyplayer.doc.db.framework.db.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库类型枚举
|
||||||
|
*/
|
||||||
|
public enum DatabaseProductEnum {
|
||||||
|
MYSQL("com.mysql.jdbc.Driver"),
|
||||||
|
SQLSERVER("net.sourceforge.jtds.jdbc.Driver"),
|
||||||
|
ORACLE("oracle.jdbc.driver.OracleDriver"),
|
||||||
|
POSTGRESQL("org.postgresql.Driver"),
|
||||||
|
HIVE("org.apache.hive.jdbc.HiveDriver"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private String driverClassName;
|
||||||
|
|
||||||
|
DatabaseProductEnum(String driverClassName) {
|
||||||
|
this.driverClassName = driverClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDriverClassName() {
|
||||||
|
return driverClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDriverClassName(String driverClassName) {
|
||||||
|
this.driverClassName = driverClassName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.zyplayer.doc.db.service;
|
|||||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@@ -18,7 +19,7 @@ public class DbBaseFactory {
|
|||||||
DatabaseRegistrationBean databaseRegistrationBean;
|
DatabaseRegistrationBean databaseRegistrationBean;
|
||||||
@Resource
|
@Resource
|
||||||
private List<DbBaseService> dbBaseServiceList;
|
private List<DbBaseService> dbBaseServiceList;
|
||||||
private Map<DatabaseFactoryBean.DatabaseProduct, DbBaseService> dbBaseServiceMap;
|
private Map<DatabaseProductEnum, DbBaseService> dbBaseServiceMap;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.zyplayer.doc.db.service;
|
package com.zyplayer.doc.db.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
|
||||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||||
@@ -12,11 +11,12 @@ import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
|||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||||
import com.zyplayer.doc.db.framework.db.dto.*;
|
import com.zyplayer.doc.db.framework.db.dto.*;
|
||||||
import com.zyplayer.doc.db.framework.db.mapper.base.*;
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
|
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
||||||
|
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteResult;
|
||||||
|
import com.zyplayer.doc.db.framework.db.mapper.base.SqlExecutor;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -66,7 +66,7 @@ public abstract class DbBaseService {
|
|||||||
*
|
*
|
||||||
* @return 服务类型
|
* @return 服务类型
|
||||||
*/
|
*/
|
||||||
abstract DatabaseFactoryBean.DatabaseProduct getDatabaseProduct();
|
abstract DatabaseProductEnum getDatabaseProduct();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取库列表
|
* 获取库列表
|
||||||
@@ -236,14 +236,14 @@ public abstract class DbBaseService {
|
|||||||
|
|
||||||
Map<String, List<TableInfoDto>> tableMapList = new HashMap<>();
|
Map<String, List<TableInfoDto>> tableMapList = new HashMap<>();
|
||||||
// MYSQL可以一次性查询所有库表
|
// MYSQL可以一次性查询所有库表
|
||||||
if (databaseFactoryBean.getDatabaseProduct() == DatabaseFactoryBean.DatabaseProduct.MYSQL) {
|
if (databaseFactoryBean.getDatabaseProduct() == DatabaseProductEnum.MYSQL) {
|
||||||
List<TableInfoDto> dbTableList = baseMapper.getTableList(null);
|
List<TableInfoDto> dbTableList = baseMapper.getTableList(null);
|
||||||
tableMapList = dbTableList.stream().collect(Collectors.groupingBy(TableInfoDto::getDbName));
|
tableMapList = dbTableList.stream().collect(Collectors.groupingBy(TableInfoDto::getDbName));
|
||||||
}
|
}
|
||||||
for (DatabaseInfoDto infoDto : dbNameDtoList) {
|
for (DatabaseInfoDto infoDto : dbNameDtoList) {
|
||||||
List<TableInfoDto> tableInfoDtoList = tableMapList.get(infoDto.getDbName());
|
List<TableInfoDto> tableInfoDtoList = tableMapList.get(infoDto.getDbName());
|
||||||
// SQLSERVER必须要库才能查
|
// SQLSERVER必须要库才能查
|
||||||
if (databaseFactoryBean.getDatabaseProduct() == DatabaseFactoryBean.DatabaseProduct.SQLSERVER) {
|
if (databaseFactoryBean.getDatabaseProduct() == DatabaseProductEnum.SQLSERVER) {
|
||||||
tableInfoDtoList = baseMapper.getTableList(infoDto.getDbName());
|
tableInfoDtoList = baseMapper.getTableList(infoDto.getDbName());
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isEmpty(tableInfoDtoList)) {
|
if (CollectionUtils.isEmpty(tableInfoDtoList)) {
|
||||||
@@ -327,9 +327,9 @@ public abstract class DbBaseService {
|
|||||||
* 保存存储过程
|
* 保存存储过程
|
||||||
*
|
*
|
||||||
* @param procSql 存储过程SQL
|
* @param procSql 存储过程SQL
|
||||||
|
* @return
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2020年4月24日
|
* @since 2020年4月24日
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public ExecuteResult saveProcedure(Long sourceId, String dbName, String typeName, String procName, String procSql) {
|
public ExecuteResult saveProcedure(Long sourceId, String dbName, String typeName, String procName, String procSql) {
|
||||||
// 需要各数据服务自己实现,各数据库产品的实现都不一样
|
// 需要各数据服务自己实现,各数据库产品的实现都不一样
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.zyplayer.doc.db.service;
|
package com.zyplayer.doc.db.service;
|
||||||
|
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
|
||||||
import com.zyplayer.doc.db.framework.db.dto.TableInfoDto;
|
import com.zyplayer.doc.db.framework.db.dto.TableInfoDto;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -11,8 +11,8 @@ import java.util.List;
|
|||||||
public class HiveServiceImpl extends DbBaseService {
|
public class HiveServiceImpl extends DbBaseService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseFactoryBean.DatabaseProduct getDatabaseProduct() {
|
public DatabaseProductEnum getDatabaseProduct() {
|
||||||
return DatabaseFactoryBean.DatabaseProduct.HIVE;
|
return DatabaseProductEnum.HIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package com.zyplayer.doc.db.service;
|
package com.zyplayer.doc.db.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.sun.org.apache.bcel.internal.generic.RETURN;
|
|
||||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
|
||||||
import com.zyplayer.doc.db.controller.vo.TableDdlVo;
|
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.dto.ColumnInfoDto;
|
||||||
import com.zyplayer.doc.db.framework.db.dto.ProcedureDto;
|
import com.zyplayer.doc.db.framework.db.dto.ProcedureDto;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
||||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteParam;
|
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteParam;
|
||||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteResult;
|
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteResult;
|
||||||
@@ -23,8 +21,8 @@ import java.util.Optional;
|
|||||||
public class MysqlServiceImpl extends DbBaseService {
|
public class MysqlServiceImpl extends DbBaseService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseFactoryBean.DatabaseProduct getDatabaseProduct() {
|
public DatabaseProductEnum getDatabaseProduct() {
|
||||||
return DatabaseFactoryBean.DatabaseProduct.MYSQL;
|
return DatabaseProductEnum.MYSQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -32,7 +30,7 @@ public class MysqlServiceImpl extends DbBaseService {
|
|||||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||||
Map<String, String> tableDdl = baseMapper.getTableDdl(dbName, tableName);
|
Map<String, String> tableDdl = baseMapper.getTableDdl(dbName, tableName);
|
||||||
TableDdlVo tableDdlVo = new TableDdlVo();
|
TableDdlVo tableDdlVo = new TableDdlVo();
|
||||||
tableDdlVo.setCurrent(DatabaseFactoryBean.DatabaseProduct.MYSQL.name().toLowerCase());
|
tableDdlVo.setCurrent(DatabaseProductEnum.MYSQL.name().toLowerCase());
|
||||||
tableDdlVo.setMysql(tableDdl.get("Create Table"));
|
tableDdlVo.setMysql(tableDdl.get("Create Table"));
|
||||||
tableDdlVo.setOracle("// TODO 等待大佬来实现转换");
|
tableDdlVo.setOracle("// TODO 等待大佬来实现转换");
|
||||||
// TODO 将建表语句转换为其他数据库的,还不知道怎么做,先这样留着,看有没大佬来实现
|
// TODO 将建表语句转换为其他数据库的,还不知道怎么做,先这样留着,看有没大佬来实现
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.zyplayer.doc.db.service;
|
package com.zyplayer.doc.db.service;
|
||||||
|
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OracleServiceImpl extends DbBaseService {
|
public class OracleServiceImpl extends DbBaseService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
DatabaseFactoryBean.DatabaseProduct getDatabaseProduct() {
|
DatabaseProductEnum getDatabaseProduct() {
|
||||||
return DatabaseFactoryBean.DatabaseProduct.ORACLE;
|
return DatabaseProductEnum.ORACLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.zyplayer.doc.db.service;
|
package com.zyplayer.doc.db.service;
|
||||||
|
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PostgresqlServiceImpl extends DbBaseService {
|
public class PostgresqlServiceImpl extends DbBaseService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
DatabaseFactoryBean.DatabaseProduct getDatabaseProduct() {
|
DatabaseProductEnum getDatabaseProduct() {
|
||||||
return DatabaseFactoryBean.DatabaseProduct.POSTGRESQL;
|
return DatabaseProductEnum.POSTGRESQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.zyplayer.doc.db.service;
|
package com.zyplayer.doc.db.service;
|
||||||
|
|
||||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo;
|
import com.zyplayer.doc.db.controller.vo.TableColumnVo;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
|
||||||
import com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto;
|
import com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto;
|
||||||
|
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||||
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ import java.util.stream.Collectors;
|
|||||||
public class SqlserverServiceImpl extends DbBaseService {
|
public class SqlserverServiceImpl extends DbBaseService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
DatabaseFactoryBean.DatabaseProduct getDatabaseProduct() {
|
DatabaseProductEnum getDatabaseProduct() {
|
||||||
return DatabaseFactoryBean.DatabaseProduct.SQLSERVER;
|
return DatabaseProductEnum.SQLSERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user