//查看飞手的飞行任务 public Ipage<BisFlyerVO> getBisFlyerListAll() { List<BisFlyer> bisFlyerList = bisFlyerMapper.selectList(null); List<BisFlyerVO> bisFlyerVOList = new ArrayList<>(); for (BisFlyer bisFlyer : bisFlyerList) { BisFlyerVO bisFlyerVO = new BisFlyerVO(); BeanUtils.copyProperties(bisFlyer, bisFlyerVO); DatSite datSite = datSiteMapper.selectById(bisFlyer.getSiteId()); if (datSite != null) { bisFlyerVO.setStieName(datSite.getSiteName()); } QueryWrapper<BisTask> bisTaskQueryWrapper = new QueryWrapper<>(); bisTaskQueryWrapper.eq("flyer_id", bisFlyer.getId()).eq("task_status", 2); int taskCount = bisTaskMapper.selectCount(bisTaskQueryWrapper); bisFlyerVO.setTaskStatus(String.valueOf(taskCount)); QueryWrapper<BisTask> bisTaskQueryWrapper2 = new QueryWrapper<>(); bisTaskQueryWrapper2.eq("flyer_id", bisFlyer.getId()).eq("task_status", 8) .ge("create_time", LocalDate.now().withDayOfMonth(1)).le("create_time", LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth())); int flyNumber = bisTaskMapper.selectCount(bisTaskQueryWrapper2); bisFlyerVO.setThisMonthFlyNumber(flyNumber); bisFlyerVOList.add(bisFlyerVO); } return bisFlyerVOList; } 把这个方法加个分页,参数改成BisFlyerVO bisFlyerVO,BisFlyerVO继承了 分页VO类 @Data public class PageReqVO { @ApiModelProperty(value = "第几页") @TableField(exist = false) private int page=1; @ApiModelProperty(value = "分页数量") @TableField(exist = false) private int limit=10; }
时间: 2024-01-04 08:03:28 浏览: 106
好的,您的要求是在这个方法中加入分页功能,同时将方法返回类型改为IPage<BisFlyerVO>。可以按照以下步骤进行修改:
1. 在BisFlyerVO类中继承分页VO类PageReqVO:
```
@Data
public class BisFlyerVO extends PageReqVO {
// 其他属性
}
```
2. 在getBisFlyerListAll方法中使用Page对象进行分页,并将方法返回类型改为IPage<BisFlyerVO>:
```
public IPage<BisFlyerVO> getBisFlyerListAll(BisFlyerVO bisFlyerVO) {
Page<BisFlyer> bisFlyerPage = new Page<>(bisFlyerVO.getPage(), bisFlyerVO.getLimit());
bisFlyerMapper.selectPage(bisFlyerPage, null);
List<BisFlyer> bisFlyerList = bisFlyerPage.getRecords();
List<BisFlyerVO> bisFlyerVOList = new ArrayList<>();
for (BisFlyer bisFlyer : bisFlyerList) {
BisFlyerVO bisFlyerVO = new BisFlyerVO();
BeanUtils.copyProperties(bisFlyer, bisFlyerVO);
DatSite datSite = datSiteMapper.selectById(bisFlyer.getSiteId());
if (datSite != null) {
bisFlyerVO.setStieName(datSite.getSiteName());
}
QueryWrapper<BisTask> bisTaskQueryWrapper = new QueryWrapper<>();
bisTaskQueryWrapper.eq("flyer_id", bisFlyer.getId()).eq("task_status", 2);
int taskCount = bisTaskMapper.selectCount(bisTaskQueryWrapper);
bisFlyerVO.setTaskStatus(String.valueOf(taskCount));
QueryWrapper<BisTask> bisTaskQueryWrapper2 = new QueryWrapper<>();
bisTaskQueryWrapper2.eq("flyer_id", bisFlyer.getId()).eq("task_status", 8)
.ge("create_time", LocalDate.now().withDayOfMonth(1)).le("create_time", LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()));
int flyNumber = bisTaskMapper.selectCount(bisTaskQueryWrapper2);
bisFlyerVO.setThisMonthFlyNumber(flyNumber);
bisFlyerVOList.add(bisFlyerVO);
}
return new PageImpl<>(bisFlyerVOList, bisFlyerPage, bisFlyerPage.getTotal());
}
```
3. 在调用getBisFlyerListAll方法时传入BisFlyerVO对象,其中的page和limit属性表示分页参数。
注意:如果您使用的是MyBatis Plus,可以直接在方法参数中添加Page对象,然后在查询中传入该Page对象即可完成分页操作。
阅读全文