用PageHelper进行分页查询,代码如下
try {
PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
List<ImEvacuationInfo> moveOutList = new ArrayList<>();
if(flag == 1||flag == 2){
moveOutList = imEvacuationMapper.queryMoveOutList1(paramMap);
}
PageBean<ImEvacuationInfo> list = new PageBean<ImEvacuationInfo>(moveOutList);
modelMap.put("dataInfo", list);
modelMap.put("dataTotal", list.getTotal());
ObjectMapper mapper = new ObjectMapper();
jsonfromMap = mapper.writeValueAsString(modelMap);
} catch (Exception e) {
e.printStackTrace
}
打印sql如下
SELECT count(*) FROM tbl_immigration_evacuation i LEFT JOIN tbl_person_basic_info p ON i.archives_number = p.archivesNumber LEFT JOIN dic_sex s ON s.ID = p.gender LEFT JOIN dic_manager_status m ON m.id = p.AdminStatus WHERE i.final_result = 3 AND i.emigrant_organization_bureau_id = ?
==> Parameters: 262(String)
<== Columns: count(*)
<== Row: 23
<== Total: 1
先查询total