//查看公告列表
public PagingQueryUtil findAllInfo(Integer pageSize,Integer currentPage){
Long accountId=LocalAccountHelper.getAccountId();
//按照创建时间倒叙
Sort sort=new Sort(Sort.Direction.DESC, "createTime");
//分页
PageRequest pageRequest=new PageRequest(currentPage,pageSize,sort);
//传参
Specification<RecruitSubaccountBulletin> specification=new Specification<RecruitSubaccountBulletin>() {
@Override
public Predicate toPredicate(Root<RecruitSubaccountBulletin> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate id=cb.equal(root.get("id").as(Long.class),accountId);
Predicate isDelete=cb.equal(root.get("isDelete").as(Short.class),CommonValueUtil.defaultValue);
Predicate predicate= cb.and(id,isDelete);
return predicate;
}
};
//查询
Page<RecruitSubaccountBulletin> page=recruitSubaccountBulletinRepository.findAll(specification,pageRequest);
//转换查询结果
List<RecruitInformationView> recruitInformationViews=this.getInformationViews(page.getContent());
return PagingQueryUtil.getPageInfo(page,recruitInformationViews);
}
public static PagingQueryUtil getPageInfo(Page<?> page){
PagingQueryUtil pagingQueryUtil=new PagingQueryUtil();
pagingQueryUtil.setPages(page.getTotalPages());
pagingQueryUtil.setPageNum(page.getNumber()+1);
pagingQueryUtil.setTotal((int) page.getTotalElements());
pagingQueryUtil.setPageSize(page.getSize());
pagingQueryUtil.setData(page.getContent());
return pagingQueryUtil;
}
网友评论