package com.srs.dormitory.utils;

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

import java.util.List;

public class PageUtil {

    public PageUtil() {
    }


    @SuppressWarnings({"rawtypes", "unchecked"})
    public static TableDataInfo getDataTable(List<?> list, List<?> total) {
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list);
        if (total == null) {
            rspData.setTotal(new PageInfo(list).getTotal());
            return rspData;
        }
        rspData.setTotal(new PageInfo(total).getTotal());
        return rspData;
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public static TableDataInfo getDataTable(List<?> list) {
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list);
        rspData.setTotal(new PageInfo(list).getTotal());
        return rspData;
    }
}
