1,pageHelper分页请参考:
https://blog.csdn.net/nanhuaibeian/article/details/106649936
2,自己写分页:
package com.zkml.hkm.common;
import lombok.Data;
import java.io.Serializable;
/**
-
@author shiyf
-
@description
-
@since 2021-12-28
*/
@Data
public class PageBean implements Serializable {/**
- 序列化
*/
private static final long serialVersionUID = 1L;
/**
- 每页显示条数
/
private Integer pageSize = 10;
/* - 当前页数
/
private Integer pageNum = 1;
/* - 起始条数
*/
private Integer beginIndex = 0;
public void setBeginIndex(Integer beginIndex) {
this.beginIndex = beginIndex;
}public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
if (pageSize != null) {
this.beginIndex = (this.pageNum - 1) * this.pageSize;
}
}public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
if (pageNum != null) {
this.beginIndex = (this.pageNum - 1) * this.pageSize;
}
} - 序列化
}
/**
-
保费管理参数
-
@author xie
-
@Date 2022/01/13
*/
@ApiModel(description = “保费管理参数”)
@Data
public class PremiumDto extends PageBean {/**
- 获取保费总行列表
- @param premiumDto
- @return
*/
@PostMapping(value = “/queryPremiumInfoList”)
@ApiOperation(“获取保费总行列表”)
public ResponseBean queryPremiumBankList(@RequestBody PremiumDto premiumDto){
return premiumService.queryPremiumBankList(premiumDto);
}
@Override
public ResponseBean queryPremiumBankList(PremiumDto premiumDto) {
log.info("保费总行列表查询参数:{}", premiumDto);
ResponseBean response = new ResponseBean();
try{
//查询总行信息列表条数、总金额、总笔数、总支行数
Map<String,Object> countMap = premiumMapper.queryPremiumBankListCount(premiumDto);
long totalCount = (Long) countMap.get("totalCount");
BigDecimal totalNum = (BigDecimal) countMap.get("totalNum");
if(totalNum == null){
totalNum = new BigDecimal(0);
}
Double totalAmount = (Double) countMap.get("totalAmount");
if(totalAmount == null){
totalAmount = 0.00;
}
Integer totalBranchCount = premiumMapper.queryPremiumBankBranchCount(premiumDto);
log.info("总行信息列表查询条数:{}",totalCount);
List<Map<String,Object>> bankList = new ArrayList<>();
if(totalCount>0){
//查询总行信息列表
bankList = premiumMapper.queryPremiumBankList(premiumDto);
//查询支行数
for(int i =0; i<bankList.size(); i++){
String bankName = (String) bankList.get(i).get("premiumBank");
premiumDto.setBankName(bankName);
int branchCount = premiumMapper.queryPremiumBankBranchCount(premiumDto);
bankList.get(i).put("branchCount",branchCount);
}
}
Map<String, Object> result = new HashMap<>(Constant.MAP_DEFAULT_SIZE);
result.put("total", totalCount);
result.put("totalNum", totalNum);
result.put("totalAmount", totalAmount);
result.put("totalBranchCount", totalBranchCount);
result.put("content", bankList);
result.put("pageSize", premiumDto.getPageSize());
result.put("pageNum", premiumDto.getPageNum());
response.setData(result);
response.setCode(1);
response.setMessage("总行信息列表查询成功!");
return response;
}catch (Exception e){
log.info("总行信息列表查询异常:{}",e);
response.setStatus(Constant.FAIL_STATUS);
response.setCode(0);
response.setMessage("总行信息列表查询异常!");
return response;
}
}