增加DDL建表语句展示,优化数据预览,优化卡顿问题

This commit is contained in:
暮光:城中城
2020-05-08 22:32:54 +08:00
parent 0cf04e8466
commit 713582bebf
13 changed files with 125 additions and 81 deletions

View File

@@ -158,6 +158,18 @@ public class DatabaseDocController {
return DocDbResponseJson.ok(dbResultMap);
}
@PostMapping(value = "/getTableDdl")
public ResponseJson getTableDdl(Long sourceId, String dbName, String tableName) {
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
Map<String, String> dataMap = baseMapper.getTableDdl(dbName, tableName);
DatabaseFactoryBean databaseFactoryBean = databaseRegistrationBean.getFactoryById(sourceId);
// 不同数据源类型获取方式不一致
if (Objects.equals(DatabaseProduct.MYSQL, databaseFactoryBean.getDatabaseProduct())) {
return DocDbResponseJson.ok(dataMap.get("Create Table"));
}
return DocDbResponseJson.ok("暂未支持的数据库类型");
}
@PostMapping(value = "/getDatabaseList")
public ResponseJson getDatabaseList(Long sourceId) {
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);

View File

@@ -5,100 +5,118 @@ import com.zyplayer.doc.db.framework.db.dto.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 数据库的mapper持有对象接口
*
* @author 暮光:城中城
* @since 2018年8月8日
*/
public interface BaseMapper {
/**
* 获取库列表
*
* @return 数据库列表
* @author 暮光:城中城
* @since 2018年8月8日
*/
Map<String, String> getTableDdl(@Param("dbName") String dbName, @Param("tableName") String tableName);
/**
* 获取库列表
*
* @return 数据库列表
* @author 暮光:城中城
* @since 2018年8月8日
*/
List<DatabaseInfoDto> getDatabaseList();
/**
* 获取表列表
* @author 暮光:城中城
* @since 2018年8月8日
*
* @param dbName 数据库名
* @return 数据库表列表
* @author 暮光:城中城
* @since 2018年8月8日
*/
List<TableInfoDto> getTableList(@Param("dbName")String dbName);
List<TableInfoDto> getTableList(@Param("dbName") String dbName);
/**
* 获取字段列表
* @author 暮光:城中城
* @since 2018年8月8日
* @param dbName 数据库名
*
* @param dbName 数据库名
* @param tableName 表名
* @return 字段列表
*/
List<TableColumnDescDto> getTableColumnList(@Param("dbName") String dbName, @Param("tableName") String tableName);
/**
* 获取字段注释
* @author 暮光:城中城
* @since 2018年8月8日
*/
List<TableColumnDescDto> getTableColumnList(@Param("dbName") String dbName, @Param("tableName") String tableName);
/**
* 获取字段注释
*
* @param tableName 表名
* @return 表字段注释
* @author 暮光:城中城
* @since 2018年8月8日
*/
List<TableColumnDescDto> getTableColumnDescList(@Param("tableName") String tableName);
/**
* 模糊搜索表和字段
* @author 暮光:城中城
* @since 2018年8月8日
* @param dbName 数据库名
*
* @param dbName 数据库名
* @param searchText 搜索内容
* @return 表和字段信息
* @author 暮光:城中城
* @since 2018年8月8日
*/
List<QueryTableColumnDescDto> getTableAndColumnBySearch(@Param("dbName") String dbName, @Param("searchText") String searchText);
/**
* 获取表注释
* @author 暮光:城中城
* @since 2018年8月8日
*
* @param tableName 可不传,传了只查询指定表的注释
* @return 表注释
*/
List<TableDescDto> getTableDescList(@Param("dbName") String dbName, @Param("tableName") String tableName);
/**
* 增加表注释
* @author 暮光:城中城
* @since 2018年8月8日
*/
List<TableDescDto> getTableDescList(@Param("dbName") String dbName, @Param("tableName") String tableName);
/**
* 增加表注释
*
* @param tableName 表名
* @param newDesc 新的注释
* @param newDesc 新的注释
* @author 暮光:城中城
* @since 2018年8月8日
*/
void updateTableDesc(@Param("dbName") String dbName, @Param("tableName") String tableName, @Param("newDesc") String newDesc);
/**
* 增加字段注释
*
* @param dbName 数据库名
* @param tableName 表名
* @param columnName 字段名
* @param newDesc 新的注释
* @param columnInfo 字段信息
* @author 暮光:城中城
* @since 2018年8月8日
* @param dbName 数据库名
* @param tableName 表名
* @param columnName 字段名
* @param newDesc 新的注释
* @param columnInfo 字段信息
*/
void updateTableColumnDesc(@Param("dbName") String dbName, @Param("tableName") String tableName,
@Param("columnName") String columnName, @Param("newDesc") String newDesc,
@Param("columnInfo") ColumnInfoDto columnInfo);
@Param("columnName") String columnName, @Param("newDesc") String newDesc,
@Param("columnInfo") ColumnInfoDto columnInfo);
/**
* 获取表基本信息
*
* @param dbName 数据库名
* @param tableName 表名
* @author 暮光:城中城
* @since 2019年9月1日
* @param dbName 数据库名
* @param tableName 表名
*/
TableStatusVo getTableStatus(@Param("dbName") String dbName, @Param("tableName") String tableName);
}

View File

@@ -48,6 +48,10 @@
group by TABLE_SCHEMA
</select>
<select id="getTableDdl" resultType="java.util.Map">
show create table ${dbName}.${tableName}
</select>
<select id="getTableList" resultType="com.zyplayer.doc.db.framework.db.dto.TableInfoDto">
select table_schema dbName,table_name tableName, table_comment as tableComment
from information_schema.tables