数据库表信息状态展示

This commit is contained in:
暮光:城中城
2019-09-04 22:41:44 +08:00
parent abc24b424f
commit c4ccaa20ca
11 changed files with 374 additions and 119 deletions

View File

@@ -19,6 +19,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.TableStatusVo;
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.DatabaseProduct;
@@ -158,6 +159,13 @@ public class DatabaseDocController {
return DocDbResponseJson.ok(dbNameDtoList);
}
@PostMapping(value = "/getTableStatus")
public ResponseJson getTableStatus(Long sourceId, String dbName, String tableName) {
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
TableStatusVo tableStatusVo = baseMapper.getTableStatus(dbName, tableName);
return DocDbResponseJson.ok(tableStatusVo);
}
@PostMapping(value = "/getTableList")
public ResponseJson getTableList(Long sourceId, String dbName) {
BaseMapper baseMapper = this.getBaseMapper(sourceId);

View File

@@ -0,0 +1,168 @@
package com.zyplayer.doc.db.controller.vo;
import java.util.Date;
public class TableStatusVo {
private String name;
private String engine;
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 String collation;
private String checksum;
private String createOptions;
private String comment;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEngine() {
return engine;
}
public void setEngine(String engine) {
this.engine = engine;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public String getRowFormat() {
return rowFormat;
}
public void setRowFormat(String rowFormat) {
this.rowFormat = rowFormat;
}
public Long getRows() {
return rows;
}
public void setRows(Long rows) {
this.rows = rows;
}
public Long getAvgRowLength() {
return avgRowLength;
}
public void setAvgRowLength(Long avgRowLength) {
this.avgRowLength = avgRowLength;
}
public Long getDataLength() {
return dataLength;
}
public void setDataLength(Long dataLength) {
this.dataLength = dataLength;
}
public Long getMaxDataLength() {
return maxDataLength;
}
public void setMaxDataLength(Long maxDataLength) {
this.maxDataLength = maxDataLength;
}
public Long getIndexLength() {
return indexLength;
}
public void setIndexLength(Long indexLength) {
this.indexLength = indexLength;
}
public Long getDataFree() {
return dataFree;
}
public void setDataFree(Long dataFree) {
this.dataFree = dataFree;
}
public Long getAutoIncrement() {
return autoIncrement;
}
public void setAutoIncrement(Long autoIncrement) {
this.autoIncrement = autoIncrement;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getCheckTime() {
return checkTime;
}
public void setCheckTime(Date checkTime) {
this.checkTime = checkTime;
}
public String getCollation() {
return collation;
}
public void setCollation(String collation) {
this.collation = collation;
}
public String getChecksum() {
return checksum;
}
public void setChecksum(String checksum) {
this.checksum = checksum;
}
public String getCreateOptions() {
return createOptions;
}
public void setCreateOptions(String createOptions) {
this.createOptions = createOptions;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}

View File

@@ -1,5 +1,6 @@
package com.zyplayer.doc.db.framework.db.mapper.base;
import com.zyplayer.doc.db.controller.vo.TableStatusVo;
import com.zyplayer.doc.db.framework.db.dto.*;
import org.apache.ibatis.annotations.Param;
@@ -91,4 +92,13 @@ public interface BaseMapper {
@Param("columnName") String columnName, @Param("newDesc") String newDesc,
@Param("columnInfo") ColumnInfoDto columnInfo);
/**
* 获取表基本信息
*
* @author 暮光:城中城
* @since 2019年9月1日
* @param dbName 数据库名
* @param tableName 表名
*/
TableStatusVo getTableStatus(@Param("dbName") String dbName, @Param("tableName") String tableName);
}

View File

@@ -19,6 +19,27 @@
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="TableStatusDtoMap" type="com.zyplayer.doc.db.controller.vo.TableStatusVo">
<result column="Name" property="name"/>
<result column="Engine" property="engine"/>
<result column="Version" property="version"/>
<result column="Row_format" property="rowFormat"/>
<result column="Rows" property="rows"/>
<result column="Avg_row_length" property="avgRowLength"/>
<result column="Data_length" property="dataLength"/>
<result column="Max_data_length" property="maxDataLength"/>
<result column="Index_length" property="indexLength"/>
<result column="Data_free" property="dataFree"/>
<result column="Auto_increment" property="autoIncrement"/>
<result column="Create_time" property="createTime"/>
<result column="Update_time" property="updateTime"/>
<result column="Check_time" property="checkTime"/>
<result column="Collation" property="collation"/>
<result column="Checksum" property="checksum"/>
<result column="Create_options" property="createOptions"/>
<result column="Comment" property="comment"/>
</resultMap>
<select id="getDatabaseList" resultType="com.zyplayer.doc.db.framework.db.dto.DatabaseInfoDto">
select TABLE_SCHEMA dbName
from information_schema.tables
@@ -39,6 +60,10 @@
ORDER BY ordinal_position
</select>
<select id="getTableStatus" resultMap="TableStatusDtoMap">
show table status from ${dbName} like #{tableName}
</select>
<select id="getTableColumnDescList" resultMap="TableColumnDescDtoMap">
select 1
</select>

View File

@@ -22,6 +22,10 @@
SELECT NAME as dbName FROM Master..SysDatabases ORDER BY NAME
</select>
<select id="getTableStatus" resultType="com.zyplayer.doc.db.controller.vo.TableStatusVo">
select 1
</select>
<select id="getTableList" resultType="com.zyplayer.doc.db.framework.db.dto.TableInfoDto">
SELECT NAME as tableName, ID as tableId
FROM ${dbName}..SysObjects Where XType='U' ORDER BY NAME

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,2 @@
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=n(n.s=u[l]);return f};var t={},o={2:0};n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(a);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var u=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+e+".js?"+{0:"80bc97c8e1f56e403c39",1:"0a0403eb1820498dc9bc"}[e];var a=setTimeout(r,12e4);return i.onerror=i.onload=r,u.appendChild(i),c},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=doc-db-manifest.js.map?42eca50901b3d81e2837
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=n(n.s=u[l]);return f};var t={},o={2:0};n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(a);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var u=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+e+".js?"+{0:"ea7225220eb365539ffe",1:"0a0403eb1820498dc9bc"}[e];var a=setTimeout(r,12e4);return i.onerror=i.onload=r,u.appendChild(i),c},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=doc-db-manifest.js.map?468c61085fdba28ab9e4

