package com.ho.common.tools.util;


import com.github.pagehelper.Page;
import com.ho.common.tools.entity.PageVO;

import java.util.List;

/**
* @ClassName:       PageUtils
*                   分页工具类
* @Author:
* @CreateDate:      2019/9/19 13:26
* @UpdateUser:
* @UpdateDate:      2019/9/19 13:26
* @Version:         0.0.1
*/
public class PageUtilsOld {
	private PageUtilsOld() {}

    public static <T> PageVO<T> getPageVO(List<T> list) {
        PageVO<T> result = new PageVO<>();
        if (list instanceof Page) {
            Page<T> page = (Page<T>) list;
            result.setTotalRows(page.getTotal());
            result.setTotalPages(page.getPages());
            result.setPageNum(page.getPageNum());
            result.setPageSize(page.getPageSize());
            result.setCurPageSize(page.size());
            result.setList(page.getResult());
        }
        return result;
    }
}
