使用PageHelper做分页,查询结果List实际是Page对象(class Page extends ArrayList)

 

public PageInfo(List list, int navigatePages) {
    this.isFirstPage = false;
    this.isLastPage = false;
    this.hasPreviousPage = false;
    this.hasNextPage = false;
    if (list instanceof Page) {
    
        Page page = (Page)list;
        this.pageNum = page.getPageNum();
        this.pageSize = page.getPageSize();
        this.orderBy = page.getOrderBy();
        this.pages = page.getPages();
        this.list = page;
        this.size = page.size();
        this.total = page.getTotal();
        if (this.size == 0) {
            this.startRow = 0;
            this.endRow = 0;
        } else {
            this.startRow = page.getStartRow() + 1;
            this.endRow = this.startRow - 1 + this.size;
        }
    } else if (list instanceof Collection) {
    
        this.pageNum = 1;
        this.pageSize = list.size();
        this.pages = 1;
        this.list = list;
        this.size = list.size();
        this.total = (long)list.size();
        this.startRow = 0;
        this.endRow = list.size() > 0 ? list.size() - 1 : 0;
    }

    if (list instanceof Collection) {
        this.navigatePages = navigatePages;
        this.calcNavigatepageNums();
        this.calcPage();
        this.judgePageBoudary();
    }

}

你可能感兴趣的:(使用PageHelper做分页,查询结果List实际是Page对象(class Page extends ArrayList))