|
@@ -12,6 +12,7 @@ import java.util.stream.Collectors;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -39,13 +40,15 @@ public class ExamDataServiceImpl implements ExamDataService {
|
|
|
private ExamStudentCountRepo examStudentCountRepo;
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo<ExamDataBean> queryPage(Long rootOrgId, Integer pageNo, Integer pageSize) {
|
|
|
+ public PageInfo<ExamDataBean> queryPage(Long rootOrgId, String examName, Integer pageNo, Integer pageSize) {
|
|
|
Specification<ExamDataEntity> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
if (null != rootOrgId) {
|
|
|
predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
}
|
|
|
-
|
|
|
+ if (StringUtils.isNotBlank(examName)) {
|
|
|
+ predicates.add(cb.like(root.get("examName"), toSqlSearchPattern(examName)));
|
|
|
+ }
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
};
|
|
|
|
|
@@ -173,4 +176,14 @@ public class ExamDataServiceImpl implements ExamDataService {
|
|
|
ed.setCompleteCount(completeCount.intValue());
|
|
|
examDataRepo.save(ed);
|
|
|
}
|
|
|
+
|
|
|
+ private String toSqlSearchPattern(String column) {
|
|
|
+ if (StringUtils.isBlank(column)) {
|
|
|
+ return "%";
|
|
|
+ } else {
|
|
|
+ column = column.trim().replaceAll("\\s", "%");
|
|
|
+ column = "%" + column + "%";
|
|
|
+ return column;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|