表数据查看增加选择展示列功能,域账号登录优化

This commit is contained in:
暮光:城中城
2021-09-25 21:28:37 +08:00
parent 27c0d8e50a
commit b82f6ae2e0
9 changed files with 106 additions and 67 deletions

View File

@@ -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/chunk-vendors.8924efc6.css rel=preload as=style><link href=css/index.ba19e721.css rel=preload as=style><link href=js/chunk-vendors.1ddbf5ec.js rel=preload as=script><link href=js/index.6b959b2c.js rel=preload as=script><link href=css/chunk-vendors.8924efc6.css rel=stylesheet><link href=css/index.ba19e721.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.1ddbf5ec.js></script><script src=js/index.6b959b2c.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.ba19e721.css rel=preload as=style><link href=js/chunk-vendors.1ddbf5ec.js rel=preload as=script><link href=js/index.1771804b.js rel=preload as=script><link href=css/chunk-vendors.8924efc6.css rel=stylesheet><link href=css/index.ba19e721.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.1ddbf5ec.js></script><script src=js/index.1771804b.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
@@ -21,14 +22,14 @@ import java.util.Optional;
@SpringBootApplication @SpringBootApplication
@ComponentScan(basePackages = {"com.zyplayer.doc.manage", "com.zyplayer.doc.data"}) @ComponentScan(basePackages = {"com.zyplayer.doc.manage", "com.zyplayer.doc.data"})
public class Application extends SpringBootServletInitializer { public class Application extends SpringBootServletInitializer {
private static Logger logger = LoggerFactory.getLogger(Application.class); private static Logger logger = LoggerFactory.getLogger(Application.class);
@Override @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class); return application.sources(Application.class);
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
ConfigurableApplicationContext application = SpringApplication.run(Application.class, args); ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);
Environment env = application.getEnvironment(); Environment env = application.getEnvironment();

View File

@@ -1,30 +0,0 @@
package com.zyplayer.doc.manage.framework.config;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
@Configurable
public class LdapConfig {
String url = "ldap://10.0.1.1:10389";
String base = "dc=xx,dc=net";
String userDn = "cn=Manager,dc=xx,dc=net";
String password = "MKDSHYDNIS";
/**
* 初始化
*/
@Bean
public LdapTemplate getLdapTemplate() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(url);
contextSource.setBase(base);
contextSource.setUserDn(userDn);
contextSource.setPassword(password);
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
return new LdapTemplate(contextSource);
}
}

View File

