赞
踩
@Data public class ListQueryParam { /** * 页码 */ private int pageNo = 1; /** * 数据条数 */ private int pageSize = 10; /** * 分页信息 */ private PageInfo pageInfo; /** * 数据权限信息 */ private DataAuthority dataAuthority; public void initListQueryParam(CurrentUser currentUser) { this.pageInfo = new PageInfo(this.pageNo, this.pageSize); this.dataAuthority = new DataAuthority(currentUser); } public void setListTotal(int total) { this.pageInfo.setTotal(total); } public void setListData(Object data) { this.pageInfo.setList(data); } }
/**
* 示例
* biz_customer 表join标识
*/
private boolean bizCustomerJoinFlag;
public void setCustomerName(String customerName) {
this.customerName = customerName;
if (Toolkit.isValid(customerName)) {
this.bizCustomerJoinFlag = true;
}
}
@Override public PageInfo getPreLoanList(PreLoanQueryParam queryParam) { PageInfo pageInfo = queryParam.getPageInfo(); AbstractPagination<PreLoanInfo, PreLoanQueryParam> preLoanPagination = new AbstractPagination<PreLoanInfo, PreLoanQueryParam>() { @Override public int countDataTotal(PreLoanQueryParam param) { // 查询数据总条数 return preLoanMapper.countPreLoanList(param, param.getDataAuthority()); } @Override public List<PreLoanInfo> getDataList(PreLoanQueryParam param) { // 查询列表数据 List<PreLoanInfo> preLoanList = preLoanMapper.getPreLoanList(param, param.getDataAuthority()); // xxx列表数据处理 return preLoanList; } }; preLoanPagination.execute(pageInfo, queryParam); return pageInfo; }
/** * 分页查询抽象类 */ @Slf4j public abstract class AbstractPagination<T, V> { /** * 统计数据总数 * * @param v 查询参数 * @return */ public abstract int countDataTotal(V v); /** * 获取数据列表 * * @param v 查询参数 * @return */ public abstract List<T> getDataList(V v); /** * 执行 * * @param p 分页数据 * @param v 查询参数 */ public void execute(PageInfo p, V v) { CompletableFuture<PageInfo> totalFuture = CompletableFuture.supplyAsync(() -> { p.setTotal(this.countDataTotal(v)); return p; }); CompletableFuture<PageInfo> listFuture = CompletableFuture.supplyAsync(() -> { p.setList(this.getDataList(v)); return p; }); CompletableFuture.allOf(totalFuture, listFuture).join(); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。