@Override public Page<SysUserPolicyEntity> selectInsured(GrpnameForm data, int current, int pageSize) { //查询 String employeeNo = data.getEmployeeNo(); String grpname = data.getGrpname(); List<SysUserPolicyEntity> lcgrpcontVoPage = lcgrpcontMapper.selectInsured(grpname); LambdaQueryWrapper<SysUserPolicyEntity> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ObjectUtils.isNotEmpty(employeeNo), SysUserPolicyEntity::getEmployeeNo, employeeNo); List<SysUserPolicyEntity> sysUserPolicyEntityList = sysUserPolicyMapper.selectList(wrapper); for (SysUserPolicyEntity record : lcgrpcontVoPage) { for (SysUserPolicyEntity policyEntity : sysUserPolicyEntityList) { if (record.getGrpcontno().equals(policyEntity.getGrpcontno())) { record.setSelectFlag(policyEntity.getSelectFlag()); } } } sysUserPolicyMapper.delete(wrapper); Page<SysUserPolicyEntity> objectPage = new Page<>(); objectPage.setRecords(lcgrpcontVoPage); objectPage.setCurrent(current); objectPage.setSize(pageSize); objectPage.setTotal(lcgrpcontVoPage.size()); return objectPage; }按照分页放入数据
时间: 2024-02-14 07:04:20 浏览: 66
List<map>多字段组合排序
5星 · 资源好评率100%
可以使用PageHelper插件来实现分页,具体代码如下:
```
@Override
public Page<SysUserPolicyEntity> selectInsured(GrpnameForm data, int current, int pageSize) {
//查询
String employeeNo = data.getEmployeeNo();
String grpname = data.getGrpname();
List<SysUserPolicyEntity> lcgrpcontVoPage = lcgrpcontMapper.selectInsured(grpname);
LambdaQueryWrapper<SysUserPolicyEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ObjectUtils.isNotEmpty(employeeNo), SysUserPolicyEntity::getEmployeeNo, employeeNo);
List<SysUserPolicyEntity> sysUserPolicyEntityList = sysUserPolicyMapper.selectList(wrapper);
for (SysUserPolicyEntity record : lcgrpcontVoPage) {
for (SysUserPolicyEntity policyEntity : sysUserPolicyEntityList) {
if (record.getGrpcontno().equals(policyEntity.getGrpcontno())) {
record.setSelectFlag(policyEntity.getSelectFlag());
}
}
}
sysUserPolicyMapper.delete(wrapper);
//使用PageHelper插件进行分页
PageHelper.startPage(current, pageSize);
List<SysUserPolicyEntity> list = new ArrayList<>(lcgrpcontVoPage);
PageInfo<SysUserPolicyEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
```
其中,PageHelper.startPage(current, pageSize)表示开始分页,current表示当前页码,pageSize表示每页显示的数量。PageInfo<SysUserPolicyEntity> pageInfo = new PageInfo<>(list)表示将分页后的数据封装到PageInfo对象中。最后返回pageInfo即可。
阅读全文