Search in sources :

Example 6 with PageRowBounds

use of com.github.pagehelper.PageRowBounds in project Mybatis-PageHelper by pagehelper.

the class AbstractHelperDialect method afterCount.

@Override
public boolean afterCount(long count, Object parameterObject, RowBounds rowBounds) {
    Page page = getLocalPage();
    page.setTotal(count);
    if (rowBounds instanceof PageRowBounds) {
        ((PageRowBounds) rowBounds).setTotal(count);
    }
    // pageSize = 0 的时候,还需要执行后续查询,但是不会分页
    if (page.getPageSizeZero() != null) {
        // PageSizeZero=false&&pageSize<=0
        if (!page.getPageSizeZero() && page.getPageSize() <= 0) {
            return false;
        } else // PageSizeZero=true&&pageSize<0 返回 false,只有>=0才需要执行后续的
        if (page.getPageSizeZero() && page.getPageSize() < 0) {
            return false;
        }
    }
    // 页码>0 && 开始行数<总行数即可,不需要考虑 pageSize(上面的 if 已经处理不符合要求的值了)
    return page.getPageNum() > 0 && count > page.getStartRow();
}
Also used : PageRowBounds(com.github.pagehelper.PageRowBounds) Page(com.github.pagehelper.Page)

Aggregations

PageRowBounds (com.github.pagehelper.PageRowBounds)6 User (com.github.pagehelper.model.User)4 SqlSession (org.apache.ibatis.session.SqlSession)4 Test (org.junit.Test)4 Page (com.github.pagehelper.Page)2 UserMapper (com.github.pagehelper.mapper.UserMapper)2 IPage (com.github.pagehelper.IPage)1 HashMap (java.util.HashMap)1