如下所示
/**
* @description 定义一个泛型方法,将mybatis-plus自带的分页返回对象IPage 转成 PageInfo
* @author zhangzy
* @param iPage
* @return com.github.pagehelper.PageInfo<org.apache.poi.ss.formula.functions.T>
* @exception
* @Date 2021/11/25 13:43
**/
public static <T> PageInfo<T> getPageInfoByIPage(IPage<T> iPage){
PageInfo<T> result = new PageInfo<>();
result.setPages((int)iPage.getPages());
result.setPageNum((int)iPage.getCurrent());
result.setPageSize((int)iPage.getSize());
result.setList(iPage.getRecords());
result.setTotal((int)iPage.getTotal());
return result;
}
注意事项:主要加个 < T > 表示让程序认识T表示泛型,而不是一个类叫T