package com.ruoyi.common.page;


import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

public class PageUtil {

    /**
     *
     * @param list 返回数据
     * @param totalList 计算总数据量的数据
     * @return
     */
    public static TableDataInfo getTableDataInfo(List list, List totalList){
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setRows(list);
        rspData.setMsg("查询成功");
        if(totalList==null){
            rspData.setTotal(Integer.valueOf(new PageInfo(list).getTotal() + ""));
        }else {
            rspData.setTotal(Integer.valueOf(new PageInfo(totalList).getTotal()+""));
        }
        return rspData;
    }
}
