/**
* 分頁查詢公司擁有的專案的列表
* @param companyId
* @return
*/
public Page<Project> getListByCompanyPage(PageFilter pageFilter,String companyId,Date beginDate,Date endDate,String projectName) {
Page<Project> l=projectRepository.findAll(new Specification<Project>() {
@Override
public Predicate toPredicate(Root<Project> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cBuilder) {
//開始,定義一個Predicate
Predicate p = cBuilder.conjunction();
/**精確查詢**/
p = cBuilder.and(p, cBuilder.equal(root.get("companyId"), companyId));
/**模糊查詢**/
p = cBuilder.and(p, cBuilder.like(root.get("projectName"), "%"+projectName+"%"));
/**時間段查詢**/
//大於等於開始時間
p = cBuilder.and(p, cBuilder.greaterThanOrEqualTo(root.get("createTime"), beginDate));
//小於等於結束時間
p = cBuilder.and(p, cBuilder.lessThanOrEqualTo(root.get("createTime"), endDate));
return p;
}
}, pageFilter.getPageRequest());
return l;
/**
* 分頁查詢公司擁有的專案的列表
* @param companyId
* @return
*/
public Page<Project> getListByCompanyPage(PageFilter pageFilter,String companyId,Date beginDate,Date endDate,String projectName) {
Page<Project> l=projectRepository.findAll(new Specification<Project>() {
@Override
public Predicate toPredicate(Root<Project> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cBuilder) {
//開始,定義一個Predicate
Predicate p = cBuilder.conjunction();
/**精確查詢**/
p = cBuilder.and(p, cBuilder.equal(root.get("companyId"), companyId));
/**模糊查詢**/
p = cBuilder.and(p, cBuilder.like(root.get("projectName"), "%"+projectName+"%"));
/**時間段查詢**/
//大於等於開始時間
p = cBuilder.and(p, cBuilder.greaterThanOrEqualTo(root.get("createTime"), beginDate));
//小於等於結束時間
p = cBuilder.and(p, cBuilder.lessThanOrEqualTo(root.get("createTime"), endDate));
return p;
}
}, pageFilter.getPageRequest());
return l;
}