package com.brilliance.isc.common.vo;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

@Data
public class CommonResult<T> {
    private Integer pageNumber;
    private Integer pageSize;
    private Integer totalPage;
    private List<T> list;
    private long total;

    public static <T> CommonResult<T> restPage(List<T> pageInfo) {
        CommonResult<T> commonResult = new CommonResult<T>();
        PageInfo<T> page = new PageInfo<>(pageInfo);
        // 页码数
        commonResult.setPageNumber(page.getPageNum());
        // 每页显示条数
        commonResult.setPageSize(page.getPageSize());
        // 总页数
        commonResult.setTotalPage(page.getPages());
        // 总条数
        commonResult.setTotal(page.getTotal());
        // 每页显示的数据详情
        commonResult.setList(page.getList());
        return commonResult;
    }
}
