package com.sunwin.robot2ips.util;

import com.github.pagehelper.PageInfo;

import java.util.List;
import java.util.Map;

/**
 * @Description: 自定义分页类（解决pageHelper返回结果需要封装出错问题）
 * @Author: shiwn
 * @Date: 2020/3/13 13:40
 */
public class PageInfoUtil {
    /**
     * @Description: 包装PageHelper对象对象
     * @Param: [pageOrg]
     * @Author: shiwn
     * @Date: 2020/3/13 14:03
     */
    public static PageInfo<Map> PageInfoMap(PageInfo pageOrg, List list) {
        PageInfo<Map> pageInfo = new PageInfo<>();
        pageInfo.setPageNum(pageOrg.getPageNum());
        pageInfo.setPageSize(pageOrg.getPageSize());
        pageInfo.setSize(pageOrg.getSize());
        pageInfo.setStartRow(pageOrg.getStartRow());
        pageInfo.setEndRow(pageOrg.getEndRow());

        pageInfo.setPages(pageOrg.getPages());
        pageInfo.setPrePage(pageOrg.getPrePage());
        pageInfo.setNextPage(pageOrg.getNextPage());

        pageInfo.setIsFirstPage(pageOrg.isIsFirstPage());
        pageInfo.setIsLastPage(pageOrg.isIsLastPage());

        pageInfo.setNavigateFirstPage(pageOrg.getNavigateFirstPage());
        pageInfo.setNavigateLastPage(pageOrg.getNavigateLastPage());


        pageInfo.setTotal(pageOrg.getTotal());
        pageInfo.setList(list);
        return pageInfo;
    }
}