View File

@@ -8,7 +8,7 @@
<body>
<div id="app"></div>
<script type="text/javascript" src="doc-db-manifest.js?42eca50901b3d81e2837"></script><script type="text/javascript" src="doc-db-vendor.js?0a0403eb1820498dc9bc"></script><script type="text/javascript" src="doc-db-index.js?80bc97c8e1f56e403c39"></script></body>
<script type="text/javascript" src="doc-db-manifest.js?468c61085fdba28ab9e4"></script><script type="text/javascript" src="doc-db-vendor.js?0a0403eb1820498dc9bc"></script><script type="text/javascript" src="doc-db-index.js?ea7225220eb365539ffe"></script></body>
</html>

View File

@@ -589,7 +589,7 @@ public class MgDocumentController {
*/
private Map<String, String> getGlobalParamMap(List<GlobalParamVo> globalParamList, String paramIn) {
Map<String, String> paramMap = globalParamList.stream().filter(val -> Objects.equals(val.getParamIn(), paramIn))
.collect(Collectors.toMap(GlobalParamVo::getKey, GlobalParamVo::getValue));
.collect(Collectors.toMap(GlobalParamVo::getKey, GlobalParamVo::getValue, (val1, val2) -> val1, HashMap::new));
return paramMap;
}
@@ -598,7 +598,7 @@ public class MgDocumentController {
*/
private Map<String, Object> getGlobalParamObjMap(List<GlobalParamVo> globalParamList, String paramIn) {
Map<String, Object> paramMap = globalParamList.stream().filter(val -> Objects.equals(val.getParamIn(), paramIn))
.collect(Collectors.toMap(GlobalParamVo::getKey, GlobalParamVo::getValue));
.collect(Collectors.toMap(GlobalParamVo::getKey, GlobalParamVo::getValue, (val1, val2) -> val1, HashMap::new));
return paramMap;
}

View File

@@ -9,6 +9,7 @@ var URL = {
databaseList: '/zyplayer-doc-db/doc-db/getDatabaseList',
tableList: '/zyplayer-doc-db/doc-db/getTableList',
tableColumnList: '/zyplayer-doc-db/doc-db/getTableColumnList',
tableStatus: '/zyplayer-doc-db/doc-db/getTableStatus',
tableAndColumnBySearch: '/zyplayer-doc-db/doc-db/getTableAndColumnBySearch',
updateTableDesc: '/zyplayer-doc-db/doc-db/updateTableDesc',
updateTableColumnDesc: '/zyplayer-doc-db/doc-db/updateTableColumnDesc',

View File

@@ -2,17 +2,41 @@
<div class="table-info-vue">
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">表信息</div>
<el-form label-width="100px">
<el-form-item label="数据源:">{{vueQueryParam.host}}</el-form-item>
<el-form-item label="数据库:">{{vueQueryParam.dbName}}</el-form-item>
<el-form-item label="数据表:">{{vueQueryParam.tableName}}</el-form-item>
<el-form-item label="表注释:">
<el-row class="status-info-row">
<el-col :span="24"><span class="label">数据源</span>{{vueQueryParam.host}}</el-col>
</el-row>
<el-row class="status-info-row">
<el-col :span="6"><span class="label">数据库</span>{{vueQueryParam.dbName}}</el-col>
<el-col :span="6"><span class="label">数据表</span>{{vueQueryParam.tableName}}</el-col>
<el-col :span="6"><span class="label">引擎</span>{{tableStatusInfo.engine}}</el-col>
</el-row>
<el-row class="status-info-row">
<el-col :span="6"><span class="label">行数</span>{{tableStatusInfo.rows||0}}</el-col>
<el-col :span="6"><span class="label">自动递增</span>{{tableStatusInfo.avgRowLength||0}}</el-col>
<el-col :span="6"><span class="label">行格式</span>{{tableStatusInfo.rowFormat}}</el-col>
<el-col :span="6"><span class="label">排序规则</span>{{tableStatusInfo.collation}}</el-col>
</el-row>
<el-row class="status-info-row">
<el-col :span="6"><span class="label">索引长度</span>{{getBytesSize(tableStatusInfo.indexLength)}}</el-col>
<el-col :span="6"><span class="label">数据长度</span>{{getBytesSize(tableStatusInfo.dataLength)}}</el-col>
<el-col :span="6"><span class="label">最大长度</span>{{getBytesSize(tableStatusInfo.maxDataLength)}}</el-col>
<el-col :span="6"><span class="label">可用空间</span>{{getBytesSize(tableStatusInfo.dataFree)}}</el-col>
</el-row>
<el-row class="status-info-row">
<el-col :span="6"><span class="label">创建时间</span>{{tableStatusInfo.createTime}}</el-col>
<el-col :span="6"><span class="label">修改时间</span>{{tableStatusInfo.updateTime}}</el-col>
<el-col :span="6"><span class="label">检查时间</span>{{tableStatusInfo.checkTime}}</el-col>
<el-col :span="6"><span class="label">创建选项</span>{{tableStatusInfo.createOptions}}</el-col>
</el-row>
<el-row class="status-info-row">
<el-col :span="24">
<span class="label">表注释</span>
<span v-if="tableInfo.inEdit == 1" @keyup.enter="saveTableDescription">
<el-input v-model="tableInfo.newDesc" placeholder="输入表注释" v-on:blur="saveTableDescription" style="width: 500px;"></el-input>
</span>
<span v-else>{{tableInfo.description || '暂无注释'}} <i class="el-icon-edit edit-table-desc" v-on:click="tableInfo.inEdit = 1"></i></span>
</el-form-item>
</el-form>
</el-col>
</el-row>
</el-card>
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">字段信息</div>
@@ -53,6 +77,7 @@
return {
columnListLoading: false,
vueQueryParam: {},
tableStatusInfo: {},
columnList: [],
tableInfo: [],
};
@@ -86,11 +111,23 @@
app.tableInfo = tableInfo;
app.columnListLoading = false;
});
this.common.post(this.apilist1.tableStatus, this.vueQueryParam, function (json) {
app.tableStatusInfo = json.data || {};
});
},
descBoxClick(row) {
// row.newDesc = row.description;
row.inEdit = 1;
},
getBytesSize(size) {
if (!size) return "0 bytes";
var num = 1024.00;
if (size < num) return size + " bytes";
if (size < Math.pow(num, 2)) return (size / num).toFixed(2) + "KB";
if (size < Math.pow(num, 3)) return (size / Math.pow(num, 2)).toFixed(2) + "MB";
if (size < Math.pow(num, 4)) return (size / Math.pow(num, 3)).toFixed(2) + "GB";
return (size / Math.pow(num, 4)).toFixed(2) + "TB";
},
saveColumnDescription(row) {
if (row.inEdit == 0 || row.description == row.newDesc) {
row.inEdit = 0;
@@ -124,5 +161,7 @@
.table-info-vue .edit-table-desc{cursor: pointer; color: #409EFF;}
.table-info-vue .description{cursor: pointer;}
.table-info-vue .el-table td, .table-info-vue .el-table th{padding: 5px 0;}
.table-info-vue .status-info-row{padding: 8px 0;}
.table-info-vue .status-info-row .label{width: 80px;display: inline-block;text-align: right;color: #606266;}
</style>