@@ -46,8 +46,8 @@ public class LoginController {
// TODO 域账号登录,待测试 // TODO 域账号登录,待测试
@Value("${spring.ldap.domainName:}") @Value("${spring.ldap.domainName:}")
private String ldapDomainName; private String ldapDomainName;
@Value("${spring.ldap.urls:}") @Value("${spring.ldap.enable:}")
private String ldapUrls; private boolean ldapLoginEnable;
/** /**
* 用户登录 * 用户登录
@@ -59,7 +59,7 @@ public class LoginController {
queryWrapper.eq("del_flag", 0); queryWrapper.eq("del_flag", 0);
UserInfo userInfo = userInfoService.getOne(queryWrapper); UserInfo userInfo = userInfoService.getOne(queryWrapper);
// 如果使用域账号登录 // 如果使用域账号登录
if (this.isUseLdapServer()) { if (ldapLoginEnable) {
LdapPerson ldapPerson = this.getUserFromLdap(username, password); LdapPerson ldapPerson = this.getUserFromLdap(username, password);
if (null == ldapPerson) { if (null == ldapPerson) {
return DocResponseJson.warn("用户名或密码错误"); return DocResponseJson.warn("用户名或密码错误");
@@ -117,13 +117,6 @@ public class LoginController {
return userInfo; return userInfo;
} }
/**
* 是否使用域账号登录
*/
public boolean isUseLdapServer() {
return StringUtils.isNotEmpty(ldapUrls);
}
/** /**
* 鉴别域账号中是否有该用户 * 鉴别域账号中是否有该用户
*/ */

View File

@@ -10,6 +10,13 @@ spring:
datasource: datasource:
continue-on-error: true continue-on-error: true
ldap:
enable: false
urls: ['ldap://10.0.1.1:10389']
base: dc=xx,dc=net
username: cn=Manager,dc=xx,dc=net
password: MKDSHYDNIS
anonymousReadOnly: true
# 端口和根路劲main方法启动时需要放tomcat后以tomcat的配置为准 # 端口和根路劲main方法启动时需要放tomcat后以tomcat的配置为准
server: server:

View File

@@ -58,10 +58,11 @@ public class RedisUtil {
Jedis jedis = null; Jedis jedis = null;
try { try {
jedis = pool.getResource(); jedis = pool.getResource();
T result = consumer.apply(jedis);
if (key != null && expire > 0) { if (key != null && expire > 0) {
jedis.expire(key, expire); jedis.expire(key, expire);
} }
return consumer.apply(jedis); return result;
} catch (Exception e) { } catch (Exception e) {
logger.error("redis操作失败{}", e.getMessage()); logger.error("redis操作失败{}", e.getMessage());
return null; return null;

View File

@@ -17,21 +17,26 @@
<div v-else-if="sqlExecuting" v-loading="sqlExecuting" style="padding: 20px 0;">数据加载中...</div> <div v-else-if="sqlExecuting" v-loading="sqlExecuting" style="padding: 20px 0;">数据加载中...</div>
<div v-else-if="executeResultList.length <= 0" v-loading="sqlExecuting" style="padding: 20px 0;">暂无数据</div> <div v-else-if="executeResultList.length <= 0" v-loading="sqlExecuting" style="padding: 20px 0;">暂无数据</div>
<div v-else style="position: relative;"> <div v-else style="position: relative;">
<div style="position: absolute;right: 0;z-index: 1;" v-show="this.choiceResultObj[this.executeShowTable] && this.choiceResultObj[this.executeShowTable].length > 0"> <div style="position: absolute;right: 0;z-index: 1;" v-show="executeShowTable !== 'table0'">
<el-button icon="el-icon-delete" size="small" @click="deleteCheckLine" type="danger" plain style="margin-right: 10px;">删除</el-button> <span v-show="choiceResultObj[executeShowTable] && choiceResultObj[executeShowTable].length > 0">
<!-- 复制选中行 --> <el-button icon="el-icon-delete" size="small" @click="deleteCheckLine" type="danger" plain style="margin-right: 10px;">删除</el-button>
<el-dropdown @command="handleCopyCheckLineCommand"> <!-- 复制选中行 -->
<el-button type="primary" size="small" icon="el-icon-document-copy"> <el-dropdown @command="handleCopyCheckLineCommand">
复制选中行<i class="el-icon-arrow-down el-icon--right"></i> <el-button type="primary" size="small" icon="el-icon-document-copy">
</el-button> 复制选中行<i class="el-icon-arrow-down el-icon--right"></i>
<el-dropdown-menu slot="dropdown"> </el-button>
<el-dropdown-item command="insert">SQL Inserts</el-dropdown-item> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="update">SQL Updates</el-dropdown-item> <el-dropdown-item command="insert">SQL Inserts</el-dropdown-item>
<el-dropdown-item command="json">JSON</el-dropdown-item> <el-dropdown-item command="update">SQL Updates</el-dropdown-item>
</el-dropdown-menu> <el-dropdown-item command="json">JSON</el-dropdown-item>
</el-dropdown> </el-dropdown-menu>
</el-dropdown>
</span>
<el-tooltip effect="dark" content="选择展示列" placement="top">
<el-button icon="el-icon-setting" size="small" style="margin-left: 10px;" @click="choiceShowColumnDrawerShow"></el-button>
</el-tooltip>
</div> </div>
<el-tabs v-model="executeShowTable"> <el-tabs v-model="executeShowTable" @tab-click="executeShowTableClick">
<el-tab-pane label="信息" name="table0"> <el-tab-pane label="信息" name="table0">
<pre>{{executeResultInfo}}</pre> <pre>{{executeResultInfo}}</pre>
</el-tab-pane> </el-tab-pane>
@@ -100,11 +105,6 @@
<el-checkbox :true-label="1" :false-label="0" v-model="downloadDataParam.dropTableFlag" @change="dropTableFlagChange">删除表{{downloadDataParam.dropTableFlag==1?'!!':''}}</el-checkbox> <el-checkbox :true-label="1" :false-label="0" v-model="downloadDataParam.dropTableFlag" @change="dropTableFlagChange">删除表{{downloadDataParam.dropTableFlag==1?'!!':''}}</el-checkbox>
<el-checkbox :true-label="1" :false-label="0" v-model="downloadDataParam.createTableFlag" @change="createTableFlagChange">创建表</el-checkbox> <el-checkbox :true-label="1" :false-label="0" v-model="downloadDataParam.createTableFlag" @change="createTableFlagChange">创建表</el-checkbox>
</el-form-item> </el-form-item>
<el-form-item label="保留的列:">
<el-select v-model="downloadDataParam.retainColumnArr" multiple placeholder="不选则保留全部列" style="width: 370px;">
<el-option v-for="item in conditionDataCols" :key="item.prop" :label="item.prop" :value="item.prop"></el-option>
</el-select>
</el-form-item>
<el-form-item label="更新条件列:" v-if="downloadDataParam.downloadType === 'update'"> <el-form-item label="更新条件列:" v-if="downloadDataParam.downloadType === 'update'">
<el-select v-model="downloadDataParam.conditionColumnArr" multiple placeholder="不选则是没有条件的更新" style="width: 370px;"> <el-select v-model="downloadDataParam.conditionColumnArr" multiple placeholder="不选则是没有条件的更新" style="width: 370px;">
<el-option v-for="item in conditionDataCols" :key="item.prop" :label="item.prop" :value="item.prop"></el-option> <el-option v-for="item in conditionDataCols" :key="item.prop" :label="item.prop" :value="item.prop"></el-option>
@@ -116,6 +116,27 @@
<el-button type="primary" @click="doDownloadTableData"> </el-button> <el-button type="primary" @click="doDownloadTableData"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-drawer
size="350px"
:with-header="false"
:visible.sync="choiceShowColumnDrawer"
:before-close="choiceShowColumnDrawerClose"
direction="rtl">
<div style="padding: 10px;">
<el-row>
<el-col :span="12">选择展示列</el-col>
<el-col :span="12" style="text-align: right;">
<el-checkbox v-model="choiceShowColumnAll" @change="choiceShowColumnAllChange">全选</el-checkbox>
<el-button type="primary" size="mini" @click="choiceShowColumnOk" style="margin-left: 10px;">确定</el-button>
</el-col>
</el-row>
</div>
<div style="">
<el-tree ref="showColumnTree" node-key="name" :props="showColumnProps" :data="tableDataColumns" check-on-click-node show-checkbox
@check-change="tableDataColumnsCheckChange">
</el-tree>
</div>
</el-drawer>
<form method="post" ref="downloadForm" :action="downloadFormParam.url" target="_blank"> <form method="post" ref="downloadForm" :action="downloadFormParam.url" target="_blank">
<input type="hidden" :name="key" :value="val" v-for="(val,key) in downloadFormParam.param"> <input type="hidden" :name="key" :value="val" v-for="(val,key) in downloadFormParam.param">
</form> </form>
@@ -151,6 +172,7 @@
// 选择复制 // 选择复制
choiceResultObj: {}, choiceResultObj: {},
exportConditionVisible: false, exportConditionVisible: false,
tableDataColumns: [],
conditionDataCols: [], conditionDataCols: [],
conditionDataColsChoice: [], conditionDataColsChoice: [],
// 导出 // 导出
@@ -166,6 +188,11 @@
url: 'zyplayer-doc-db/data-view/downloadMultiple', url: 'zyplayer-doc-db/data-view/downloadMultiple',
param: {} param: {}
}, },
// 选择展示列
choiceShowColumnDrawer: false,
showColumnProps: {label: 'name'},
choiceShowColumnLast: [],
choiceShowColumnAll: true,
// 编辑器 // 编辑器
sqlExecutorContent: '', sqlExecutorContent: '',
sqlEditorConfig: { sqlEditorConfig: {
@@ -215,6 +242,7 @@
this.primaryKeyColumn = item; this.primaryKeyColumn = item;
} }
}); });
this.tableDataColumns = columnList;
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};
@@ -289,6 +317,7 @@
tableName: this.pageParam.tableName, tableName: this.pageParam.tableName,
executeId: this.nowExecutorId, executeId: this.nowExecutorId,
condition: conditionSql, condition: conditionSql,
retainColumn: this.choiceShowColumnLast.join(','),
pageNum: this.currentPage, pageNum: this.currentPage,
pageSize: this.pageSize, pageSize: this.pageSize,
orderColumn: this.tableSort.prop, orderColumn: this.tableSort.prop,
@@ -321,7 +350,8 @@
this.executeShowTable = (itemIndex === 1) ? "table0" : "table1"; this.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
this.executeResultInfo = executeResultInfo; this.executeResultInfo = executeResultInfo;
this.executeResultList = executeResultList; this.executeResultList = executeResultList;
}).catch(e => { this.executeShowTableClick();
}).catch(e => {
this.sqlExecuting = false; this.sqlExecuting = false;
}); });
}, },
@@ -364,6 +394,12 @@
handleSelectionChange(val) { handleSelectionChange(val) {
this.$set(this.choiceResultObj, this.executeShowTable, val); this.$set(this.choiceResultObj, this.executeShowTable, val);
}, },
executeShowTableClick() {
let currentTable = this.executeResultList.find(item => item.name === this.executeShowTable);
if (currentTable) {
this.choiceShowColumnLast = currentTable.dataCols.map(val => val.prop);
}
},
doCopyCheckLineUpdate() { doCopyCheckLineUpdate() {
let choiceData = this.choiceResultObj[this.executeShowTable] || []; let choiceData = this.choiceResultObj[this.executeShowTable] || [];
if (choiceData.length > 0) { if (choiceData.length > 0) {
@@ -440,7 +476,7 @@
let condition = {}, conditionColumn = {}, retainColumn = {}; let condition = {}, conditionColumn = {}, retainColumn = {};
condition[this.pageParam.tableName] = conditionSql; condition[this.pageParam.tableName] = conditionSql;
conditionColumn[this.pageParam.tableName] = this.downloadDataParam.conditionColumnArr.join(","); conditionColumn[this.pageParam.tableName] = this.downloadDataParam.conditionColumnArr.join(",");
retainColumn[this.pageParam.tableName] = this.downloadDataParam.retainColumnArr.join(","); retainColumn[this.pageParam.tableName] = this.choiceShowColumnLast.join(",");
this.downloadFormParam.param = { this.downloadFormParam.param = {
executeId: this.nowExecutorId, executeId: this.nowExecutorId,
sourceId: this.pageParam.sourceId, sourceId: this.pageParam.sourceId,
@@ -480,6 +516,37 @@
this.downloadDataParam.dropTableFlag = 0; this.downloadDataParam.dropTableFlag = 0;
} }
}, },
choiceShowColumnDrawerShow() {
this.choiceShowColumnDrawer = true;
setTimeout(() => {
this.$refs.showColumnTree.setCheckedKeys(this.choiceShowColumnLast);
this.choiceShowColumnAll = (this.choiceShowColumnLast.length === this.tableDataColumns.length);
}, 10);
},
choiceShowColumnDrawerClose() {
this.choiceShowColumnDrawer = false;
},
choiceShowColumnOk() {
let checkedKeys = this.$refs.showColumnTree.getCheckedKeys();
if (checkedKeys.length <= 0) {
this.$message.warning("必须选择一列展示");
} else {
this.choiceShowColumnLast = checkedKeys;
this.choiceShowColumnDrawer = false;
this.doExecutorClick();
}
},
tableDataColumnsCheckChange() {
let checkedKeys = this.$refs.showColumnTree.getCheckedKeys();
this.choiceShowColumnAll = (checkedKeys.length === this.tableDataColumns.length);
},
choiceShowColumnAllChange() {
let choiceAll = [];
if (this.choiceShowColumnAll) {
choiceAll = this.tableDataColumns.map(val => val.name);
}
this.$refs.showColumnTree.setCheckedKeys(choiceAll);
},
} }
} }
</script> </script>