1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
private PageInfo result(List<Object> idList, int pageNum, int pageSize){ List<BaseMenuVO> result = selectTree("0", menuMapper.findByIds(idList)); List<BaseMenuVO> baseMenuVOS = result .stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); PageInfo pageInfo = new PageInfo(result); pageInfo.setTotal(result.size()); pageInfo.setList(baseMenuVOS); pageInfo.setPageNum(pageNum); pageInfo.setPageSize(pageSize); return pageInfo; }
private List<BaseMenuVO> selectTree(String parentId, List<BaseMenuVO> treeEntityList) { List<BaseMenuVO> collect = treeEntityList.stream() .filter(treeEntity -> treeEntity.getParentId().equals(parentId)) .peek(treeEntity -> treeEntity.setChildren(selectTree(treeEntity.getId(), treeEntityList))) .collect(Collectors.toList()); return collect; }
|