| | |
| | | */ |
| | | public class PageHelperUtil { |
| | | |
| | | public static <T> PageInfo<T> pageInfo(int currentPage, int pageSize, List list) { |
| | | public static <T> PageInfo<T> pageInfo(Integer currentPage, Integer pageSize, List list) { |
| | | |
| | | int fromIndex = 0; |
| | | int toIndex = 0; |
| | | //取出总记录数 |
| | | int total = list.size(); |
| | | //当前页码 |
| | | currentPage = (currentPage <= 0) ? 1 : currentPage; |
| | | if (currentPage == null || currentPage <= 0) { |
| | | currentPage = 1; |
| | | } |
| | | //当前页条目数 |
| | | pageSize = (pageSize <= 0) ? 10 : (Math.min(pageSize, total)); |
| | | if (pageSize == null || pageSize <= 0 || pageSize > 500) { |
| | | pageSize = 20; |
| | | } |
| | | |
| | | if (total / pageSize == 0 && total % pageSize > 0) { |
| | | fromIndex = 0; |