package com.skr.mdm.util;

import com.github.pagehelper.PageInfo;
import com.skr.mdm.bean.vo.PageResultVO;

import java.util.List;

/**
 * @author nfq
 * @date 2020/8/27 16:26
 */
public class PageUtil {

    public static PageResultVO getPageResult(PageInfo<?> pageInfo) {
        return PageResultVO.builder()
                .pageNum(pageInfo.getPageNum())
                .pageSize(pageInfo.getPageSize())
                .pages(pageInfo.getPages())
                .total(pageInfo.getTotal())
                .data(pageInfo.getList())
                .build();
    }

    public static <T> PageResultVO getPageResult(List<T> data) {
        PageInfo<T> pageInfo = new PageInfo<>(data);
        return PageResultVO.builder()
                .pageNum(pageInfo.getPageNum())
                .pageSize(pageInfo.getPageSize())
                .pages(pageInfo.getPages())
                .total(pageInfo.getTotal())
                .data(pageInfo.getList())
                .build();
    }

}
