diff --git a/src/main/java/com/ruoyi/framework/mybatis/ExecutorPageMethodInterceptor.java b/src/main/java/com/ruoyi/framework/mybatis/ExecutorPageMethodInterceptor.java new file mode 100644 index 000000000..aa5acc617 --- /dev/null +++ b/src/main/java/com/ruoyi/framework/mybatis/ExecutorPageMethodInterceptor.java @@ -0,0 +1,259 @@ +package com.ruoyi.framework.mybatis; + +import java.lang.reflect.Field; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Properties; +import javax.xml.bind.PropertyException; +import org.apache.ibatis.executor.ErrorContext; +import org.apache.ibatis.executor.ExecutorException; +import org.apache.ibatis.executor.statement.BaseStatementHandler; +import org.apache.ibatis.executor.statement.RoutingStatementHandler; +import org.apache.ibatis.executor.statement.StatementHandler; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.ParameterMapping; +import org.apache.ibatis.mapping.ParameterMode; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.plugin.Intercepts; +import org.apache.ibatis.plugin.Invocation; +import org.apache.ibatis.plugin.Plugin; +import org.apache.ibatis.plugin.Signature; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.property.PropertyTokenizer; +import org.apache.ibatis.scripting.xmltags.ForEachSqlNode; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.type.TypeHandler; +import org.apache.ibatis.type.TypeHandlerRegistry; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.web.page.PageUtilEntity; + +/**三 + * 拦截需要分页SQL + * + * @author yangzz + */ +@Intercepts({ @Signature(type = StatementHandler.class, method = "prepare", args = { Connection.class, Integer.class }) }) +public class ExecutorPageMethodInterceptor implements Interceptor +{ + + private static String dialect = ""; // 数据库方言 + private static String pageSqlId = ""; // mapper.xml中需要拦截的ID(正则匹配) + + @Override + public Object intercept(Invocation ivk) throws Throwable + { + // TODO Auto-generated method stub + if (ivk.getTarget() instanceof RoutingStatementHandler) + { + RoutingStatementHandler statementHandler = (RoutingStatementHandler) ivk.getTarget(); + BaseStatementHandler delegate = (BaseStatementHandler) ReflectHelper.getValueByFieldName(statementHandler, + "delegate"); + MappedStatement mappedStatement = (MappedStatement) ReflectHelper.getValueByFieldName(delegate, + "mappedStatement"); + + if (mappedStatement.getId().matches(pageSqlId)) + { // 拦截需要分页的SQL + BoundSql boundSql = delegate.getBoundSql(); + Object parameterObject = boundSql.getParameterObject();// 分页SQL + diff --git a/src/main/resources/static/ajax/libs/bootstrap-table/page/bootstrap-page.js b/src/main/resources/static/ajax/libs/bootstrap-table/page/bootstrap-page.js index 347d9deea..629e4682e 100644 --- a/src/main/resources/static/ajax/libs/bootstrap-table/page/bootstrap-page.js +++ b/src/main/resources/static/ajax/libs/bootstrap-table/page/bootstrap-page.js @@ -1,3 +1,6 @@ +// 自定义分页处理 ruoyi + +// 初始化表格 function initTable(_columns, _url) { $('.bootstrap-table').bootstrapTable({ method: 'GET', @@ -30,6 +33,14 @@ function initTable(_columns, _url) { }); } +// 刷新 function refresh() { $('.bootstrap-table').bootstrapTable('refresh'); +} + +// 获取选中数组 +function getIdSelections(_id) { + return $.map($('.bootstrap-table').bootstrapTable('getSelections'), function (row) { + return row[_id] + }); } \ No newline at end of file diff --git a/src/main/resources/static/ruoyi/js/common.js b/src/main/resources/static/ruoyi/js/index.js similarity index 100% rename from src/main/resources/static/ruoyi/js/common.js rename to src/main/resources/static/ruoyi/js/index.js diff --git a/src/main/resources/static/js/appjs/monitor/online/online.js b/src/main/resources/static/ruoyi/monitor/online/online.js similarity index 66% rename from src/main/resources/static/js/appjs/monitor/online/online.js rename to src/main/resources/static/ruoyi/monitor/online/online.js index 851c7846c..9133c614d 100644 --- a/src/main/resources/static/js/appjs/monitor/online/online.js +++ b/src/main/resources/static/ruoyi/monitor/online/online.js @@ -63,34 +63,42 @@ $(function() { }); function forceLogout(id) { - layer.confirm('确定要强制选中用户下线吗?', { - btn: ['确定', '取消'] - }, - function() { + layer.confirm("确定要强制选中用户下线吗?",{icon: 3, title:'提示'},function(index){ $.ajax({ url: prefix + "/forceLogout/" + id, type: "post", - data: { - 'id': id - }, + data: { 'id': id }, success: function(r) { if (r.code == 0) { - layer.msg(r.msg); + layer.msg(r.msg, { icon: 1, time: 1000 }); refresh(); } else { - layer.msg(r.msg); + layer.alert(r.msg, {icon: 2, title:"系统提示"}); } } }); }) } -function addTest() -{ - alert("addTest"); +function batchForceLogout() { + var rows = getIdSelections("sessionId"); + if (rows.length == 0) { + layer.msg("请选择要删除的数据"); + return; + } + layer.confirm("确认要删除选中的" + rows.length + "条数据吗?",{icon: 3, title:'提示'},function(index){ + $.ajax({ + type: 'POST', + data: { "ids": rows }, + url: prefix + '/batchForceLogout', + success: function(r) { + if (r.code == 0) { + layer.msg(r.msg, { icon: 1, time: 1000 }); + refresh(); + } else { + layer.alert(r.msg, {icon: 2, title:"系统提示"}); + } + } + }); + }); } - -function batDelTest() -{ - alert("batDelTest"); -} \ No newline at end of file diff --git a/src/main/resources/static/js/appjs/system/user/rmk.txt b/src/main/resources/static/ruoyi/system/user/rmk.txt similarity index 100% rename from src/main/resources/static/js/appjs/system/user/rmk.txt rename to src/main/resources/static/ruoyi/system/user/rmk.txt diff --git a/src/main/resources/templates/include.html b/src/main/resources/templates/include.html index 3496942cc..d9dc19dae 100644 --- a/src/main/resources/templates/include.html +++ b/src/main/resources/templates/include.html @@ -13,7 +13,7 @@ - + @@ -36,7 +36,6 @@ - diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index f9d99611a..6744faa8f 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -127,6 +127,6 @@ - + diff --git a/src/main/resources/templates/monitor/online/online.html b/src/main/resources/templates/monitor/online/online.html index 4ef7d9691..20bbaa88e 100644 --- a/src/main/resources/templates/monitor/online/online.html +++ b/src/main/resources/templates/monitor/online/online.html @@ -5,13 +5,14 @@
- @@ -23,6 +24,6 @@
- + \ No newline at end of file