概述
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.12</version>
</dependency>
/**
* 线下还款处理搜索分页列表(财务管理模块)
*/
@Override
public PageResult<RepayDto> queryOfflineRepay(String searchKey, Date repayTimeStart, Date repayTimeEnd, Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum, pageSize, true);
List<RepayDto> repayDtoList = repayDao.queryOfflineRepay(searchKey, repayTimeStart, repayTimeEnd);
//翻译逾期状态 和账单状态
for (RepayDto repayDao : repayDtoList){
if(repayDao.getOverdueStatus() != null){
repayDao.setOverdueStatusName(RepayConstants.getDictName(repayDao.getOverdueStatus()));
}
if(repayDao.getRepayStatus() != null){
repayDao.setRepayStatusName(RepayConstants.getDictName(repayDao.getRepayStatus()));
}
}
Long total = ((Page) repayDtoList).getTotal();
//添加其他两个字段
Map<String, Object> otherMap = repayDao.queryOtherData(searchKey, repayTimeStart, repayTimeEnd);
//封装最后结果返回
PageResult<RepayDto> result = new PageResult<>(repayDtoList, total, pageNum, pageSize);
result.setOtherDatas(otherMap);
return result;
}```
```java
package com.i78dk.saascommon.common.sys;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* description: 某些模块分页字段不一样,将用到的分页字段都放在这兼容
*/
@Data
public class PageResult<T> implements Serializable {
/**
* 数据
*/
private List<T> dataList;
/**
* 当前页
*/
private Integer pageNo;
/**
* 每页多少记录数
*/
private Integer pageSize;
/**
* 总记录数
*/
private Long totalCount;
/**
* 页码总数
*/
private Integer totalPage;
/**
* 其它附加数据,有些功能需要在列表外添加一些附加数据,这样可以省去一些自定义对象
*/
private Map<String, Object> otherDatas;
/**
* Description: 添加附加数据
*/
public void setOtherData(String key, Object value) {
if (otherDatas == null) {
otherDatas = new HashMap<>();
}
otherDatas.put(key, value);
}
public PageResult(){
}
/**
* 自定义分页使用
* @param list list
* @param count count
* @param pageNo pageNo
* @param pageSize pageSize
*/
public PageResult(List<T> list, Long count, Integer pageNo, Integer pageSize){
// 都是数据
// 深拷贝,避免json的循环引用检测
this.dataList = list;
// 都是总记录数
this.totalCount = count;
// 都是当前页
this.pageNo = pageNo;
int totalPages = (int)(count / pageSize);
totalPages = count % pageSize > 0 ? totalPages + 1 : totalPages;
this.totalPage = totalPages;
this.pageSize = pageSize;
}
}
<!-- 线下还款处理搜索分页列表(财务管理模块) -->
<select id="queryOfflineRepay" resultType="com.i78dk.saasfinancecloud.inter.dto.RepayDto">
SELECT
u.user_name loanUserName,
fbr.id id,
fbr.bill_id billId,
fbr.order_id orderId,
m.merchant_name merchantName,
cgb.`name` productCategoryName,
o.audit_money loanAmount,
fbb.bill_number billNumber,
fbb.period billPeriod,
fbb.principal principal,
fbb.interest interest,
fbb.add_amount addAmount,
fbb.overdue_fee overdueFee,
<!--总计应还=每期本金+每期利息+本期平台服务费+逾期手续费 -->
CEIL(fbb.principal+fbb.interest+fbb.add_amount+fbb.overdue_fee) shouldPay,
fbb.status_overdue overdueStatus,
fbb.status_repay repayStatus,
fbr.create_time createTime
FROM fc_bm_repay fbr
left join `order` o on fbr.order_id = o.id
left join order_extend oe on o.id = oe.order_id
left join merchant m on o.merchant_id = m.id
left join `user` u on o.user_id = u.id
left join cp_goods_baseinfo cgb on oe.goods_id = cgb.id
left join fc_bm_bill fbb on o.id = fbb.order_id
where fbr.repay_type = 'offline'
<if test = "searchKey != null and searchKey != '' ">
AND (o.order_no = #{searchKey} OR u.real_name = #{searchKey} OR u.mobile = #{searchKey})
</if>
<if test = "repayTimeStart != null">
AND fbr.repay_time <![CDATA[ >= ]]> DATE_FORMAT(#{repayTimeStart},'%Y-%m-%d')
</if>
<if test = "repayTimeEnd != null">
AND fbr.repay_time <![CDATA[ <= ]]> DATE_FORMAT(#{repayTimeEnd},'%Y-%m-%d')
</if>
ORDER BY fbr.repay_time DESC
</select>
最后
以上就是发嗲白羊为你收集整理的pageHelper怎么分页的全部内容,希望文章能够帮你解决pageHelper怎么分页所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复