judyW
2019-03-13 20:10:04浏览 1810
@Override
@Transactional(rollbackFor = Exception.class)
public SimplePageInfo test(Integer pageNum, Integer pageSize, Long userId) {
List<MarkTextPO> markTextPOList = markTextPOMapper.selectUnFinishedByUserId(userId);
if (markTextPOList.size() == 100) {
} else {
Integer count = 100 - markTextPOList.size();
List<MarkTextPO> extraList = markTextPOMapper.selectUnFinished(count);
extraList.forEach(item -> {
Long flag = markTextPOMapper.updateByOwnerUserId(item.getMarkTextId(), userId);
if (flag == 1) {
markTextPOList.add(item);
}
});
}
SimplePageInfo page = SimplePageInfo.of(markTextPOList.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()));
page.setNumber(pageNum);
page.setPages(5);
page.setPageSize(pageSize);
page.setTotalElements(100);
return page;
}