|
@@ -28,6 +28,7 @@ import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -69,14 +70,14 @@ public class PaperServiceImpl extends BaseService implements PaperService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Paper> findAll(Pageable pageable, String keyword) {
|
|
|
- Specifications<Paper> where = Specifications.where(getWhereClause(null, keyword));
|
|
|
+ public Page<Paper> findAll(Pageable pageable, String keyword, Map<String,String> extraCondition) {
|
|
|
+ Specifications<Paper> where = Specifications.where(getWhereClause(null, keyword,extraCondition));
|
|
|
return paperDao.findAll(where, pageable);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Paper> findAllByOwnerId(long ownerId, String keyword, Pageable pageable) {
|
|
|
- Specifications<Paper> where = Specifications.where(getWhereClause(ownerId, keyword));
|
|
|
+ public Page<Paper> findAllByOwnerId(long ownerId, String keyword, Pageable pageable, Map<String,String> extraCondition) {
|
|
|
+ Specifications<Paper> where = Specifications.where(getWhereClause(ownerId, keyword,extraCondition));
|
|
|
return paperDao.findAll(where, pageable);
|
|
|
}
|
|
|
|
|
@@ -170,12 +171,19 @@ public class PaperServiceImpl extends BaseService implements PaperService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Specification<Paper> getWhereClause(Long ownerId, String keyword) {
|
|
|
+ private Specification<Paper> getWhereClause(Long ownerId, String keyword, Map<String,String> extraCondition) {
|
|
|
User thirdUser = userDao.findByEmail(OwningPartyConstants.THIRDEMAIL);
|
|
|
return new Specification<Paper>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<Paper> a, CriteriaQuery<?> q, CriteriaBuilder cb) {
|
|
|
Predicate predicate = cb.conjunction();
|
|
|
+ if (extraCondition != null) {
|
|
|
+ for (String key:extraCondition.keySet()) {
|
|
|
+ predicate.getExpressions().add(
|
|
|
+ cb.equal(a.get(key), extraCondition.get(key))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
if(ownerId!=null) {
|
|
|
predicate.getExpressions().add(
|
|
|
cb.equal(a.<Long>get("ownerId"), ownerId)
|