|
@@ -181,18 +181,6 @@ public class ExamController extends ControllerSupport {
|
|
|
@RequestParam(required = false) String examType,
|
|
|
@RequestParam(required = false) Boolean enable) {
|
|
|
|
|
|
- if (StringUtils.isBlank(name)) {
|
|
|
- List<ExamEntity> list = Lists.newArrayList();
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- // 过载保护
|
|
|
- int total = examRepo.countByNameLike(name);
|
|
|
- if (total > 1000) {
|
|
|
- List<ExamEntity> list = Lists.newArrayList();
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
predicates.add(cb.equal(root.get("rootOrgId"), getRootOrgId()));
|
|
@@ -208,8 +196,22 @@ public class ExamController extends ControllerSupport {
|
|
|
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
};
|
|
|
- Sort sort = new Sort(Direction.DESC, "updateTime");
|
|
|
- List<ExamEntity> list = examRepo.findAll(specification, sort);
|
|
|
+
|
|
|
+ PageRequest pageRequest = new PageRequest(0, 50, new Sort(Direction.DESC, "updateTime"));
|
|
|
+ Page<ExamEntity> page = examRepo.findAll(specification, pageRequest);
|
|
|
+
|
|
|
+ Iterator<ExamEntity> iterator = page.iterator();
|
|
|
+ List<ExamEntity> list = Lists.newArrayList();
|
|
|
+
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ ExamEntity next = iterator.next();
|
|
|
+
|
|
|
+ ExamEntity bean = new ExamEntity();
|
|
|
+ bean.setId(next.getId());
|
|
|
+ bean.setName(next.getName());
|
|
|
+
|
|
|
+ list.add(bean);
|
|
|
+ }
|
|
|
|
|
|
return list;
|
|
|
}
|