java中使用PageInfo分页的几种方式总结(案例)工作总结仅供自己学习

编程

@Override

public PageInfo<SettlementRecordDetailModel> payeeQuery(PartnerModel partner, Long orgId, Query query) {

PageInfo<SettlementRecordDetailModel> pageInfo = null;

if (partner.getPartnerType().equals(PartnerTypeConstants.PASSIVE_CREATE)) {

// 客户端

pageInfo = PageHelper.startPage(query.getPageNum(),

query.getPageSize()).doSelectPageInfo(() -> mapper.selectAllByOrgId(orgId));

} else if (partner.getType().equals((short) 4)) {

// 运营端

pageInfo = PageHelper.startPage(query.getPageNum(),

query.getPageSize()).doSelectPageInfo(() -> mapper.selectAllByOperatorOrgId(partner.getOrgId()));

}

return pageInfo;

}

方式二:

@Override

public PageInfo<SettlementRecordDetailModel> payeeQuery(PartnerModel partner, Long orgId, Query query) {

PageInfo<SettlementRecordDetailModel> settlementRecordDetails = new PageInfo<>();

List<SettlementRecordDetailModel> list = new ArrayList<>();

if (!StringUtils.isEmpty(query.getWhere().get("customerOrgId"))) {

Long customerId = Long.valueOf(String.valueOf(query.getWhere().get("customerId")));

PageInfo<Object> pageInfo = PageHelper.startPage(query.getPageNum(), query.getPageSize()).doSelectPageInfo(() -> mapper.selectAllByCustomerId(customerId));

List<SettlementRecordDetailModel> settlementRecordDetailModels = mapper.selectAllByCustomerId(customerId);

settlementRecordDetails.setList(settlementRecordDetailModels);

} else {

Query q = new Query();

List<CustomerV2Model> customerV2Models = setServiceClientService.customerQueryAll(q);

for (CustomerV2Model customerV2Model : customerV2Models) {

List<SettlementRecordDetailModel> settlementRecordDetailModels = mapper.selectAllByCustomerId(customerV2Model.getId());

list.addAll(settlementRecordDetailModels);

}

settlementRecordDetails.setList(list);

}

return settlementRecordDetails;

}

方式三:

@Override

public PageInfo<SettlementRecordDetailModel> query(Query query) {

PageInfo<SettlementRecordDetailModel> pageInfo = super.query(query);

List<SettlementRecordDetailModel> models = pageInfo.getList();

List<SettlementRecordDetailModel> countList = new ArrayList<>();

for (SettlementRecordDetailModel model : models) {

String number = model.getCertificateNumber();

String name = model.getTalentPersonName();

int flag = 0;

for (SettlementRecordDetailModel settlementRecordDetailModel : countList) {

String certificateNumber = settlementRecordDetailModel.getCertificateNumber();

String talentPersonName = settlementRecordDetailModel.getTalentPersonName();

if (number.equals(certificateNumber) && name.equals(talentPersonName)) {

BigDecimal count = model.getSettlementAmount().add(settlementRecordDetailModel.getSettlementAmount());

settlementRecordDetailModel.setSettlementAmount(count);

flag = 1;

}

}

//0为新增数据 1位计算金额

if (flag == 0) {

countList.add(model);

}

}

pageInfo.setList(countList);

return pageInfo;

}

以上是 java中使用PageInfo分页的几种方式总结(案例)工作总结仅供自己学习 的全部内容, 来源链接: utcz.com/z/516393.html

回到顶部