91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 66KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-05
  • 語言: 其他
  • 標簽: mybati??

資源簡介

結合這篇文章使用, 保證原創. https://blog.csdn.net/super_sys/article/details/88371496

資源截圖

代碼片段和文件信息

package?org.mybatis.plugin;

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?org.apache.commons.lang3.StringUtils;
import?org.apache.ibatis.executor.ErrorContext;
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.Systemmetaobject;
import?org.apache.ibatis.scripting.xmltags.ForEachSqlNode;
import?org.apache.ibatis.session.Configuration;
import?org.apache.ibatis.type.JdbcType;
import?org.apache.ibatis.type.TypeException;
import?org.apache.ibatis.type.TypeHandler;
import?org.apache.ibatis.type.TypeHandlerRegistry;
import?org.mybatis.plugin.exception.PluginPropertyUndefinedException;
import?org.mybatis.plugin.model.DBTypeEnum;
import?org.mybatis.plugin.model.QueryParam;
import?org.mybatis.plugin.util.GenMysqlCountUtil;
import?org.mybatis.plugin.util.ReflectUtil;

@Intercepts({
@Signature(type?=?StatementHandler.class?method?=?“prepare“?args?=?{?Connection.class?Integer.class?})?})
public?class?PagePlugin?implements?Interceptor?{

/**?數據庫方言?*/
private?static?String?dialect?=?““;

/**?mapper.xml中需要攔截的ID(正則匹配)?*/
private?static?String?pageSqlId?=?““;

public?object?intercept(Invocation?ivk)?throws?Throwable?{

if?(!(ivk.getTarget()?instanceof?RoutingStatementHandler))?{
return?ivk.proceed();
}

RoutingStatementHandler?statementHandler?=?(RoutingStatementHandler)?ivk.getTarget();
baseStatementHandler?delegate?=?(baseStatementHandler)?ReflectUtil.getValueByFieldName(statementHandler
“delegate“);
MappedStatement?mappedStatement?=?(MappedStatement)?ReflectUtil.getValueByFieldName(delegate
“mappedStatement“);

//?只攔截需要分頁的SQL
if?(!mappedStatement.getId().matches(pageSqlId))?{
return?ivk.proceed();
}

BoundSql?boundSql?=?delegate.getBoundSql();
//?分頁SQL

共有 條評論