use of com.ch999.haha.admin.vo.MyAdoptionVO in project haha by hahafreeasair666.
the class AdoptionRequestServiceImpl method getMyAdoptionList.
@Override
public PageVO<MyAdoptionVO> getMyAdoptionList(Integer userId, Integer currentPage) {
Integer size = 10;
Wrapper<AdoptionRequest> wrapper = new EntityWrapper<>();
wrapper.eq("userid", userId);
List<MyAdoptionVO> list = new ArrayList<>();
List<AdoptionRequest> adoptionRequests = this.selectList(wrapper);
PageVO<MyAdoptionVO> pageVO = new PageVO<>();
pageVO.setTotalPage((int) Math.ceil(adoptionRequests.size() / (double) size));
pageVO.setCurrentPage(currentPage);
if (CollectionUtils.isNotEmpty(adoptionRequests)) {
if (adoptionRequests.size() > size * (currentPage - 1)) {
adoptionRequests = adoptionRequests.subList(size * (currentPage - 1), size * currentPage > adoptionRequests.size() ? adoptionRequests.size() : size * currentPage);
} else {
adoptionRequests = new ArrayList<>();
}
adoptionRequests.forEach(li -> {
News news = newsService.selectById(li.getNewsId());
MyAdoptionVO myAdoptionVO = new MyAdoptionVO();
myAdoptionVO.setNewsId(li.getNewsId());
myAdoptionVO.setTitle(news.getTitle());
// 组装领养成功与否状态
Adoption adoption = adoptionService.selectOne(new EntityWrapper<Adoption>().eq("adoptionid", li.getNewsId()));
if (adoption.getIsAdoption()) {
myAdoptionVO.setIsSuccess(adoption.getUserId().equals(userId) ? 1 : 2);
} else {
myAdoptionVO.setIsSuccess(0);
}
myAdoptionVO.setPic(getOnePicPath(news));
list.add(myAdoptionVO);
});
}
pageVO.setList(list);
return pageVO;
}
Aggregations