@Override public Pager<PageCategory> findAllPageCategory( Pager<PageCategory> pager, PageCategoryExample example) { if (example == null) example = new PageCategoryExample(); List<PageCategory> pageCategoryList = pageCategoryMapper.selectPageCategoryCount(); // 只对大类进行分页 Map<Long, PageCategory> categoryMap = this.handlePageCategory(pageCategoryList); List<PageCategory> arrayList = new ArrayList<PageCategory>(categoryMap.values()); int listSize = arrayList.size(); int fromIndex = pager.getStartNumber(); int toIndex = pager.getStartNumber() + pager.getEndNumber(); if (fromIndex > listSize) return pager; if (toIndex > listSize) { toIndex = listSize; } pager.setList(arrayList.subList(fromIndex, toIndex)); pager.setTotalCount(categoryMap.size()); return pager; }
@Override public List<PageCategory> findAllPageCategory() { List<PageCategory> pageCategoryList = pageCategoryMapper.selectPageCategoryCount(); Map<Long, PageCategory> categoryMap = this.handlePageCategory(pageCategoryList); return new ArrayList<>(categoryMap.values()); }