注释完善
This commit is contained in:
@@ -82,6 +82,7 @@ public class DatabaseDocController {
|
||||
|
||||
/**
|
||||
* 获取数据源基本信息
|
||||
*
|
||||
* @param sourceId 数据源ID
|
||||
* @return 基本信息
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.util.TypeUtils;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.core.util.StringUtil;
|
||||
import com.zyplayer.doc.db.controller.download.FormatDownloadConst;
|
||||
import com.zyplayer.doc.db.controller.download.FormatDownloadService;
|
||||
import com.zyplayer.doc.db.controller.param.DataViewParam;
|
||||
@@ -23,6 +22,7 @@ import com.zyplayer.doc.db.service.database.DbBaseService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -170,7 +170,7 @@ public class DbDataViewController {
|
||||
return sqlExecutor.execute(executeParam);
|
||||
} catch (Exception e) {
|
||||
logger.error("执行出错", e);
|
||||
return ExecuteResult.error(StringUtil.getException(e), executeSql);
|
||||
return ExecuteResult.error(ExceptionUtils.getFullStackTrace(e), executeSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserInfo;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
|
||||
import com.zyplayer.doc.db.framework.configuration.DatasourceUtil;
|
||||
@@ -37,12 +36,12 @@ import java.util.stream.Collectors;
|
||||
@AuthMan(DocAuthConst.DB_DATASOURCE_MANAGE)
|
||||
@RequestMapping("/zyplayer-doc-db/datasource")
|
||||
public class DbDatasourceController {
|
||||
|
||||
|
||||
@Resource
|
||||
DatabaseRegistrationBean databaseRegistrationBean;
|
||||
@Resource
|
||||
DbDatasourceService dbDatasourceService;
|
||||
|
||||
|
||||
@PostMapping(value = "/list")
|
||||
public ResponseJson list(Integer pageNum, Integer pageSize, String name, String groupName) {
|
||||
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
|
||||
@@ -56,7 +55,7 @@ public class DbDatasourceController {
|
||||
}
|
||||
return DocDbResponseJson.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/groups")
|
||||
public ResponseJson groups() {
|
||||
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
|
||||
@@ -93,7 +92,7 @@ public class DbDatasourceController {
|
||||
}
|
||||
return DocDbResponseJson.ok();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
public ResponseJson update(DbDatasource dbDatasource) {
|
||||
if (StringUtils.isBlank(dbDatasource.getName())) {
|
||||
|
||||
@@ -195,6 +195,7 @@ public class DbProcedureController {
|
||||
|
||||
/**
|
||||
* 创建日志对象
|
||||
*
|
||||
* @param sourceId
|
||||
* @param dbName
|
||||
* @param typeName
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DbTableRelationController {
|
||||
relationVoChildren.setTableName(param.getTableName());
|
||||
relationVoChildren.setName(columnDto.getName());
|
||||
relationVoChildren.setColumnName(columnDto.getName());
|
||||
relationVoChildren.setChildren(this.getRelation(param.getSourceId(), param.getDbName(), param.getTableName(), columnDto.getName(), drillPath,1));
|
||||
relationVoChildren.setChildren(this.getRelation(param.getSourceId(), param.getDbName(), param.getTableName(), columnDto.getName(), drillPath, 1));
|
||||
childrenRelationList.add(relationVoChildren);
|
||||
}
|
||||
relationVo.setChildren(childrenRelationList);
|
||||
|
||||
@@ -15,10 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zyplayer.doc.db.controller.download;
|
||||
|
||||
/**
|
||||
* 下载类型枚举
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-08-14
|
||||
*/
|
||||
public class FormatDownloadConst {
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zyplayer.doc.db.controller.download;
|
||||
|
||||
/**
|
||||
* 下载类型枚举
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-08-14
|
||||
*/
|
||||
public enum FormatDownloadEnum {
|
||||
INSERT(FormatDownloadConst.INSERT),
|
||||
|
||||
@@ -4,6 +4,12 @@ import com.zyplayer.doc.db.controller.param.DataViewParam;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 下载服务
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-08-14
|
||||
*/
|
||||
public interface FormatDownloadService {
|
||||
|
||||
public void download(HttpServletResponse response, DataViewParam param, String[] tableNameArr) throws Exception;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.controller.param;
|
||||
|
||||
/**
|
||||
* 数据预览查询参数
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-20
|
||||
*/
|
||||
public class DataViewParam {
|
||||
// 基本信息
|
||||
private String executeId;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.controller.param;
|
||||
|
||||
/**
|
||||
* 存储过程列表查询参数
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
public class ProcedureListParam {
|
||||
private Long sourceId;
|
||||
private String dbName;
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
package com.zyplayer.doc.db.controller.vo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zyplayer.doc.db.controller.vo.TableColumnVo.TableInfoVo;
|
||||
import com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据库表导出
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class DatabaseExportVo {
|
||||
|
||||
|
||||
private Map<String, List<TableColumnDescDto>> columnList;
|
||||
|
||||
|
||||
private List<TableInfoVo> tableList;
|
||||
|
||||
public DatabaseExportVo(Map<String, List<TableColumnDescDto>> columnList, List<TableInfoVo> tableList) {
|
||||
@@ -20,17 +26,17 @@ public class DatabaseExportVo {
|
||||
public Map<String, List<TableColumnDescDto>> getColumnList() {
|
||||
return columnList;
|
||||
}
|
||||
|
||||
|
||||
public void setColumnList(Map<String, List<TableColumnDescDto>> columnList) {
|
||||
this.columnList = columnList;
|
||||
}
|
||||
|
||||
|
||||
public List<TableInfoVo> getTableList() {
|
||||
return tableList;
|
||||
}
|
||||
|
||||
|
||||
public void setTableList(List<TableInfoVo> tableList) {
|
||||
this.tableList = tableList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.zyplayer.doc.db.controller.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表字段信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class TableColumnVo {
|
||||
|
||||
|
||||
private List<TableColumnDescDto> columnList;
|
||||
|
||||
|
||||
private TableInfoVo tableInfo;
|
||||
|
||||
|
||||
public static class TableInfoVo {
|
||||
|
||||
@ColumnWidth(20)
|
||||
@@ -21,38 +27,38 @@ public class TableColumnVo {
|
||||
@ColumnWidth(80)
|
||||
@ExcelProperty("表注释")
|
||||
private String description;
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<TableColumnDescDto> getColumnList() {
|
||||
return columnList;
|
||||
}
|
||||
|
||||
|
||||
public void setColumnList(List<TableColumnDescDto> columnList) {
|
||||
this.columnList = columnList;
|
||||
}
|
||||
|
||||
|
||||
public TableInfoVo getTableInfo() {
|
||||
return tableInfo;
|
||||
}
|
||||
|
||||
|
||||
public void setTableInfo(TableInfoVo tableInfo) {
|
||||
this.tableInfo = tableInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@ import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 表ddl信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-04-23
|
||||
*/
|
||||
public class TableDdlVo {
|
||||
private String current;
|
||||
private String mysql;
|
||||
|
||||
@@ -2,21 +2,27 @@ package com.zyplayer.doc.db.controller.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 表基本信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-09-04
|
||||
*/
|
||||
public class TableStatusVo {
|
||||
private String name;
|
||||
private String engine;
|
||||
private Long version;
|
||||
private Long version;
|
||||
private String rowFormat;
|
||||
private Long rows;
|
||||
private Long avgRowLength;
|
||||
private Long dataLength;
|
||||
private Long maxDataLength;
|
||||
private Long indexLength;
|
||||
private Long dataFree;
|
||||
private Long autoIncrement;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private Date checkTime;
|
||||
private Long rows;
|
||||
private Long avgRowLength;
|
||||
private Long dataLength;
|
||||
private Long maxDataLength;
|
||||
private Long indexLength;
|
||||
private Long dataFree;
|
||||
private Long autoIncrement;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private Date checkTime;
|
||||
private String collation;
|
||||
private String checksum;
|
||||
private String createOptions;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.controller.vo;
|
||||
|
||||
/**
|
||||
* 用户数据库授权信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-08-22
|
||||
*/
|
||||
public class UserDbAuthVo {
|
||||
private String userName;
|
||||
private Long userId;
|
||||
|
||||
@@ -4,6 +4,12 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 应用启动监听
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationListenerBean implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ import org.springframework.core.io.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据库连接工具类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-07-04
|
||||
*/
|
||||
public class DatasourceUtil {
|
||||
private static final SqlLogInterceptor sqlLogInterceptor = new SqlLogInterceptor();
|
||||
// url解析
|
||||
|
||||
@@ -5,12 +5,18 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 开启db模块的注解
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {
|
||||
"com.zyplayer.doc.db",
|
||||
"com.zyplayer.doc.db",
|
||||
})
|
||||
public @interface EnableDocDb {
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.zyplayer.doc.db.framework.configuration.analysis;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* 数据库链接url解析api
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-13
|
||||
*/
|
||||
public interface AnalysisApi {
|
||||
|
||||
Resource[] process(String dbUrl, DatabaseFactoryBean databaseFactoryBean) throws Exception;
|
||||
|
||||
@@ -5,6 +5,12 @@ import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* hive链接url解析
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-13
|
||||
*/
|
||||
public class HiveAnalysis implements AnalysisApi {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,12 @@ import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* mysql链接url解析
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-13
|
||||
*/
|
||||
public class MysqlAnalysis implements AnalysisApi {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,12 @@ import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* Oracle链接url解析
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-13
|
||||
*/
|
||||
public class OracleAnalysis implements AnalysisApi {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,12 @@ import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* Postgresql链接url解析
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-13
|
||||
*/
|
||||
public class PostgresqlAnalysis implements AnalysisApi {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,12 @@ import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* Sqlserver链接url解析
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-13
|
||||
*/
|
||||
public class SqlserverAnalysis implements AnalysisApi {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.framework.consts;
|
||||
|
||||
/**
|
||||
* 数据库授权前缀
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-08-22
|
||||
*/
|
||||
public enum DbAuthType {
|
||||
NO_AUTH(0, "DB_NO_AUTH_"),
|
||||
VIEW(1, "DB_VIEW_"),
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.framework.db.dto;
|
||||
|
||||
/**
|
||||
* 字段信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class ColumnInfoDto {
|
||||
private String isNullable;
|
||||
private String columnType;
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package com.zyplayer.doc.db.framework.db.dto;
|
||||
|
||||
/**
|
||||
* 数据库信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class DatabaseInfoDto {
|
||||
private String dbName;
|
||||
|
||||
|
||||
public String getDbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
|
||||
public void setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.zyplayer.doc.db.framework.db.dto;
|
||||
|
||||
/**
|
||||
* 存储过程信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
public class ProcedureDto {
|
||||
private String db;
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
package com.zyplayer.doc.db.framework.db.dto;
|
||||
|
||||
/**
|
||||
* 表字段注释信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class QueryTableColumnDescDto {
|
||||
private String tableName;
|
||||
private String columnName;
|
||||
private String description;
|
||||
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.zyplayer.doc.db.framework.db.dto;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
|
||||
/**
|
||||
* 表字段注释信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class TableColumnDescDto {
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty("表名")
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.framework.db.dto;
|
||||
|
||||
/**
|
||||
* 表注释信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class TableDescDto {
|
||||
private String tableName;
|
||||
private String description;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.framework.db.dto;
|
||||
|
||||
/**
|
||||
* 表信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-11-27
|
||||
*/
|
||||
public class TableInfoDto {
|
||||
private String dbName;
|
||||
private String tableName;
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.zyplayer.doc.db.framework.db.enums;
|
||||
|
||||
/**
|
||||
* 数据库类型枚举
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-13
|
||||
*/
|
||||
public enum DatabaseProductEnum {
|
||||
MYSQL("com.mysql.jdbc.Driver"),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zyplayer.doc.db.framework.db.interceptor;
|
||||
|
||||
import org.apache.ibatis.cache.CacheKey;
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
@@ -19,9 +20,16 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 日志拦截
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-26
|
||||
*/
|
||||
@Intercepts({
|
||||
@Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }),
|
||||
@Signature(type = Executor.class, method = "query", args = { MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class })
|
||||
@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}),
|
||||
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
|
||||
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
|
||||
})
|
||||
public class SqlLogInterceptor implements Interceptor {
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.zyplayer.doc.db.framework.db.interceptor;
|
||||
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.ParameterMapping;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class SqlLogUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SqlLogUtil.class);
|
||||
|
||||
private static String getParameterValue(Object obj) {
|
||||
String value;
|
||||
if (obj instanceof String) {
|
||||
value = "'" + obj.toString() + "'";
|
||||
} else if (obj instanceof Date) {
|
||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.CHINA);
|
||||
value = "'" + formatter.format(obj) + "'";
|
||||
} else {
|
||||
value = (obj == null) ? "'null'" : obj.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String getSqlString(Map<String, Object> paramMap, BoundSql boundSql) {
|
||||
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
|
||||
StringBuilder sqlSb = new StringBuilder(boundSql.getSql().replaceAll("[\\s]+", " "));
|
||||
int fromIndex = 0;
|
||||
if (parameterMappings.size() > 0) {
|
||||
for (ParameterMapping parameterMapping : parameterMappings) {
|
||||
String propertyName = parameterMapping.getProperty();
|
||||
Object obj = paramMap.get(propertyName);
|
||||
fromIndex = replacePlaceholder(sqlSb, fromIndex, getParameterValue(obj));
|
||||
}
|
||||
}
|
||||
return sqlSb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换?占位符
|
||||
*
|
||||
* @param sql
|
||||
* @param fromIndex
|
||||
* @param replaceStr
|
||||
* @return
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年10月27日
|
||||
*/
|
||||
private static int replacePlaceholder(StringBuilder sql, int fromIndex, String replaceStr) {
|
||||
int index = sql.indexOf("?", fromIndex);
|
||||
if (index >= 0) {
|
||||
sql.replace(index, index + 1, replaceStr);
|
||||
}
|
||||
return index + replaceStr.length();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.framework.db.mapper.base;
|
||||
|
||||
/**
|
||||
* 执行类型
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-08-22
|
||||
*/
|
||||
public enum ExecuteType {
|
||||
ALL, SELECT,
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.zyplayer.doc.db.framework.db.mapper.base;
|
||||
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.zyplayer.doc.core.util.StringUtil;
|
||||
import com.zyplayer.doc.data.service.manage.DbHistoryService;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
|
||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||
|
||||
@@ -2,13 +2,19 @@ package com.zyplayer.doc.db.framework.db.parser;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
|
||||
/**
|
||||
* 参数填充接口
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-27
|
||||
*/
|
||||
public interface FillParamParser {
|
||||
|
||||
/**
|
||||
* 执行时间处理
|
||||
*
|
||||
* @param dateTime 时间
|
||||
* @param paramOne 第一个参数
|
||||
* @param dateTime 时间
|
||||
* @param paramOne 第一个参数
|
||||
* @param paramThree 第三个参数
|
||||
* @return 时间格式化
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Copyright 2009-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2009-2017 the original author or authors.
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.zyplayer.doc.db.framework.db.parser;
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.apache.ibatis.parsing.TokenHandler;
|
||||
|
||||
/**
|
||||
* 参数预处理类
|
||||
*
|
||||
* @author Clinton Begin
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-10-10
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.db.framework.db.transfer;
|
||||
|
||||
/**
|
||||
* 数据互导状态类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-10-06
|
||||
*/
|
||||
public enum TransferTaskStatus {
|
||||
// 最后执行状态 0=未执行 1=执行中 2=执行成功 3=执行失败 4=取消执行
|
||||
NOT_START(0), EXECUTING(1), SUCCESS(2), ERROR(3), CANCEL(4);
|
||||
|
||||
@@ -6,6 +6,12 @@ import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* json工具类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-20
|
||||
*/
|
||||
public class JSONUtil {
|
||||
|
||||
public static SerializeConfig serializeConfig = new SerializeConfig();
|
||||
|
||||
@@ -7,6 +7,12 @@ import com.zyplayer.doc.db.framework.consts.DbAuthType;
|
||||
import com.zyplayer.doc.db.framework.db.mapper.base.ExecuteType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 执行权限判断类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-08-14
|
||||
*/
|
||||
@Service
|
||||
public class ExecuteAuthService {
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据库服务工厂类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-01
|
||||
*/
|
||||
@Service
|
||||
public class DatabaseServiceFactory {
|
||||
|
||||
@@ -45,6 +51,7 @@ public class DatabaseServiceFactory {
|
||||
|
||||
/**
|
||||
* 获取下载服务
|
||||
*
|
||||
* @param databaseProductEnum 数据库类型
|
||||
* @return 下载服务
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* hive数据查询服务实现类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-05-11
|
||||
*/
|
||||
@Service
|
||||
public class HiveServiceImpl extends DbBaseService {
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* MySQL数据查询服务实现类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-01
|
||||
*/
|
||||
@Service
|
||||
public class MysqlServiceImpl extends DbBaseService {
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.zyplayer.doc.db.service.database;
|
||||
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Oracle数据查询服务实现类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-01
|
||||
*/
|
||||
@Service
|
||||
public class OracleServiceImpl extends DbBaseService {
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.zyplayer.doc.db.service.database;
|
||||
import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Postgresql数据查询服务实现类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-01
|
||||
*/
|
||||
@Service
|
||||
public class PostgresqlServiceImpl extends DbBaseService {
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Sqlserver数据查询服务实现类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-01
|
||||
*/
|
||||
@Service
|
||||
public class SqlserverServiceImpl extends DbBaseService {
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 基础的数据导出服务类,按照MySQL规范写的,不满足的可新增类来实现
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-05
|
||||
*/
|
||||
@Service
|
||||
public class BaseDownloadService implements DownloadService {
|
||||
|
||||
@@ -9,6 +9,12 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 下载服务
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-17
|
||||
*/
|
||||
@Service
|
||||
public interface DownloadService {
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* SQLServer的数据导出服务类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-06-17
|
||||
*/
|
||||
@Service
|
||||
public class SqlserverDownloadService implements DownloadService {
|
||||
|
||||
Reference in New Issue
Block a user