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 33 34 35 36
| public Map<String, Object> list(YourEntityClass entities, @RequestParam(value = "pageNum",required = false) String pageNum, @RequestParam(value = "pageSize",required = false) String pageSize) { Map<String, Object> map = new HashMap<>(); Integer pageNumInt = 1; if (pageNum != null) { pageNumInt = Integer.parseInt(pageNum); } Integer pageSizeInt = 10; if (pageSize != null) { pageSizeInt = Integer.parseInt(pageSize); }
paperInfo.setIsdown("0"); List<YourEntityClass> list = entityService.selectYourEntityClassList(entities); List<YourEntityClass> listSort = new ArrayList<>(); int size = list.size(); int pageStart = pageNumInt == 1 ? 0 : (pageNumInt - 1) * pageSizeInt;//截取的开始位置 int pageEnd = size < pageNumInt * pageSizeInt ? size : pageNumInt * pageSizeInt;//截取的结束位置 if (size > pageStart) { listSort = list.subList(pageStart, pageEnd); } if (list == null || list.size() == 0) { map.put("total", 0); map.put("rows", null); map.put("code", 200); map.put("msg","查询成功"); return map; } map.put("total", size); map.put("rows", listSort); map.put("code", 200); map.put("msg","查询成功"); return map; }
|