@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-21 14:59:01 浏览: 136
可以自己实现分页放入数据,具体代码如下:
```
@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);
//自制分页放入数据
int total = lcgrpcontVoPage.size();
int startIndex = (current - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, total);
List<SysUserPolicyEntity> pageList = lcgrpcontVoPage.subList(startIndex, endIndex);
Page<SysUserPolicyEntity> objectPage = new Page<>();
objectPage.setRecords(pageList);
objectPage.setCurrent(current);
objectPage.setSize(pageSize);
objectPage.setTotal(total);
return objectPage;
}
```
其中,total表示总记录数,startIndex表示分页查询的起始位置,endIndex表示分页查询的结束位置,pageList表示分页后的数据。最后返回objectPage即可。
阅读全文