SQL执行的动态参数保存,数据预览列表头移上去展示列说明
This commit is contained in:
@@ -59,6 +59,11 @@ public class DbFavorite implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer yn;
|
private Integer yn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行参数JSON
|
||||||
|
*/
|
||||||
|
private String paramJson;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -129,4 +134,12 @@ public class DbFavorite implements Serializable {
|
|||||||
public void setDatasourceId(Long datasourceId) {
|
public void setDatasourceId(Long datasourceId) {
|
||||||
this.datasourceId = datasourceId;
|
this.datasourceId = datasourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParamJson() {
|
||||||
|
return paramJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParamJson(String paramJson) {
|
||||||
|
this.paramJson = paramJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ public class DbHistory implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer yn;
|
private Integer yn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行参数JSON
|
||||||
|
*/
|
||||||
|
private String paramJson;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -115,4 +120,12 @@ public class DbHistory implements Serializable {
|
|||||||
public void setDatasourceId(Long datasourceId) {
|
public void setDatasourceId(Long datasourceId) {
|
||||||
this.datasourceId = datasourceId;
|
this.datasourceId = datasourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParamJson() {
|
||||||
|
return paramJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParamJson(String paramJson) {
|
||||||
|
this.paramJson = paramJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface DbHistoryService extends IService<DbHistory> {
|
public interface DbHistoryService extends IService<DbHistory> {
|
||||||
|
|
||||||
void saveHistory(String content, Long datasourceId);
|
void saveHistory(String content, String paramJson, Long datasourceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,12 @@ public class DbHistoryServiceImpl extends ServiceImpl<DbHistoryMapper, DbHistory
|
|||||||
DbHistoryMapper dbHistoryMapper;
|
DbHistoryMapper dbHistoryMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveHistory(String content, Long datasourceId) {
|
public void saveHistory(String content, String paramJson, Long datasourceId) {
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
DbHistory dbHistory = new DbHistory();
|
DbHistory dbHistory = new DbHistory();
|
||||||
dbHistory.setDatasourceId(datasourceId);
|
dbHistory.setDatasourceId(datasourceId);
|
||||||
dbHistory.setContent(content);
|
dbHistory.setContent(content);
|
||||||
|
dbHistory.setParamJson(paramJson);
|
||||||
dbHistory.setCreateTime(new Date());
|
dbHistory.setCreateTime(new Date());
|
||||||
dbHistory.setCreateUserId(currentUser.getUserId());
|
dbHistory.setCreateUserId(currentUser.getUserId());
|
||||||
dbHistory.setCreateUserName(currentUser.getUsername());
|
dbHistory.setCreateUserName(currentUser.getUsername());
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class DbSqlExecutorController {
|
|||||||
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
DbBaseService dbBaseService = databaseServiceFactory.getDbBaseService(sourceId);
|
||||||
String useDbSql = dbBaseService.getUseDbSql(dbName);
|
String useDbSql = dbBaseService.getUseDbSql(dbName);
|
||||||
// 保留历史记录
|
// 保留历史记录
|
||||||
dbHistoryService.saveHistory(sql.trim(), sourceId);
|
dbHistoryService.saveHistory(sql.trim(), params, sourceId);
|
||||||
// 参数处理
|
// 参数处理
|
||||||
Map<String, Object> paramMap = JSON.parseObject(params);
|
Map<String, Object> paramMap = JSON.parseObject(params);
|
||||||
List<String> resultList = new LinkedList<>();
|
List<String> resultList = new LinkedList<>();
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon-db.png><title>数据库文档管理</title><link href=css/app.5c9df0aa.css rel=preload as=style><link href=css/chunk-vendors.8924efc6.css rel=preload as=style><link href=js/app.612a825e.js rel=preload as=script><link href=js/chunk-vendors.22b87709.js rel=preload as=script><link href=css/chunk-vendors.8924efc6.css rel=stylesheet><link href=css/app.5c9df0aa.css rel=stylesheet></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.22b87709.js></script><script src=js/app.612a825e.js></script></body></html>
|
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon-db.png><title>数据库文档管理</title><link href=css/chunk-vendors.8924efc6.css rel=preload as=style><link href=css/index.5c9df0aa.css rel=preload as=style><link href=js/chunk-vendors.22b87709.js rel=preload as=script><link href=js/index.fe7dd667.js rel=preload as=script><link href=css/chunk-vendors.8924efc6.css rel=stylesheet><link href=css/index.5c9df0aa.css rel=stylesheet></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.22b87709.js></script><script src=js/index.fe7dd667.js></script></body></html>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
zyplayer-doc-db/src/main/resources/dist/js/index.fe7dd667.js
vendored
Normal file
1
zyplayer-doc-db/src/main/resources/dist/js/index.fe7dd667.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -93,6 +93,7 @@ CREATE TABLE `db_favorite` (
|
|||||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
`yn` tinyint(4) NULL DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
`yn` tinyint(4) NULL DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||||
`datasource_id` bigint(20) NULL DEFAULT NULL COMMENT '数据源ID',
|
`datasource_id` bigint(20) NULL DEFAULT NULL COMMENT '数据源ID',
|
||||||
|
`param_json` varchar(1024) DEFAULT NULL COMMENT '执行参数JSON',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
@@ -112,6 +113,7 @@ CREATE TABLE `db_history` (
|
|||||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
`yn` tinyint(4) NULL DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
`yn` tinyint(4) NULL DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||||
`datasource_id` bigint(20) NULL DEFAULT NULL COMMENT '数据源ID',
|
`datasource_id` bigint(20) NULL DEFAULT NULL COMMENT '数据源ID',
|
||||||
|
`param_json` varchar(1024) DEFAULT NULL COMMENT '执行参数JSON',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 135 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB AUTO_INCREMENT = 135 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
|||||||
@@ -21,5 +21,6 @@ CREATE TABLE `db_table_relation` (
|
|||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='表关系';
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='表关系';
|
||||||
|
|
||||||
|
-- 增加执行参数JSON
|
||||||
|
alter table db_history add `param_json` varchar(1024) DEFAULT NULL COMMENT '执行参数JSON';
|
||||||
|
alter table db_favorite add `param_json` varchar(1024) DEFAULT NULL COMMENT '执行参数JSON';
|
||||||
|
|||||||
@@ -45,6 +45,11 @@
|
|||||||
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column type="selection" width="55"></el-table-column>
|
||||||
<el-table-column type="index" width="50"></el-table-column>
|
<el-table-column type="index" width="50"></el-table-column>
|
||||||
<el-table-column sortable v-for="item in resultItem.dataCols" :prop="item.prop" :label="item.prop" :width="item.width">
|
<el-table-column sortable v-for="item in resultItem.dataCols" :prop="item.prop" :label="item.prop" :width="item.width">
|
||||||
|
<template slot="header" slot-scope="scope">
|
||||||
|
<el-tooltip effect="dark" :content="item.desc" placement="top">
|
||||||
|
<span>{{item.prop}}</span>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<textarea readonly :value="scope.row[item.prop]" class="el-textarea__inner" rows="1"></textarea>
|
<textarea readonly :value="scope.row[item.prop]" class="el-textarea__inner" rows="1"></textarea>
|
||||||
</template>
|
</template>
|
||||||
@@ -170,7 +175,8 @@
|
|||||||
minLines: 3,
|
minLines: 3,
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
},
|
},
|
||||||
executorSource: {}
|
executorSource: {},
|
||||||
|
columnMap: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@@ -188,12 +194,15 @@
|
|||||||
// }, 500);
|
// }, 500);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init(param) {
|
init(param, columnList) {
|
||||||
if (this.pageParam.sourceId == param.sourceId) {
|
if (this.pageParam.sourceId == param.sourceId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.pageParam = param;
|
this.pageParam = param;
|
||||||
this.executorSource = {sourceId: param.sourceId, dbName: param.dbName, tableName: param.tableName};
|
this.executorSource = {sourceId: param.sourceId, dbName: param.dbName, tableName: param.tableName};
|
||||||
|
let columnMap = {};
|
||||||
|
columnList.forEach(item => columnMap[item.name] = item);
|
||||||
|
this.columnMap = columnMap;
|
||||||
this.doExecutorSqlCommon();
|
this.doExecutorSqlCommon();
|
||||||
// this.vueQueryParam = to.query;
|
// this.vueQueryParam = to.query;
|
||||||
// let newName = {key: this.$route.fullPath, val: '数据-'+this.vueQueryParam.tableName};
|
// let newName = {key: this.$route.fullPath, val: '数据-'+this.vueQueryParam.tableName};
|
||||||
@@ -328,7 +337,8 @@
|
|||||||
var width = (width1 > width2) ? width1 : width2;
|
var width = (width1 > width2) ? width1 : width2;
|
||||||
width = (width < 50) ? 50 : width;
|
width = (width < 50) ? 50 : width;
|
||||||
width = (width > 200) ? 200 : width;
|
width = (width > 200) ? 200 : width;
|
||||||
executeResultCols.push({prop: key, width: width + 50});
|
let column = this.columnMap[key] || {};
|
||||||
|
executeResultCols.push({prop: key, width: width + 50, desc: (column.description || key)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var resultObj = {};
|
var resultObj = {};
|
||||||
|
|||||||
@@ -46,12 +46,12 @@
|
|||||||
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
|
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
|
||||||
<el-table-column prop="content" label="SQL">
|
<el-table-column prop="content" label="SQL">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row.content)" :title="scope.row.content">{{scope.row.content}}</pre>
|
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row)" :title="scope.row.content">{{scope.row.content}}</pre>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="160px">
|
<el-table-column label="操作" width="160px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" type="primary" @click="inputFavoriteSql(scope.row.content)">输入</el-button>
|
<el-button size="mini" type="primary" @click="inputFavoriteSql(scope.row)">输入</el-button>
|
||||||
<el-button size="mini" type="success" @click="addFavorite(scope.row.content)" style="margin-left: 10px;">收藏</el-button>
|
<el-button size="mini" type="success" @click="addFavorite(scope.row.content)" style="margin-left: 10px;">收藏</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -62,12 +62,12 @@
|
|||||||
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
|
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
|
||||||
<el-table-column prop="content" label="SQL">
|
<el-table-column prop="content" label="SQL">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row.content)" :title="scope.row.content">{{scope.row.content}}</pre>
|
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row)" :title="scope.row.content">{{scope.row.content}}</pre>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="160px">
|
<el-table-column label="操作" width="160px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" type="primary" v-on:click="inputFavoriteSql(scope.row.content)">输入</el-button>
|
<el-button size="mini" type="primary" v-on:click="inputFavoriteSql(scope.row)">输入</el-button>
|
||||||
<el-button size="mini" type="danger" v-on:click="delFavorite(scope.row)" style="margin-left: 10px;">删除</el-button>
|
<el-button size="mini" type="danger" v-on:click="delFavorite(scope.row)" style="margin-left: 10px;">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -234,7 +234,18 @@
|
|||||||
sqlValue = this.sqlExecutorEditor.getValue();
|
sqlValue = this.sqlExecutorEditor.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let param = {name: '我的收藏', content: sqlValue, datasourceId: this.choiceDatasourceId};
|
let sqlParamObj = {};
|
||||||
|
this.sqlParams.forEach(item => {
|
||||||
|
if (!!item.value) {
|
||||||
|
sqlParamObj[item.key] = item.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let param = {
|
||||||
|
name: '我的收藏',
|
||||||
|
content: sqlValue,
|
||||||
|
paramJson: JSON.stringify(sqlParamObj),
|
||||||
|
datasourceId: this.choiceDatasourceId
|
||||||
|
};
|
||||||
datasourceApi.updateFavorite(param).then(() => {
|
datasourceApi.updateFavorite(param).then(() => {
|
||||||
this.$message.success("收藏成功");
|
this.$message.success("收藏成功");
|
||||||
this.loadFavoriteList();
|
this.loadFavoriteList();
|
||||||
@@ -246,8 +257,14 @@
|
|||||||
this.loadFavoriteList();
|
this.loadFavoriteList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
inputFavoriteSql(content) {
|
inputFavoriteSql(item) {
|
||||||
this.sqlExecutorEditor.setValue(content, 1);
|
this.sqlExecutorEditor.setValue(item.content, 1);
|
||||||
|
if (!!item.paramJson) {
|
||||||
|
let paramJson = JSON.parse(item.paramJson);
|
||||||
|
for (let key in paramJson) {
|
||||||
|
this.sqlParamHistory[key] = paramJson[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
formatterSql() {
|
formatterSql() {
|
||||||
let dataSql = this.sqlExecutorEditor.getSelectedText();
|
let dataSql = this.sqlExecutorEditor.getSelectedText();
|
||||||
|
|||||||
@@ -207,7 +207,7 @@
|
|||||||
dbType: this.tableStatusInfo.dbType,
|
dbType: this.tableStatusInfo.dbType,
|
||||||
// 默认排序字段,先随便取一个,impala等数据库必须排序后才能分页查
|
// 默认排序字段,先随便取一个,impala等数据库必须排序后才能分页查
|
||||||
orderColumn: primaryColumn.name,
|
orderColumn: primaryColumn.name,
|
||||||
});
|
}, this.columnList);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCopySuccess(e) {
|
onCopySuccess(e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user