执行器库表信息查询修改,展示优化,增加快捷键执行
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
package com.zyplayer.doc.data.repository.manage.entity;
|
package com.zyplayer.doc.data.repository.manage.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import java.util.Date;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
@@ -22,6 +23,11 @@ public class DbFavorite implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据源ID
|
||||||
|
*/
|
||||||
|
private Long datasourceId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收藏标题
|
* 收藏标题
|
||||||
@@ -115,4 +121,12 @@ public class DbFavorite implements Serializable {
|
|||||||
", yn=" + yn +
|
", yn=" + yn +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getDatasourceId() {
|
||||||
|
return datasourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatasourceId(Long datasourceId) {
|
||||||
|
this.datasourceId = datasourceId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.zyplayer.doc.db.framework.db.dto.*;
|
|||||||
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
import com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper;
|
||||||
import com.zyplayer.doc.db.framework.db.mapper.mysql.MysqlMapper;
|
import com.zyplayer.doc.db.framework.db.mapper.mysql.MysqlMapper;
|
||||||
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
@@ -89,6 +90,7 @@ public class DatabaseDocController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取编辑器所需的所有信息,用于自动补全
|
* 获取编辑器所需的所有信息,用于自动补全
|
||||||
|
* 此接口会返回所有库表结构,介意的话请自己手动屏蔽调此接口
|
||||||
* @param sourceId
|
* @param sourceId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -109,19 +111,35 @@ public class DatabaseDocController {
|
|||||||
List<DatabaseInfoDto> dbNameDtoList = baseMapper.getDatabaseList();
|
List<DatabaseInfoDto> dbNameDtoList = baseMapper.getDatabaseList();
|
||||||
Map<String, List<TableInfoDto>> dbTableMap = new HashMap<>();
|
Map<String, List<TableInfoDto>> dbTableMap = new HashMap<>();
|
||||||
Map<String, List<TableColumnDescDto>> tableColumnsMap = new HashMap<>();
|
Map<String, List<TableColumnDescDto>> tableColumnsMap = new HashMap<>();
|
||||||
|
|
||||||
|
Map<String, List<TableInfoDto>> tableMapList = new HashMap<>();
|
||||||
|
// MYSQL可以一次性查询所有库表
|
||||||
|
if (databaseFactoryBean.getDatabaseProduct() == DatabaseProduct.MYSQL) {
|
||||||
|
List<TableInfoDto> dbTableList = baseMapper.getTableList(null);
|
||||||
|
tableMapList = dbTableList.stream().collect(Collectors.groupingBy(TableInfoDto::getDbName));
|
||||||
|
}
|
||||||
for (DatabaseInfoDto infoDto : dbNameDtoList) {
|
for (DatabaseInfoDto infoDto : dbNameDtoList) {
|
||||||
List<TableInfoDto> dbTableList = baseMapper.getTableList(infoDto.getDbName());
|
List<TableInfoDto> tableInfoDtoList = tableMapList.get(infoDto.getDbName());
|
||||||
dbTableMap.put(infoDto.getDbName(), dbTableList);
|
// SQLSERVER必须要库才能查
|
||||||
for (TableInfoDto tableInfoDto : dbTableList) {
|
if (databaseFactoryBean.getDatabaseProduct() == DatabaseProduct.SQLSERVER) {
|
||||||
TableColumnVo tableColumnVo = this.getTableColumnVo(databaseFactoryBean, infoDto.getDbName(), tableInfoDto.getTableName());
|
tableInfoDtoList = baseMapper.getTableList(infoDto.getDbName());
|
||||||
// 重新组装一下,只返回两个字段,减少返回数据量
|
}
|
||||||
List<TableColumnDescDto> descDtoList = tableColumnVo.getColumnList().stream().map(val -> {
|
if (CollectionUtils.isEmpty(tableInfoDtoList)) {
|
||||||
TableColumnDescDto dto = new TableColumnDescDto();
|
continue;
|
||||||
dto.setName(val.getName());
|
}
|
||||||
dto.setDescription(val.getDescription());
|
dbTableMap.put(infoDto.getDbName(), tableInfoDtoList);
|
||||||
return dto;
|
// 小于10个库,查所有库,否则只查询当前链接的库,防止库表太多,数据量太大
|
||||||
}).collect(Collectors.toList());
|
// 如果觉得没必要就自己改吧!
|
||||||
tableColumnsMap.put(tableInfoDto.getTableName(), descDtoList);
|
Map<String, List<TableColumnDescDto>> columnDescDtoMap = new HashMap<>();
|
||||||
|
if (dbNameDtoList.size() <= 10 || Objects.equals(databaseFactoryBean.getDbName(), infoDto.getDbName())) {
|
||||||
|
List<TableColumnDescDto> columnDescDto = baseMapper.getTableColumnList(infoDto.getDbName(), null);
|
||||||
|
columnDescDtoMap = columnDescDto.stream().collect(Collectors.groupingBy(TableColumnDescDto::getTableName));
|
||||||
|
}
|
||||||
|
for (TableInfoDto tableInfoDto : tableInfoDtoList) {
|
||||||
|
List<TableColumnDescDto> descDtoList = columnDescDtoMap.get(tableInfoDto.getTableName());
|
||||||
|
if (CollectionUtils.isNotEmpty(descDtoList)) {
|
||||||
|
tableColumnsMap.put(tableInfoDto.getTableName(), descDtoList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, Object> dbResultMap = new HashMap<>();
|
Map<String, Object> dbResultMap = new HashMap<>();
|
||||||
@@ -177,9 +195,9 @@ public class DatabaseDocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/getTableDescList")
|
@PostMapping(value = "/getTableDescList")
|
||||||
public ResponseJson getTableDescList(Long sourceId, String tableName) {
|
public ResponseJson getTableDescList(Long sourceId, String dbName, String tableName) {
|
||||||
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
BaseMapper baseMapper = this.getViewAuthBaseMapper(sourceId);
|
||||||
List<TableDescDto> columnDescDto = baseMapper.getTableDescList(tableName);
|
List<TableDescDto> columnDescDto = baseMapper.getTableDescList(dbName, tableName);
|
||||||
return DocDbResponseJson.ok(columnDescDto);
|
return DocDbResponseJson.ok(columnDescDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +292,7 @@ public class DatabaseDocController {
|
|||||||
tableColumnVo.setColumnList(columnDescDto);
|
tableColumnVo.setColumnList(columnDescDto);
|
||||||
// 表注释
|
// 表注释
|
||||||
TableInfoVo tableInfoVo = new TableInfoVo();
|
TableInfoVo tableInfoVo = new TableInfoVo();
|
||||||
List<TableDescDto> tableDescList = baseMapper.getTableDescList(tableName);
|
List<TableDescDto> tableDescList = baseMapper.getTableDescList(dbName, tableName);
|
||||||
String description = null;
|
String description = null;
|
||||||
if (tableDescList.size() > 0) {
|
if (tableDescList.size() > 0) {
|
||||||
TableDescDto descDto = tableDescList.get(0);
|
TableDescDto descDto = tableDescList.get(0);
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public class DbSqlExecutorController {
|
|||||||
if (!manageAuth && !select && !update) {
|
if (!manageAuth && !select && !update) {
|
||||||
return DocDbResponseJson.warn("没有该数据源的执行权限");
|
return DocDbResponseJson.warn("没有该数据源的执行权限");
|
||||||
}
|
}
|
||||||
|
// 保留历史记录
|
||||||
|
dbHistoryService.saveHistory(sql.trim(), sourceId);
|
||||||
List<String> resultList = new LinkedList<>();
|
List<String> resultList = new LinkedList<>();
|
||||||
// 支持;分割的多个sql执行
|
// 支持;分割的多个sql执行
|
||||||
String[] sqlArr = sql.split(";");
|
String[] sqlArr = sql.split(";");
|
||||||
@@ -99,9 +101,10 @@ public class DbSqlExecutorController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/favorite/list")
|
@PostMapping(value = "/favorite/list")
|
||||||
public ResponseJson favoriteList() {
|
public ResponseJson favoriteList(Long sourceId) {
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
UpdateWrapper<DbFavorite> wrapper = new UpdateWrapper<>();
|
UpdateWrapper<DbFavorite> wrapper = new UpdateWrapper<>();
|
||||||
|
wrapper.eq(sourceId != null, "datasource_id", sourceId);
|
||||||
wrapper.eq("create_user_id", currentUser.getUserId());
|
wrapper.eq("create_user_id", currentUser.getUserId());
|
||||||
wrapper.eq("yn", 1);
|
wrapper.eq("yn", 1);
|
||||||
wrapper.orderByDesc("id");
|
wrapper.orderByDesc("id");
|
||||||
@@ -112,8 +115,11 @@ public class DbSqlExecutorController {
|
|||||||
@PostMapping(value = "/favorite/add")
|
@PostMapping(value = "/favorite/add")
|
||||||
public ResponseJson addFavorite(DbFavorite dbFavorite) {
|
public ResponseJson addFavorite(DbFavorite dbFavorite) {
|
||||||
Integer yn = Optional.ofNullable(dbFavorite.getYn()).orElse(1);
|
Integer yn = Optional.ofNullable(dbFavorite.getYn()).orElse(1);
|
||||||
if (yn == 1 && StringUtils.isBlank(dbFavorite.getContent())) {
|
if (yn == 1) {
|
||||||
return DocDbResponseJson.warn("收藏的SQL不能为空");
|
if (StringUtils.isBlank(dbFavorite.getContent())) {
|
||||||
|
return DocDbResponseJson.warn("收藏的SQL不能为空");
|
||||||
|
}
|
||||||
|
dbFavorite.setContent(dbFavorite.getContent().trim());
|
||||||
}
|
}
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
if (dbFavorite.getId() != null && dbFavorite.getId() > 0) {
|
if (dbFavorite.getId() != null && dbFavorite.getId() > 0) {
|
||||||
|
|||||||
@@ -1,68 +1,76 @@
|
|||||||
package com.zyplayer.doc.db.framework.db.dto;
|
package com.zyplayer.doc.db.framework.db.dto;
|
||||||
|
|
||||||
public class TableColumnDescDto {
|
public class TableColumnDescDto {
|
||||||
private String name;
|
private String tableName;
|
||||||
private String isidenity;
|
private String name;
|
||||||
private String type;
|
private String isidenity;
|
||||||
private String nullable;
|
private String type;
|
||||||
private String length;
|
private String nullable;
|
||||||
private String ispramary;
|
private String length;
|
||||||
private String description;
|
private String ispramary;
|
||||||
|
private String description;
|
||||||
public String getName() {
|
|
||||||
return name;
|
public String getName() {
|
||||||
}
|
return name;
|
||||||
|
}
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
public void setName(String name) {
|
||||||
}
|
this.name = name;
|
||||||
|
}
|
||||||
public String getIsidenity() {
|
|
||||||
return isidenity;
|
public String getIsidenity() {
|
||||||
}
|
return isidenity;
|
||||||
|
}
|
||||||
public void setIsidenity(String isidenity) {
|
|
||||||
this.isidenity = isidenity;
|
public void setIsidenity(String isidenity) {
|
||||||
}
|
this.isidenity = isidenity;
|
||||||
|
}
|
||||||
public String getType() {
|
|
||||||
return type;
|
public String getType() {
|
||||||
}
|
return type;
|
||||||
|
}
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
public void setType(String type) {
|
||||||
}
|
this.type = type;
|
||||||
|
}
|
||||||
public String getNullable() {
|
|
||||||
return nullable;
|
public String getNullable() {
|
||||||
}
|
return nullable;
|
||||||
|
}
|
||||||
public void setNullable(String nullable) {
|
|
||||||
this.nullable = nullable;
|
public void setNullable(String nullable) {
|
||||||
}
|
this.nullable = nullable;
|
||||||
|
}
|
||||||
public String getLength() {
|
|
||||||
return length;
|
public String getLength() {
|
||||||
}
|
return length;
|
||||||
|
}
|
||||||
public void setLength(String length) {
|
|
||||||
this.length = length;
|
public void setLength(String length) {
|
||||||
}
|
this.length = length;
|
||||||
|
}
|
||||||
public String getIspramary() {
|
|
||||||
return ispramary;
|
public String getIspramary() {
|
||||||
}
|
return ispramary;
|
||||||
|
}
|
||||||
public void setIspramary(String ispramary) {
|
|
||||||
this.ispramary = ispramary;
|
public void setIspramary(String ispramary) {
|
||||||
}
|
this.ispramary = ispramary;
|
||||||
|
}
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
public String getDescription() {
|
||||||
}
|
return description;
|
||||||
|
}
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
public void setDescription(String description) {
|
||||||
}
|
this.description = description;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTableName(String tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,32 +1,40 @@
|
|||||||
package com.zyplayer.doc.db.framework.db.dto;
|
package com.zyplayer.doc.db.framework.db.dto;
|
||||||
|
|
||||||
public class TableInfoDto {
|
public class TableInfoDto {
|
||||||
private String tableName;
|
private String dbName;
|
||||||
private String tableComment;
|
private String tableName;
|
||||||
private String tableId;
|
private String tableComment;
|
||||||
|
private String tableId;
|
||||||
public String getTableName() {
|
|
||||||
return tableName;
|
public String getTableName() {
|
||||||
}
|
return tableName;
|
||||||
|
}
|
||||||
public void setTableName(String tableName) {
|
|
||||||
this.tableName = tableName;
|
public void setTableName(String tableName) {
|
||||||
}
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
public String getTableId() {
|
|
||||||
return tableId;
|
public String getTableId() {
|
||||||
}
|
return tableId;
|
||||||
|
}
|
||||||
public void setTableId(String tableId) {
|
|
||||||
this.tableId = tableId;
|
public void setTableId(String tableId) {
|
||||||
}
|
this.tableId = tableId;
|
||||||
|
}
|
||||||
public String getTableComment() {
|
|
||||||
return tableComment;
|
public String getTableComment() {
|
||||||
}
|
return tableComment;
|
||||||
|
}
|
||||||
public void setTableComment(String tableComment) {
|
|
||||||
this.tableComment = tableComment;
|
public void setTableComment(String tableComment) {
|
||||||
}
|
this.tableComment = tableComment;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
public String getDbName() {
|
||||||
|
return dbName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDbName(String dbName) {
|
||||||
|
this.dbName = dbName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public interface BaseMapper {
|
|||||||
* @param tableName 可不传,传了只查询指定表的注释
|
* @param tableName 可不传,传了只查询指定表的注释
|
||||||
* @return 表注释
|
* @return 表注释
|
||||||
*/
|
*/
|
||||||
List<TableDescDto> getTableDescList(@Param("tableName") String tableName);
|
List<TableDescDto> getTableDescList(@Param("dbName") String dbName, @Param("tableName") String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加表注释
|
* 增加表注释
|
||||||
@@ -78,7 +78,7 @@ public interface BaseMapper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加字段注释
|
* 增加字段注释
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月8日
|
* @since 2018年8月8日
|
||||||
* @param dbName 数据库名
|
* @param dbName 数据库名
|
||||||
@@ -91,4 +91,4 @@ public interface BaseMapper {
|
|||||||
@Param("columnName") String columnName, @Param("newDesc") String newDesc,
|
@Param("columnName") String columnName, @Param("newDesc") String newDesc,
|
||||||
@Param("columnInfo") ColumnInfoDto columnInfo);
|
@Param("columnInfo") ColumnInfoDto columnInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ExecuteResult {
|
|||||||
private List<Map<String, Object>> result;
|
private List<Map<String, Object>> result;
|
||||||
|
|
||||||
public ExecuteResult() {
|
public ExecuteResult() {
|
||||||
this.updateCount = 0;
|
this.updateCount = -1;
|
||||||
this.useTime = 0;
|
this.useTime = 0;
|
||||||
this.result = Collections.emptyList();
|
this.result = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
|||||||
import com.zyplayer.doc.data.service.manage.DbHistoryService;
|
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.DatabaseFactoryBean;
|
||||||
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||||
import com.zyplayer.doc.db.framework.db.interceptor.SqlLogUtil;
|
|
||||||
import org.apache.ibatis.builder.SqlSourceBuilder;
|
import org.apache.ibatis.builder.SqlSourceBuilder;
|
||||||
import org.apache.ibatis.builder.StaticSqlSource;
|
import org.apache.ibatis.builder.StaticSqlSource;
|
||||||
import org.apache.ibatis.mapping.BoundSql;
|
import org.apache.ibatis.mapping.BoundSql;
|
||||||
import org.apache.ibatis.mapping.ParameterMapping;
|
|
||||||
import org.apache.ibatis.parsing.GenericTokenParser;
|
import org.apache.ibatis.parsing.GenericTokenParser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -72,30 +70,28 @@ public class SqlExecutor {
|
|||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019年8月18日
|
* @since 2019年8月18日
|
||||||
*/
|
*/
|
||||||
public ExecuteResult execute(DatabaseFactoryBean factoryBean, String executeId, ExecuteType executeType, String sql, Map<String, Object> paramMap, ResultHandler handler) {
|
public ExecuteResult execute(DatabaseFactoryBean factoryBean, String executeId, ExecuteType executeType, String sqlStr, Map<String, Object> paramMap, ResultHandler handler) {
|
||||||
if (factoryBean == null) {
|
if (factoryBean == null) {
|
||||||
return new ExecuteResult();
|
return new ExecuteResult();
|
||||||
}
|
}
|
||||||
BoundSql boundSql = getBoundSql(sql, paramMap);
|
// BoundSql boundSql = getBoundSql(sql, paramMap);
|
||||||
sql = boundSql.getSql();
|
// sql = boundSql.getSql();
|
||||||
String sqlStr = SqlLogUtil.getSqlString(paramMap, boundSql);
|
// String sqlStr = SqlLogUtil.getSqlString(paramMap, boundSql);
|
||||||
logger.info("sql ==> {}", sqlStr);
|
logger.info("sql ==> {}", sqlStr);
|
||||||
// 保留历史记录
|
|
||||||
dbHistoryService.saveHistory(sqlStr, factoryBean.getId());
|
|
||||||
|
|
||||||
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
|
// List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
DruidPooledConnection connection = null;
|
DruidPooledConnection connection = null;
|
||||||
// 执行查询
|
// 执行查询
|
||||||
try {
|
try {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
connection = factoryBean.getDataSource().getConnection();
|
connection = factoryBean.getDataSource().getConnection();
|
||||||
preparedStatement = connection.prepareStatement(sql);
|
preparedStatement = connection.prepareStatement(sqlStr);
|
||||||
// 设置当前的PreparedStatement
|
// 设置当前的PreparedStatement
|
||||||
statementMap.put(executeId, preparedStatement);
|
statementMap.put(executeId, preparedStatement);
|
||||||
for (int i = 0; i < parameterMappings.size(); i++) {
|
// for (int i = 0; i < parameterMappings.size(); i++) {
|
||||||
preparedStatement.setObject(i + 1, paramMap.get(parameterMappings.get(i).getProperty()));
|
// preparedStatement.setObject(i + 1, paramMap.get(parameterMappings.get(i).getProperty()));
|
||||||
}
|
// }
|
||||||
// 限制下最大数量
|
// 限制下最大数量
|
||||||
preparedStatement.setMaxRows(1000);
|
preparedStatement.setMaxRows(1000);
|
||||||
if (ExecuteType.SELECT.equals(executeType)) {
|
if (ExecuteType.SELECT.equals(executeType)) {
|
||||||
@@ -120,11 +116,10 @@ public class SqlExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更新的数量
|
// 更新的数量,小于0代表不是更新语句
|
||||||
int updateCount = preparedStatement.getUpdateCount();
|
int updateCount = preparedStatement.getUpdateCount();
|
||||||
updateCount = (updateCount < 0) ? 0 : updateCount;
|
|
||||||
long useTime = System.currentTimeMillis() - startTime;
|
long useTime = System.currentTimeMillis() - startTime;
|
||||||
return new ExecuteResult(updateCount, resultList, useTime, sql);
|
return new ExecuteResult(updateCount, resultList, useTime, sqlStr);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper">
|
<mapper namespace="com.zyplayer.doc.db.framework.db.mapper.base.BaseMapper">
|
||||||
|
|
||||||
<resultMap id="TableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto" >
|
<resultMap id="TableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto" >
|
||||||
|
<result column="TABLE_NAME" property="tableName" jdbcType="VARCHAR" />
|
||||||
<result column="NAME" property="name" jdbcType="VARCHAR" />
|
<result column="NAME" property="name" jdbcType="VARCHAR" />
|
||||||
<result column="ISIDENITY" property="isidenity" jdbcType="VARCHAR" />
|
<result column="ISIDENITY" property="isidenity" jdbcType="VARCHAR" />
|
||||||
<result column="TYPE" property="type" jdbcType="VARCHAR" />
|
<result column="TYPE" property="type" jdbcType="VARCHAR" />
|
||||||
@@ -11,13 +12,13 @@
|
|||||||
<result column="ISPRAMARY" property="ispramary" jdbcType="VARCHAR" />
|
<result column="ISPRAMARY" property="ispramary" jdbcType="VARCHAR" />
|
||||||
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="QueryTableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.QueryTableColumnDescDto" >
|
<resultMap id="QueryTableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.QueryTableColumnDescDto" >
|
||||||
<result column="TABLE_NAME" property="tableName" jdbcType="VARCHAR" />
|
<result column="TABLE_NAME" property="tableName" jdbcType="VARCHAR" />
|
||||||
<result column="COLUMN_NAME" property="columnName" jdbcType="VARCHAR" />
|
<result column="COLUMN_NAME" property="columnName" jdbcType="VARCHAR" />
|
||||||
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="getDatabaseList" resultType="com.zyplayer.doc.db.framework.db.dto.DatabaseInfoDto">
|
<select id="getDatabaseList" resultType="com.zyplayer.doc.db.framework.db.dto.DatabaseInfoDto">
|
||||||
select TABLE_SCHEMA dbName
|
select TABLE_SCHEMA dbName
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
@@ -25,44 +26,46 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTableList" resultType="com.zyplayer.doc.db.framework.db.dto.TableInfoDto">
|
<select id="getTableList" resultType="com.zyplayer.doc.db.framework.db.dto.TableInfoDto">
|
||||||
select table_name tableName, table_comment as tableComment
|
select table_schema dbName,table_name tableName, table_comment as tableComment
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
where table_schema=#{dbName}
|
<if test="dbName != null">where table_schema=#{dbName}</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTableColumnList" resultMap="TableColumnDescDtoMap">
|
<select id="getTableColumnList" resultMap="TableColumnDescDtoMap">
|
||||||
SELECT COLUMN_NAME NAME,column_comment DESCRIPTION,column_type TYPE,if(is_nullable='YES',1,0) NULLABLE
|
SELECT table_name as TABLE_NAME,COLUMN_NAME NAME,column_comment DESCRIPTION,column_type TYPE,if(is_nullable='YES',1,0) NULLABLE
|
||||||
FROM INFORMATION_SCHEMA.Columns
|
FROM INFORMATION_SCHEMA.Columns
|
||||||
WHERE table_schema=#{dbName} AND table_name=#{tableName}
|
WHERE table_schema=#{dbName}
|
||||||
|
<if test="tableName != null">and table_name=#{tableName}</if>
|
||||||
ORDER BY ordinal_position
|
ORDER BY ordinal_position
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTableColumnDescList" resultMap="TableColumnDescDtoMap">
|
<select id="getTableColumnDescList" resultMap="TableColumnDescDtoMap">
|
||||||
select 1
|
select 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTableAndColumnBySearch" resultMap="QueryTableColumnDescDtoMap">
|
<select id="getTableAndColumnBySearch" resultMap="QueryTableColumnDescDtoMap">
|
||||||
SELECT TABLE_NAME, COLUMN_NAME, column_comment DESCRIPTION
|
SELECT TABLE_NAME, COLUMN_NAME, column_comment DESCRIPTION
|
||||||
FROM INFORMATION_SCHEMA.Columns
|
FROM INFORMATION_SCHEMA.Columns
|
||||||
WHERE table_schema=#{dbName} AND (COLUMN_NAME like #{searchText} or column_comment like #{searchText})
|
WHERE table_schema=#{dbName} AND (COLUMN_NAME like #{searchText} or column_comment like #{searchText})
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTableDescList" resultType="com.zyplayer.doc.db.framework.db.dto.TableDescDto">
|
<select id="getTableDescList" resultType="com.zyplayer.doc.db.framework.db.dto.TableDescDto">
|
||||||
select table_name tableName, table_comment as description
|
select table_name tableName, table_comment as description
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
<if test="tableName != null">
|
<where>
|
||||||
where table_name=#{tableName}
|
<if test="dbName != null">and table_schema=#{dbName}</if>
|
||||||
</if>
|
<if test="tableName != null">and table_name=#{tableName}</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="updateTableDesc">
|
<insert id="updateTableDesc">
|
||||||
alter table ${dbName}.${tableName} comment #{newDesc}
|
alter table ${dbName}.${tableName} comment #{newDesc}
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="updateTableColumnDesc">
|
<insert id="updateTableColumnDesc">
|
||||||
alter table ${dbName}.${tableName} modify column ${columnName}
|
alter table ${dbName}.${tableName} modify column ${columnName}
|
||||||
${columnInfo.columnType} ${columnInfo.isNullable} ${columnInfo.columnDefault} ${columnInfo.extra}
|
${columnInfo.columnType} ${columnInfo.isNullable} ${columnInfo.columnDefault} ${columnInfo.extra}
|
||||||
comment #{newDesc}
|
comment #{newDesc}
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -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:"d0fd867e51634f6a3bdb",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}}([]);
|
!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?2fb9e03777eaeb893be9
|
//# sourceMappingURL=doc-db-manifest.js.map?42eca50901b3d81e2837
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="text/javascript" src="doc-db-manifest.js?2fb9e03777eaeb893be9"></script><script type="text/javascript" src="doc-db-vendor.js?0a0403eb1820498dc9bc"></script><script type="text/javascript" src="doc-db-index.js?d0fd867e51634f6a3bdb"></script></body>
|
<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>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
CREATE TABLE `db_favorite` (
|
CREATE TABLE `db_favorite` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||||
|
`datasource_id` bigint(20) NULL COMMENT '数据源ID',
|
||||||
`name` varchar(50) DEFAULT NULL COMMENT '收藏标题',
|
`name` varchar(50) DEFAULT NULL COMMENT '收藏标题',
|
||||||
`content` varchar(10000) DEFAULT NULL COMMENT '收藏内容',
|
`content` varchar(10000) DEFAULT NULL COMMENT '收藏内容',
|
||||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||||
@@ -39,6 +40,7 @@ INSERT INTO `auth_info`(`auth_name`, `auth_desc`, `can_edit`, `create_uid`, `cre
|
|||||||
VALUES ( 'DB_DESC_EDIT_', '表字段注释修改权', 0, 1, '2019-08-18 23:25:17', 0);
|
VALUES ( 'DB_DESC_EDIT_', '表字段注释修改权', 0, 1, '2019-08-18 23:25:17', 0);
|
||||||
|
|
||||||
-- ALTER TABLE `db_history` ADD COLUMN `datasource_id` bigint(0) NULL COMMENT '数据源ID';
|
-- ALTER TABLE `db_history` ADD COLUMN `datasource_id` bigint(0) NULL COMMENT '数据源ID';
|
||||||
|
-- ALTER TABLE `db_favorite` ADD COLUMN `datasource_id` bigint(0) NULL COMMENT '数据源ID';
|
||||||
|
|
||||||
|
|
||||||
-- ------------------------全新的库:------------------------
|
-- ------------------------全新的库:------------------------
|
||||||
|
|||||||
@@ -147,6 +147,10 @@
|
|||||||
},
|
},
|
||||||
handleNodeClick(node) {
|
handleNodeClick(node) {
|
||||||
console.log("点击节点:", node);
|
console.log("点击节点:", node);
|
||||||
|
// 执行器里面点击库表不跳转页面
|
||||||
|
// if (this.$router.currentRoute.path == "/data/executor") {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
if (node.type == 1) {
|
if (node.type == 1) {
|
||||||
this.nowClickPath = {sourceId: this.choiceDatasourceId, host: node.host, dbName: node.dbName, tableName: node.tableName};
|
this.nowClickPath = {sourceId: this.choiceDatasourceId, host: node.host, dbName: node.dbName, tableName: node.tableName};
|
||||||
this.$router.push({path: '/table/database', query: this.nowClickPath});
|
this.$router.push({path: '/table/database', query: this.nowClickPath});
|
||||||
@@ -217,7 +221,7 @@
|
|||||||
if (app.databaseList.length > 0) {
|
if (app.databaseList.length > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.choiceDatasourceId = sourceId;
|
this.choiceDatasourceId = parseInt(sourceId);
|
||||||
this.loadDatabaseList(sourceId, host, function () {
|
this.loadDatabaseList(sourceId, host, function () {
|
||||||
app.databaseExpandedKeys = [host];
|
app.databaseExpandedKeys = [host];
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
<pre id="sqlExecutorEditor" style="width: 100%;height: 500px;"></pre>
|
<pre id="sqlExecutorEditor" style="width: 100%;height: 500px;"></pre>
|
||||||
<div>
|
<div>
|
||||||
<el-button v-if="sqlExecuting" v-on:click="cancelExecutorSql" type="primary" plain size="small" icon="el-icon-video-pause">取消执行</el-button>
|
<el-button v-if="sqlExecuting" v-on:click="cancelExecutorSql" type="primary" plain size="small" icon="el-icon-video-pause">取消执行</el-button>
|
||||||
<el-button v-else v-on:click="doExecutorSql" type="primary" plain size="small" icon="el-icon-video-play">执行</el-button>
|
<el-tooltip v-else effect="dark" content="Ctrl+R、Ctrl+Enter" placement="top">
|
||||||
|
<el-button v-on:click="doExecutorSql" type="primary" plain size="small" icon="el-icon-video-play">执行</el-button>
|
||||||
|
</el-tooltip>
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
<span v-if="!!executeUpdateCount" class="execute-use-time">影响行数:{{executeUpdateCount}}</span>
|
|
||||||
<span v-if="!!executeUseTime" class="execute-use-time">查询时间:{{executeUseTime/1000}}s</span>
|
|
||||||
<el-button v-on:click="addFavorite('')" plain size="small" icon="el-icon-star-off">收藏</el-button>
|
<el-button v-on:click="addFavorite('')" plain size="small" icon="el-icon-star-off">收藏</el-button>
|
||||||
<el-button v-on:click="loadHistoryAndFavoriteList" plain size="small" icon="el-icon-tickets">收藏及历史</el-button>
|
<el-button v-on:click="loadHistoryAndFavoriteList" plain size="small" icon="el-icon-tickets">收藏及历史</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -26,11 +26,11 @@
|
|||||||
<div v-if="!!executeError" style="color: #f00;">{{executeError}}</div>
|
<div v-if="!!executeError" style="color: #f00;">{{executeError}}</div>
|
||||||
<div v-else-if="executeResultList.length <= 0" v-loading="sqlExecuting">暂无数据</div>
|
<div v-else-if="executeResultList.length <= 0" v-loading="sqlExecuting">暂无数据</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<el-tabs value="table1">
|
<el-tabs :value="executeShowTable">
|
||||||
<el-tab-pane label="信息" name="table0">
|
<el-tab-pane label="信息" name="table0">
|
||||||
<pre type="textarea" :rows="10" readonly v1-model="">{{executeResultInfo}}</pre>
|
<pre>{{executeResultInfo}}</pre>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="'结果'+(index+1)" :name="'table'+(index+1)" v-for="(resultItem, index) in executeResultList">
|
<el-tab-pane :label="'结果'+resultItem.index" :name="'table'+resultItem.index" v-for="resultItem in executeResultList" v-if="!!resultItem.index">
|
||||||
<div v-if="!!resultItem.errMsg" style="color: #f00;">{{resultItem.errMsg}}</div>
|
<div v-if="!!resultItem.errMsg" style="color: #f00;">{{resultItem.errMsg}}</div>
|
||||||
<el-table v-else :data="resultItem.dataList" stripe border style="width: 100%; margin-bottom: 5px;" class="execute-result-table" max-height="600">
|
<el-table v-else :data="resultItem.dataList" stripe border style="width: 100%; margin-bottom: 5px;" class="execute-result-table" max-height="600">
|
||||||
<el-table-column width="60px" v-if="resultItem.dataCols.length > 0">
|
<el-table-column width="60px" v-if="resultItem.dataCols.length > 0">
|
||||||
@@ -52,9 +52,11 @@
|
|||||||
<el-tabs value="favorite">
|
<el-tabs value="favorite">
|
||||||
<el-tab-pane label="我的收藏" name="favorite">
|
<el-tab-pane label="我的收藏" name="favorite">
|
||||||
<el-table :data="myFavoriteList" stripe border style="width: 100%; margin-bottom: 5px;" v-infinite-scroll>
|
<el-table :data="myFavoriteList" stripe border style="width: 100%; margin-bottom: 5px;" v-infinite-scroll>
|
||||||
<!-- <el-table-column prop="name" label="标题"></el-table-column>-->
|
<el-table-column prop="content" label="SQL">
|
||||||
<el-table-column prop="content" label="SQL"></el-table-column>
|
<template slot-scope="scope">
|
||||||
<!-- <el-table-column prop="createTime" label="收藏时间" width="160px"></el-table-column>-->
|
<pre style="margin: 0;">{{scope.row.content}}</pre>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="150px">
|
<el-table-column label="操作" width="150px">
|
||||||
<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.content)">输入</el-button>
|
||||||
@@ -102,8 +104,7 @@
|
|||||||
sqlExecuting: false,
|
sqlExecuting: false,
|
||||||
executeResultList: [],
|
executeResultList: [],
|
||||||
executeResultInfo: "",
|
executeResultInfo: "",
|
||||||
executeUseTime: 0,
|
executeShowTable: "table1",
|
||||||
executeUpdateCount: 0,
|
|
||||||
sqlExecutorEditor: {},
|
sqlExecutorEditor: {},
|
||||||
nowExecutorId: 1,
|
nowExecutorId: 1,
|
||||||
executeError: "",
|
executeError: "",
|
||||||
@@ -119,6 +120,13 @@
|
|||||||
// 下面两行先后顺序不能改
|
// 下面两行先后顺序不能改
|
||||||
this.addEditorCompleter();
|
this.addEditorCompleter();
|
||||||
app.sqlExecutorEditor = app.initAceEditor("sqlExecutorEditor", 15);
|
app.sqlExecutorEditor = app.initAceEditor("sqlExecutorEditor", 15);
|
||||||
|
app.sqlExecutorEditor.commands.addCommand({
|
||||||
|
name: "execute-sql",
|
||||||
|
bindKey: {win: "Ctrl-R|Ctrl-Shift-R|Ctrl-Enter", mac: "Command-R|Command-Shift-R|Command-Enter"},
|
||||||
|
exec: function (editor) {
|
||||||
|
app.doExecutorSql();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initAceEditor(editor, minLines) {
|
initAceEditor(editor, minLines) {
|
||||||
@@ -145,7 +153,7 @@
|
|||||||
this.loadFavoriteList();
|
this.loadFavoriteList();
|
||||||
},
|
},
|
||||||
loadFavoriteList() {
|
loadFavoriteList() {
|
||||||
this.common.post(this.apilist1.favoriteList, {}, function (json) {
|
this.common.post(this.apilist1.favoriteList, {sourceId: this.choiceDatasourceId}, function (json) {
|
||||||
app.myFavoriteList = json.data || [];
|
app.myFavoriteList = json.data || [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -161,7 +169,7 @@
|
|||||||
sqlValue = this.sqlExecutorEditor.getValue();
|
sqlValue = this.sqlExecutorEditor.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var param = {name: '我的收藏', content: sqlValue};
|
var param = {name: '我的收藏', content: sqlValue, datasourceId: this.choiceDatasourceId};
|
||||||
this.common.post(this.apilist1.updateFavorite, param, function (json) {
|
this.common.post(this.apilist1.updateFavorite, param, function (json) {
|
||||||
app.$message.success("收藏成功");
|
app.$message.success("收藏成功");
|
||||||
app.loadFavoriteList();
|
app.loadFavoriteList();
|
||||||
@@ -206,19 +214,19 @@
|
|||||||
}
|
}
|
||||||
var resultList = json.data || [];
|
var resultList = json.data || [];
|
||||||
var executeResultList = [];
|
var executeResultList = [];
|
||||||
var executeUpdateCount = 0, executeUseTime = 0;
|
var executeResultInfo = "", itemIndex = 1;
|
||||||
var executeResultInfo = "";
|
|
||||||
for (var i = 0; i < resultList.length; i++) {
|
for (var i = 0; i < resultList.length; i++) {
|
||||||
var objItem = JSON.parse(resultList[i]);
|
var objItem = JSON.parse(resultList[i]);
|
||||||
executeUpdateCount += (objItem.updateCount || 0);
|
|
||||||
executeUseTime += (objItem.useTime || 0);
|
|
||||||
executeResultInfo += app.getExecuteInfoStr(objItem);
|
executeResultInfo += app.getExecuteInfoStr(objItem);
|
||||||
var resultItem = app.dealExecuteResult(objItem);
|
var resultItem = app.dealExecuteResult(objItem);
|
||||||
|
if (resultItem.updateCount < 0) {
|
||||||
|
resultItem.index = itemIndex;
|
||||||
|
itemIndex++;
|
||||||
|
}
|
||||||
executeResultList.push(resultItem);
|
executeResultList.push(resultItem);
|
||||||
}
|
}
|
||||||
|
app.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
|
||||||
app.executeResultInfo = executeResultInfo;
|
app.executeResultInfo = executeResultInfo;
|
||||||
app.executeUseTime = executeUseTime;
|
|
||||||
app.executeUpdateCount = executeUpdateCount;
|
|
||||||
app.executeResultList = executeResultList;
|
app.executeResultList = executeResultList;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -250,8 +258,11 @@
|
|||||||
},
|
},
|
||||||
getExecuteInfoStr(resultData) {
|
getExecuteInfoStr(resultData) {
|
||||||
var resultStr = resultData.sql;
|
var resultStr = resultData.sql;
|
||||||
resultStr += "\n> " + ((!!resultData.errMsg) ? "ERROR" : "OK");
|
resultStr += "\n> 状态:" + ((!!resultData.errMsg) ? "ERROR" : "OK");
|
||||||
resultStr += "\n> " + (resultData.useTime || 0) / 1000 + "s";
|
if (resultData.updateCount >= 0) {
|
||||||
|
resultStr += "\n> 影响行数:" + resultData.updateCount;
|
||||||
|
}
|
||||||
|
resultStr += "\n> 耗时:" + (resultData.useTime || 0) / 1000 + "s";
|
||||||
resultStr += "\n\n";
|
resultStr += "\n\n";
|
||||||
return resultStr;
|
return resultStr;
|
||||||
},
|
},
|
||||||
@@ -280,7 +291,7 @@
|
|||||||
resultObj.dataCols = executeResultCols;
|
resultObj.dataCols = executeResultCols;
|
||||||
resultObj.useTime = resultData.useTime || 0;
|
resultObj.useTime = resultData.useTime || 0;
|
||||||
resultObj.errMsg = resultData.errMsg || "";
|
resultObj.errMsg = resultData.errMsg || "";
|
||||||
resultObj.updateCount = resultData.updateCount || 0;
|
resultObj.updateCount = resultData.updateCount;
|
||||||
return resultObj;
|
return resultObj;
|
||||||
},
|
},
|
||||||
addEditorCompleter() {
|
addEditorCompleter() {
|
||||||
|
|||||||
Reference in New Issue
Block a user