Class AbstractPaging

java.lang.Object
org.miaixz.bus.pager.dialect.AbstractDialect
org.miaixz.bus.pager.dialect.AbstractPaging
All Implemented Interfaces:
Dialect
Direct Known Subclasses:
AS400, CirroData, Db2, Firebird, HerdDB, Hsqldb, Informix, MySql, Oracle, Oracle9i, Oscar, PostgreSql, SqlServer

public abstract class AbstractPaging extends AbstractDialect
针对 PageContext 的实现
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
    第一个分页参数
    static String
    第二个分页参数
    static String
    count查询的id后缀
    static String
    分页的id后缀

    Fields inherited from class org.miaixz.bus.pager.dialect.AbstractDialect

    countSqlParser, orderBySqlParser
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    完成所有任务后
    boolean
    afterCount(long count, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    执行完 count 查询后
    afterPage(List pageList, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    分页查询后,处理分页结果,拦截器中直接 return 该方法的返回值
    boolean
    beforeCount(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    执行分页前,返回 true 会进行 count 查询,false 会继续下面的 beforePage 判断
    boolean
    beforePage(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    执行分页前,返回 true 会进行分页查询,false 会返回默认查询结果
    getCountSql(org.apache.ibatis.mapping.MappedStatement ms, org.apache.ibatis.mapping.BoundSql boundSql, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey countKey)
    生成 count 查询 sql
    <T> Page<T>
    获取分页参数
    abstract String
    getPageSql(String sql, Page page, org.apache.ibatis.cache.CacheKey pageKey)
    单独处理分页部分
    getPageSql(org.apache.ibatis.mapping.MappedStatement ms, org.apache.ibatis.mapping.BoundSql boundSql, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey pageKey)
    生成分页查询 sql
    protected void
    handleParameter(org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.mapping.MappedStatement ms, Class<?> firstClass, Class<?> secondClass)
     
    abstract Object
    processPageParameter(org.apache.ibatis.mapping.MappedStatement ms, Map<String,Object> paramMap, Page page, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey)
    处理分页参数
    processParameterObject(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey)
    处理查询参数对象
    void
    设置参数
    final boolean
    skip(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    跳过 count 和 分页查询

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.miaixz.bus.pager.Dialect

    asyncCountTask, isAsyncCount
  • Field Details

    • SUFFIX_PAGE

      public static String SUFFIX_PAGE
      分页的id后缀
    • SUFFIX_COUNT

      public static String SUFFIX_COUNT
      count查询的id后缀
    • PAGEPARAMETER_FIRST

      public static String PAGEPARAMETER_FIRST
      第一个分页参数
    • PAGEPARAMETER_SECOND

      public static String PAGEPARAMETER_SECOND
      第二个分页参数
  • Constructor Details

    • AbstractPaging

      public AbstractPaging()
  • Method Details

    • getLocalPage

      public <T> Page<T> getLocalPage()
      获取分页参数
      Type Parameters:
      T - 对象
      Returns:
      结果
    • skip

      public final boolean skip(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Description copied from interface: Dialect
      跳过 count 和 分页查询
      Parameters:
      ms - MappedStatement
      parameterObject - 方法参数
      rowBounds - 分页参数
      Returns:
      true 跳过,返回默认查询结果,false 执行分页查询
    • beforeCount

      public boolean beforeCount(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Description copied from interface: Dialect
      执行分页前,返回 true 会进行 count 查询,false 会继续下面的 beforePage 判断
      Parameters:
      ms - MappedStatement
      parameterObject - 方法参数
      rowBounds - 分页参数
      Returns:
      the object
    • getCountSql

      public String getCountSql(org.apache.ibatis.mapping.MappedStatement ms, org.apache.ibatis.mapping.BoundSql boundSql, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey countKey)
      Description copied from interface: Dialect
      生成 count 查询 sql
      Specified by:
      getCountSql in interface Dialect
      Overrides:
      getCountSql in class AbstractDialect
      Parameters:
      ms - MappedStatement
      boundSql - 绑定 SQL 对象
      parameterObject - 方法参数
      rowBounds - 分页参数
      countKey - count 缓存 key
      Returns:
      the object
    • afterCount

      public boolean afterCount(long count, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Description copied from interface: Dialect
      执行完 count 查询后
      Parameters:
      count - 查询结果总数
      parameterObject - 接口参数
      rowBounds - 分页参数
      Returns:
      true 继续分页查询,false 直接返回
    • processParameterObject

      public Object processParameterObject(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey)
      Description copied from interface: Dialect
      处理查询参数对象
      Parameters:
      ms - MappedStatement
      parameterObject - 方法参数
      boundSql - 绑定 SQL 对象
      pageKey - 分页缓存 key
      Returns:
      the object
    • processPageParameter

      public abstract Object processPageParameter(org.apache.ibatis.mapping.MappedStatement ms, Map<String,Object> paramMap, Page page, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey)
      处理分页参数
      Parameters:
      ms - MappedStatement
      paramMap - Map
      page - Page
      boundSql - BoundSql
      pageKey - CacheKey
      Returns:
      结果
    • beforePage

      public boolean beforePage(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Description copied from interface: Dialect
      执行分页前,返回 true 会进行分页查询,false 会返回默认查询结果
      Parameters:
      ms - MappedStatement
      parameterObject - 方法参数
      rowBounds - 分页参数
      Returns:
      the object
    • getPageSql

      public String getPageSql(org.apache.ibatis.mapping.MappedStatement ms, org.apache.ibatis.mapping.BoundSql boundSql, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey pageKey)
      Description copied from interface: Dialect
      生成分页查询 sql
      Parameters:
      ms - MappedStatement
      boundSql - 绑定 SQL 对象
      parameterObject - 方法参数
      rowBounds - 分页参数
      pageKey - 分页缓存 key
      Returns:
      the object
    • getPageSql

      public abstract String getPageSql(String sql, Page page, org.apache.ibatis.cache.CacheKey pageKey)
      单独处理分页部分
      Parameters:
      sql - sql
      page - Page
      pageKey - CacheKey
      Returns:
      the string
    • afterPage

      public Object afterPage(List pageList, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Description copied from interface: Dialect
      分页查询后,处理分页结果,拦截器中直接 return 该方法的返回值
      Parameters:
      pageList - 分页查询结果
      parameterObject - 方法参数
      rowBounds - 分页参数
      Returns:
      the object
    • afterAll

      public void afterAll()
      Description copied from interface: Dialect
      完成所有任务后
    • setProperties

      public void setProperties(Properties properties)
      Description copied from interface: Dialect
      设置参数
      Specified by:
      setProperties in interface Dialect
      Overrides:
      setProperties in class AbstractDialect
      Parameters:
      properties - 插件属性
    • handleParameter

      protected void handleParameter(org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.mapping.MappedStatement ms, Class<?> firstClass, Class<?> secondClass)
      Parameters:
      boundSql - boundSql
      ms - MappedStatement
      firstClass - 第一个分页参数
      secondClass - 第二个分页参数