forked from p85126437/datagear
SQL工作台添加SQL历史基本代码
This commit is contained in:
parent
2fedb9946c
commit
bb0a1c734f
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.datagear.management.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.datagear.model.support.AbstractStringIdEntity;
|
||||
|
||||
/**
|
||||
* SQL历史。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SqlHistory extends AbstractStringIdEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** SQL语句 */
|
||||
private String sql;
|
||||
|
||||
/** 用户ID */
|
||||
private String userId;
|
||||
|
||||
/** SQL时间 */
|
||||
private Date createTime;
|
||||
|
||||
public SqlHistory()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public SqlHistory(String id, String sql, String userId)
|
||||
{
|
||||
super(id);
|
||||
this.sql = sql;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getSql()
|
||||
{
|
||||
return sql;
|
||||
}
|
||||
|
||||
public void setSql(String sql)
|
||||
{
|
||||
this.sql = sql;
|
||||
}
|
||||
|
||||
public String getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.datagear.management.service;
|
||||
|
||||
import org.datagear.management.domain.SqlHistory;
|
||||
import org.datagear.persistence.PagingData;
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
|
||||
/**
|
||||
* {@linkplain SqlHistory}业务服务接口。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface SqlHistoryService extends EntityService<String, SqlHistory>
|
||||
{
|
||||
/**
|
||||
* 分页查询。
|
||||
*
|
||||
* @param user
|
||||
* @param pagingQuery
|
||||
* @return
|
||||
*/
|
||||
PagingData<SqlHistory> pagingQueryByUserId(String userId, PagingQuery pagingQuery);
|
||||
}
|
|
@ -21,6 +21,7 @@ import org.datagear.persistence.Order;
|
|||
import org.datagear.persistence.PagingData;
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
import org.datagear.persistence.Query;
|
||||
import org.datagear.util.StringUtil;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.support.SqlSessionDaoSupport;
|
||||
|
||||
|
@ -391,7 +392,7 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
if (orderSql.length() > 0)
|
||||
orderSql.append(", ");
|
||||
|
||||
orderSql.append(this.identifierQuote + order.getName() + this.identifierQuote);
|
||||
orderSql.append(toQuoteIdentifier(order.getName()));
|
||||
orderSql.append(" ");
|
||||
|
||||
if ("DESC".equalsIgnoreCase(order.getType()))
|
||||
|
@ -563,6 +564,17 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
params.put(this.identifierQuoteKey, this.identifierQuote);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为标识符添加引用符。
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
protected String toQuoteIdentifier(String s)
|
||||
{
|
||||
return this.identifierQuote + s + this.identifierQuote;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库标识引用符。
|
||||
* <p>
|
||||
|
@ -574,7 +586,7 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
*/
|
||||
protected String getIdentifierQuote(DataSource dataSource)
|
||||
{
|
||||
String identifierQuote = "";
|
||||
String identifierQuote = " ";
|
||||
|
||||
Connection cn = null;
|
||||
|
||||
|
@ -613,29 +625,37 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断对象、字符串、数组、集合、Map是否为空。
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
protected boolean isEmpty(Object obj)
|
||||
{
|
||||
return StringUtil.isEmpty(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串是否为空。
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
protected boolean isEmpty(String s)
|
||||
{
|
||||
return StringUtil.isEmpty(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串是否为空格串。
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
protected boolean isBlank(String s)
|
||||
{
|
||||
if (s == null)
|
||||
return true;
|
||||
|
||||
if (s.isEmpty())
|
||||
return true;
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isEmpty(String s)
|
||||
{
|
||||
return (s == null || s.isEmpty());
|
||||
return StringUtil.isBlank(s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.datagear.management.service.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.datagear.management.domain.SqlHistory;
|
||||
import org.datagear.management.service.SqlHistoryService;
|
||||
import org.datagear.persistence.PagingData;
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
/**
|
||||
* {@linkplain SqlHistoryService}实现类。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SqlHistoryServiceImpl extends AbstractMybatisEntityService<String, SqlHistory> implements SqlHistoryService
|
||||
{
|
||||
protected static final String SQL_NAMESPACE = SqlHistory.class.getName();
|
||||
|
||||
public SqlHistoryServiceImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public SqlHistoryServiceImpl(SqlSessionFactory sqlSessionFactory)
|
||||
{
|
||||
super(sqlSessionFactory);
|
||||
}
|
||||
|
||||
public SqlHistoryServiceImpl(SqlSessionTemplate sqlSessionTemplate)
|
||||
{
|
||||
super(sqlSessionTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PagingData<SqlHistory> pagingQueryByUserId(String userId, PagingQuery pagingQuery)
|
||||
{
|
||||
Map<String, Object> params = buildParamMap();
|
||||
params.put("userId", userId);
|
||||
|
||||
if (isEmpty(pagingQuery.getOrders()))
|
||||
addOrderCreateTimeDesc(params);
|
||||
|
||||
return pagingQuery(pagingQuery, params);
|
||||
}
|
||||
|
||||
protected void addOrderCreateTimeDesc(Map<String, Object> params)
|
||||
{
|
||||
params.put(QUERY_PARAM_ORDER, toQuoteIdentifier("createTime") + " DESC");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSqlNamespace()
|
||||
{
|
||||
return SQL_NAMESPACE;
|
||||
}
|
||||
}
|
|
@ -144,4 +144,13 @@ CREATE TABLE DATAGEAR_AUTHORIZATION
|
|||
|
||||
--自定义REPLACE函数
|
||||
CREATE FUNCTION DATAGEAR_REPLACE(orgStr VARCHAR(500), oldStr VARCHAR(100), newStr VARCHAR(100)) RETURNS VARCHAR(500)
|
||||
PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL NAME 'org.datagear.management.util.DerbyFunctionSupport.replace';
|
||||
PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL NAME 'org.datagear.management.util.DerbyFunctionSupport.replace';
|
||||
|
||||
CREATE TABLE DATAGEAR_SQL_HISTORY
|
||||
(
|
||||
SQLHIS_ID VARCHAR(50) NOT NULL,
|
||||
SQLHIS_SQL VARCHAR(5000) NOT NULL,
|
||||
SQLHIS_USER_ID VARCHAR(50) NOT NULL,
|
||||
SQLHIS_CREATE_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (SQLHIS_ID)
|
||||
);
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
<?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">
|
||||
|
||||
<mapper namespace="org.datagear.management.domain.SqlHistory">
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO DATAGEAR_SQL_HISTORY
|
||||
(
|
||||
SQLHIS_ID, SQLHIS_SQL, SQLHIS_USER_ID
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{entity.id}, #{entity.sql}, #{entity.userId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE DATAGEAR_SQL_HISTORY SET
|
||||
SQLHIS_SQL = #{entity.sql},
|
||||
SQLHIS_USER_ID = #{entity.userId}
|
||||
WHERE
|
||||
SQLHIS_ID = #{entity.id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM DATAGEAR_SQL_HISTORY
|
||||
WHERE
|
||||
SQLHIS_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getById" resultType="org.datagear.management.domain.SqlHistory">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
T.${_iq_}id${_iq_} = #{id}
|
||||
</select>
|
||||
|
||||
<select id="query" resultType="org.datagear.management.domain.SqlHistory">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
<include refid="common.queryOrder" />
|
||||
</select>
|
||||
|
||||
<select id="pagingQueryCount" resultType="int">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
</select>
|
||||
|
||||
<select id="pagingQuery" resultType="org.datagear.management.domain.SqlHistory">
|
||||
<include refid="common.pagingQueryHead" />
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
<include refid="common.queryOrder" />
|
||||
<include refid="common.pagingQueryFoot" />
|
||||
</select>
|
||||
|
||||
<sql id="queryView">
|
||||
SELECT
|
||||
A.SQLHIS_ID AS ${_iq_}id${_iq_},
|
||||
A.SQLHIS_SQL AS ${_iq_}sql${_iq_},
|
||||
A.SQLHIS_USER_ID AS ${_iq_}userId${_iq_},
|
||||
A.SQLHIS_CREATE_TIME AS ${_iq_}createTime${_iq_}
|
||||
FROM
|
||||
DATAGEAR_SQL_HISTORY A
|
||||
</sql>
|
||||
|
||||
<sql id="queryCondition">
|
||||
1 = 1
|
||||
<if test="userId != null">
|
||||
AND ${_iq_}userId${_iq_} = #{userId}
|
||||
</if>
|
||||
<if test="queryKeyword != null">
|
||||
AND ${_iq_}sql${_iq_} LIKE #{queryKeyword}
|
||||
</if>
|
||||
<include refid="common.queryCondition" />
|
||||
</sql>
|
||||
</mapper>
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字符串工具类。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class StringUtil
|
||||
{
|
||||
private StringUtil()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串是否为{@code null}、空格串。
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static boolean isBlank(String s)
|
||||
{
|
||||
if (s == null)
|
||||
return true;
|
||||
|
||||
if (s.isEmpty())
|
||||
return true;
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串是否为{@code null}、空。
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmpty(String s)
|
||||
{
|
||||
return (s == null || s.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断对象、字符串、数组、集合、Map是否为{@code null}、空、空元素。
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmpty(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (obj instanceof String)
|
||||
{
|
||||
String str = (String) obj;
|
||||
return (str == null || str.isEmpty());
|
||||
}
|
||||
else if (obj instanceof Object[])
|
||||
{
|
||||
Object[] array = (Object[]) obj;
|
||||
|
||||
return (array.length == 0);
|
||||
}
|
||||
else if (obj instanceof Collection<?>)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<Object> collection = (Collection<Object>) obj;
|
||||
|
||||
return (collection.isEmpty());
|
||||
}
|
||||
else if (obj instanceof Map<?, ?>)
|
||||
{
|
||||
Map<?, ?> map = (Map<?, ?>) obj;
|
||||
|
||||
return map.isEmpty();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
package org.datagear.web.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -16,6 +15,7 @@ import org.datagear.persistence.Order;
|
|||
import org.datagear.persistence.Paging;
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
import org.datagear.persistence.PersistenceManager;
|
||||
import org.datagear.util.StringUtil;
|
||||
import org.datagear.web.OperationMessage;
|
||||
import org.datagear.web.convert.ClassDataConverter;
|
||||
import org.datagear.web.util.WebUtils;
|
||||
|
@ -552,35 +552,7 @@ public abstract class AbstractController
|
|||
*/
|
||||
protected boolean isEmpty(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (obj instanceof String)
|
||||
{
|
||||
return isEmpty((String) obj);
|
||||
}
|
||||
else if (obj instanceof Object[])
|
||||
{
|
||||
Object[] array = (Object[]) obj;
|
||||
|
||||
return (array.length == 0);
|
||||
}
|
||||
else if (obj instanceof Collection<?>)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<Object> collection = (Collection<Object>) obj;
|
||||
|
||||
return (collection.isEmpty());
|
||||
}
|
||||
else if (obj instanceof Map<?, ?>)
|
||||
{
|
||||
Map<?, ?> map = (Map<?, ?>) obj;
|
||||
|
||||
return map.isEmpty();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return StringUtil.isEmpty(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -591,7 +563,7 @@ public abstract class AbstractController
|
|||
*/
|
||||
protected boolean isEmpty(String s)
|
||||
{
|
||||
return (s == null || s.isEmpty());
|
||||
return StringUtil.isEmpty(s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -602,15 +574,6 @@ public abstract class AbstractController
|
|||
*/
|
||||
protected boolean isBlank(String s)
|
||||
{
|
||||
if (s == null)
|
||||
return true;
|
||||
|
||||
if (s.isEmpty())
|
||||
return true;
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return StringUtil.isBlank(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.datagear.dbmodel.ModelSqlSelectService.ModelSqlResult;
|
|||
import org.datagear.management.domain.Schema;
|
||||
import org.datagear.management.domain.User;
|
||||
import org.datagear.management.service.SchemaService;
|
||||
import org.datagear.management.service.SqlHistoryService;
|
||||
import org.datagear.util.IDUtil;
|
||||
import org.datagear.util.IOUtil;
|
||||
import org.datagear.util.SqlScriptParser;
|
||||
|
@ -73,6 +74,9 @@ public class SqlpadController extends AbstractSchemaConnController
|
|||
@Autowired
|
||||
private DatabaseInfoResolver databaseInfoResolver;
|
||||
|
||||
@Autowired
|
||||
private SqlHistoryService sqlHistoryService;
|
||||
|
||||
public SqlpadController()
|
||||
{
|
||||
super();
|
||||
|
@ -81,13 +85,14 @@ public class SqlpadController extends AbstractSchemaConnController
|
|||
public SqlpadController(MessageSource messageSource, ClassDataConverter classDataConverter,
|
||||
SchemaService schemaService, ConnectionSource connectionSource, ModelSqlSelectService modelSqlSelectService,
|
||||
DatabaseModelResolver databaseModelResolver, SqlpadExecutionService sqlpadExecutionService,
|
||||
DatabaseInfoResolver databaseInfoResolver)
|
||||
DatabaseInfoResolver databaseInfoResolver, SqlHistoryService sqlHistoryService)
|
||||
{
|
||||
super(messageSource, classDataConverter, schemaService, connectionSource);
|
||||
this.modelSqlSelectService = modelSqlSelectService;
|
||||
this.databaseModelResolver = databaseModelResolver;
|
||||
this.sqlpadExecutionService = sqlpadExecutionService;
|
||||
this.databaseInfoResolver = databaseInfoResolver;
|
||||
this.sqlHistoryService = sqlHistoryService;
|
||||
}
|
||||
|
||||
public ModelSqlSelectService getModelSqlSelectService()
|
||||
|
@ -130,6 +135,16 @@ public class SqlpadController extends AbstractSchemaConnController
|
|||
this.databaseInfoResolver = databaseInfoResolver;
|
||||
}
|
||||
|
||||
public SqlHistoryService getSqlHistoryService()
|
||||
{
|
||||
return sqlHistoryService;
|
||||
}
|
||||
|
||||
public void setSqlHistoryService(SqlHistoryService sqlHistoryService)
|
||||
{
|
||||
this.sqlHistoryService = sqlHistoryService;
|
||||
}
|
||||
|
||||
@RequestMapping("/{schemaId}")
|
||||
public String index(HttpServletRequest request, HttpServletResponse response,
|
||||
org.springframework.ui.Model springModel, @PathVariable("schemaId") String schemaId) throws Throwable
|
||||
|
|
|
@ -299,6 +299,10 @@
|
|||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="sqlHistoryService" class="org.datagear.management.service.impl.SqlHistoryServiceImpl">
|
||||
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="sqlDateFormatter" class="org.datagear.web.format.SqlDateFormatter" />
|
||||
<bean id="sqlTimeFormatter" class="org.datagear.web.format.SqlTimeFormatter" />
|
||||
<bean id="sqlTimestampFormatter" class="org.datagear.web.format.SqlTimestampFormatter" />
|
||||
|
|
|
@ -65,6 +65,10 @@ id=ID
|
|||
confirmDelete=\u786E\u5B9A\u5220\u9664\u9009\u4E2D\u6761\u76EE\u5417\uFF1F
|
||||
anonymousUser=\u533F\u540D\u7528\u6237
|
||||
authorize=\u6388\u6743
|
||||
prevPage=\u4E0A\u4E00\u9875
|
||||
nextPage=\u4E0B\u4E00\u9875
|
||||
loadMore=\u52A0\u8F7D\u66F4\u591A
|
||||
|
||||
|
||||
dataTables.noData=\u6CA1\u6709\u6570\u636E
|
||||
dataTables.zeroRecords=\u6CA1\u6709\u7ED3\u679C
|
||||
|
|
|
@ -31,12 +31,10 @@ Schema schema 数据库,不允许为null
|
|||
<input id="sqlDelimiterInput" type="text" class="sql-delimiter-input ui-widget ui-widget-content ui-corner-all" value=";" title="<@spring.message code='sqlpad.sqlDelimiter' />"/>
|
||||
<button id="insertSqlDelimiterDefineButton" class="ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='sqlpad.insertSqlDelimiterDefine' />"><span class="ui-button-icon ui-icon ui-icon-grip-dotted-horizontal"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.insertSqlDelimiterDefine' /></button>
|
||||
<button id="insertSqlDelimiterButton" class="ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='sqlpad.insertSqlDelimiter' />"><span class="ui-button-icon ui-icon ui-icon-grip-solid-horizontal"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.insertSqlDelimiter' /></button>
|
||||
<div class="button-divider ui-widget ui-widget-content"></div>
|
||||
<button id="viewSqlHistoryButton" class="ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='sqlpad.viewSqlHistory' />"><span class="ui-button-icon ui-icon ui-icon-clock"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.viewSqlHistory' /></button>
|
||||
<div class="more-operation-wrapper">
|
||||
<button id="moreOperationButton" class="ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='sqlpad.moreOperation' />"><span class="ui-button-icon ui-icon ui-icon-caret-1-s"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.moreOperation' /></button>
|
||||
<div class="more-operation-panel ui-widget ui-widget-content ui-corner-all ui-widget-shadow ui-front">
|
||||
<form id="moreOperationForm" method="POST" action="#">
|
||||
<div class="setting-wrapper">
|
||||
<button id="settingButton" class="ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='sqlpad.moreOperation' />"><span class="ui-button-icon ui-icon ui-icon-caret-1-s"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.moreOperation' /></button>
|
||||
<div class="setting-panel ui-widget ui-widget-content ui-corner-all ui-widget-shadow ui-front">
|
||||
<form id="settingForm" method="POST" action="#">
|
||||
<div class="form-content">
|
||||
<div class="form-item">
|
||||
<div class="form-item-label"><label><@spring.message code='sqlpad.sqlCommitMode' /></label></div>
|
||||
|
@ -74,6 +72,46 @@ Schema schema 数据库,不允许为null
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="view-sql-history-wrapper">
|
||||
<button id="viewSqlHistoryButton" class="ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='sqlpad.viewSqlHistory' />"><span class="ui-button-icon ui-icon ui-icon-clock"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.viewSqlHistory' /></button>
|
||||
<div class="view-sql-history-panel ui-widget ui-widget-content ui-corner-all ui-widget-shadow ui-front">
|
||||
<form id="viewSqlHistorySearchForm" method="POST" action="#">
|
||||
<div class="form-content">
|
||||
<div class="form-item">
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="keyword" value="" class="ui-widget ui-widget-content" maxlength="50" />
|
||||
<button type="submit"><@spring.message code='query' /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="sql-history-list ui-widget ui-widget-content">
|
||||
<div class="sql-item">
|
||||
<div class="sql-date">09-19 16:24:10</div>
|
||||
<div class="sql-content">SELECT * FROM t_auto_generated_keys where id = 1 and name = '2'</div>
|
||||
</div>
|
||||
<div class="sql-item">
|
||||
<div class="sql-date">09-19 16:24:10</div>
|
||||
<div class="sql-content">SELECT * FROM t_auto_generated_keys where id = 1 and name = '2'</div>
|
||||
</div>
|
||||
<div class="sql-item">
|
||||
<div class="sql-date">09-19 16:24:10</div>
|
||||
<div class="sql-content">SELECT * FROM t_auto_generated_keys where id = 1 and name = '2'</div>
|
||||
</div>
|
||||
<div class="sql-item">
|
||||
<div class="sql-date">09-19 16:24:10</div>
|
||||
<div class="sql-content">SELECT * FROM t_auto_generated_keys;</div>
|
||||
</div>
|
||||
<div class="sql-item">
|
||||
<div class="sql-date">09-19 16:24:10</div>
|
||||
<div class="sql-content">SELECT * FROM t_auto_generated_keys;</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sql-history-foot">
|
||||
<button id="sqlHistoryLoadMoreButton" class="ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='loadMore' />"><span class="ui-button-icon ui-icon ui-icon-arrowthick-1-s"></span><span class="ui-button-icon-space"> </span><@spring.message code='loadMore' /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content ui-widget ui-widget-content">
|
||||
<div class="content-editor">
|
||||
|
@ -720,7 +758,7 @@ Schema schema 数据库,不允许为null
|
|||
{
|
||||
beforeSerialize: function($form, options)
|
||||
{
|
||||
var fetchSize = po.getResultsetFetchSize(po.element("#moreOperationForm"));
|
||||
var fetchSize = po.getResultsetFetchSize(po.element("#settingForm"));
|
||||
$("input[name='fetchSize']", $form).val(fetchSize);
|
||||
},
|
||||
success : function(modelSqlResult, statusText, xhr, $form)
|
||||
|
@ -950,12 +988,12 @@ Schema schema 数据库,不允许为null
|
|||
if(!sql)
|
||||
return;
|
||||
|
||||
var moreOperationForm = po.element("#moreOperationForm");
|
||||
var settingForm = po.element("#settingForm");
|
||||
|
||||
var commitMode = po.element("input[name='sqlCommitMode']:checked", moreOperationForm).val();
|
||||
var exceptionHandleMode = po.element("input[name='sqlExceptionHandleMode']:checked", moreOperationForm).val();
|
||||
var overTimeThreashold = po.getOverTimeThreashold(moreOperationForm);
|
||||
var resultsetFetchSize = po.getResultsetFetchSize(moreOperationForm);
|
||||
var commitMode = po.element("input[name='sqlCommitMode']:checked", settingForm).val();
|
||||
var exceptionHandleMode = po.element("input[name='sqlExceptionHandleMode']:checked", settingForm).val();
|
||||
var overTimeThreashold = po.getOverTimeThreashold(settingForm);
|
||||
var resultsetFetchSize = po.getResultsetFetchSize(settingForm);
|
||||
|
||||
po.updateExecuteSqlButtonState($this, "executing");
|
||||
|
||||
|
@ -1036,9 +1074,26 @@ Schema schema 数据库,不允许为null
|
|||
po.sqlEditor.focus();
|
||||
});
|
||||
|
||||
po.element("#moreOperationButton").click(function()
|
||||
po.element("#viewSqlHistoryButton").click(function()
|
||||
{
|
||||
po.element(".more-operation-panel").toggle();
|
||||
var $vhp = po.element(".view-sql-history-panel");
|
||||
|
||||
if(!$vhp.is(":hidden"))
|
||||
{
|
||||
$vhp.hide();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
var $shl = po.element(".sql-history-list");
|
||||
$shl.height(po.element().height()/2.5);
|
||||
$vhp.show();
|
||||
}
|
||||
});
|
||||
|
||||
po.element("#settingButton").click(function()
|
||||
{
|
||||
po.element(".setting-panel").toggle();
|
||||
});
|
||||
|
||||
po.element("input[name='sqlCommitMode']").change(function()
|
||||
|
@ -1114,6 +1169,14 @@ Schema schema 数据库,不允许为null
|
|||
{
|
||||
var $this = $(this);
|
||||
|
||||
var viewSqlStatementPanel = po.element("#viewSqlStatementPanel");
|
||||
|
||||
if(!viewSqlStatementPanel.is(":hidden"))
|
||||
{
|
||||
viewSqlStatementPanel.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
var tabsNav = po.getTabsNav(po.sqlResultTabs);
|
||||
var activeTab = po.getActiveTab(po.sqlResultTabs, tabsNav);
|
||||
|
||||
|
@ -1124,7 +1187,6 @@ Schema schema 数据库,不允许为null
|
|||
var tabForm = po.element("#" + tabId);
|
||||
var sql = $("textarea[name='sql']", tabForm).val();
|
||||
|
||||
var viewSqlStatementPanel = po.element("#viewSqlStatementPanel");
|
||||
$("textarea", viewSqlStatementPanel).val(sql);
|
||||
viewSqlStatementPanel.show().position({ my : "right bottom", at : "right top-5", of : $this});
|
||||
}
|
||||
|
@ -1155,7 +1217,7 @@ Schema schema 数据库,不允许为null
|
|||
}
|
||||
});
|
||||
|
||||
po.element("#moreOperationForm").validate(
|
||||
po.element("#settingForm").validate(
|
||||
{
|
||||
rules :
|
||||
{
|
||||
|
@ -1180,12 +1242,19 @@ Schema schema 数据库,不允许为null
|
|||
$(document.body).on("click", function(event)
|
||||
{
|
||||
var $target = $(event.target);
|
||||
|
||||
var $mop = po.element(".more-operation-panel");
|
||||
if(!$mop.is(":hidden"))
|
||||
|
||||
var $vhp = po.element(".view-sql-history-panel");
|
||||
if(!$vhp.is(":hidden"))
|
||||
{
|
||||
if($target.closest(po.element(".more-operation-wrapper")).length == 0)
|
||||
$mop.hide();
|
||||
if($target.closest(po.element(".view-sql-history-wrapper")).length == 0)
|
||||
$vhp.hide();
|
||||
}
|
||||
|
||||
var $sp = po.element(".setting-panel");
|
||||
if(!$sp.is(":hidden"))
|
||||
{
|
||||
if($target.closest(po.element(".setting-wrapper")).length == 0)
|
||||
$sp.hide();
|
||||
}
|
||||
|
||||
var $vsp = po.element("#viewSqlStatementPanel");
|
||||
|
@ -1267,7 +1336,8 @@ Schema schema 数据库,不允许为null
|
|||
});
|
||||
|
||||
po.element("input[name='sqlCommitMode'][value='AUTO']").click();
|
||||
po.element(".more-operation-panel").hide();
|
||||
po.element(".view-sql-history-panel").hide();
|
||||
po.element(".setting-panel").hide();
|
||||
po.element(".result-operations .sql-result-buttons").hide();
|
||||
po.element("#viewSqlStatementPanel").hide();
|
||||
po.element("#viewLongTextResultPanel").hide();
|
||||
|
|
|
@ -1316,32 +1316,58 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
|
|||
padding-left: 0.2em;
|
||||
padding-right: 0.2em;
|
||||
}
|
||||
.page-sqlpad .head .more-operation-wrapper{
|
||||
.page-sqlpad .head .view-sql-history-wrapper{
|
||||
float: right;
|
||||
width: 10%;
|
||||
width: 5%;
|
||||
text-align: right;
|
||||
position: relative;
|
||||
}
|
||||
.page-sqlpad .head .more-operation-wrapper > button.ui-button{
|
||||
.page-sqlpad .head .view-sql-history-wrapper .view-sql-history-panel{
|
||||
position: absolute;
|
||||
right: 0.1em;
|
||||
top: 1.2em;
|
||||
width: 800%;
|
||||
min-height: 3em;
|
||||
text-align: left;
|
||||
padding: 0.41em 1em;
|
||||
}
|
||||
.page-sqlpad .head .view-sql-history-wrapper .view-sql-history-panel .sql-history-list{
|
||||
overflow-y: auto;
|
||||
}
|
||||
.page-sqlpad .head .view-sql-history-wrapper .view-sql-history-panel .sql-history-list .sql-item{
|
||||
padding: 0.2em 0.2em;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.page-sqlpad .head .view-sql-history-wrapper .view-sql-history-panel .sql-history-foot{
|
||||
padding-top: 0.3em;
|
||||
text-align: right;
|
||||
}
|
||||
.page-sqlpad .head .setting-wrapper{
|
||||
float: right;
|
||||
width: 5%;
|
||||
text-align: right;
|
||||
position: relative;
|
||||
}
|
||||
.page-sqlpad .head .setting-wrapper > button.ui-button{
|
||||
width: 1.5em;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
.page-sqlpad .head .more-operation-wrapper .more-operation-panel{
|
||||
.page-sqlpad .head .setting-wrapper .setting-panel{
|
||||
position: absolute;
|
||||
right: 0.1em;
|
||||
top: 1.1em;
|
||||
width: 450%;
|
||||
top: 1.2em;
|
||||
width: 900%;
|
||||
text-align: left;
|
||||
padding: 0.41em 1em;
|
||||
}
|
||||
.page-sqlpad .head .more-operation-wrapper .more-operation-panel form .form-content .form-item .form-item-label{
|
||||
.page-sqlpad .head .setting-wrapper .setting-panel form .form-content .form-item .form-item-label{
|
||||
width: 35%;
|
||||
}
|
||||
.page-sqlpad .head .more-operation-wrapper .more-operation-panel form .form-content .form-item .form-item-value{
|
||||
.page-sqlpad .head .setting-wrapper .setting-panel form .form-content .form-item .form-item-value{
|
||||
width: auto;
|
||||
}
|
||||
.page-sqlpad .head .more-operation-wrapper .more-operation-panel .ui-checkboxradio-icon{
|
||||
.page-sqlpad .head .setting-wrapper .setting-panel .ui-checkboxradio-icon{
|
||||
display: none;
|
||||
}
|
||||
.page-sqlpad .content{
|
||||
|
|
Loading…
Reference in New Issue