一、分页查询
场景:动态查询,分页查询,根据传入不同的状态,分别查询不同数据表,并且在传入page对象之前用map进行VO转换。而pageable的使用地方不同影响到了分页数据的正确性,以此进行探讨。
- pageable使用于new PageImpl<>中,且直到最后才将List -> Page
- pageable使用于findAll()中
前提:Page对象封于VO内,返回数据包括了分页数据
@ApiModelProperty("记录")
private Page<ActivityRecordVO> activityRecordVOList;
@ApiModelProperty("数量")
private Integer num = 0;
@ApiModelProperty("金额")
private BigDecimal totalMoney = BigDecimal.valueOf(0);
错误运用:
List<ActivityRecordVO> activityRecordVOList = new ArrayList<>();
if (receiveSendRecordRequestVO.getSendOrReceiveType() == SendOrReceiveType.RECEIVE) {
List<ChallengeRecord> challengeRecordList = challengeRecordDao.findByUserIdAndDeleteType(userId,
DeleteType.FALSE);