|
@@ -792,8 +792,62 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
@PostMapping("getExams")
|
|
|
@Override
|
|
|
public GetExamsResp getExams(@RequestBody GetExamsReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ Boolean enable = req.getEnable();
|
|
|
+
|
|
|
+ final long start = null == req.getStart() ? 1 : req.getStart();
|
|
|
+
|
|
|
+ Pageable pageable = PageRequest.of(0, 100, Sort.Direction.ASC, "id");
|
|
|
+
|
|
|
+ Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("rootId"), rootOrgId));
|
|
|
+
|
|
|
+ predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
|
|
|
+
|
|
|
+ if (null != enable) {
|
|
|
+ predicates.add(cb.equal(root.get("enable"), enable));
|
|
|
+ }
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ Page<ExamEntity> page = examRepo.findAll(specification, pageable);
|
|
|
+
|
|
|
+ Iterator<ExamEntity> iterator = page.iterator();
|
|
|
+
|
|
|
+ List<ExamBean> list = Lists.newArrayList();
|
|
|
+ long next = start;
|
|
|
+ boolean has = false;
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ ExamEntity exam = iterator.next();
|
|
|
+ ExamBean bean = new ExamBean();
|
|
|
+ bean.setId(exam.getId());
|
|
|
+ bean.setBeginTime(exam.getBeginTime());
|
|
|
+ bean.setDuration(exam.getDuration());
|
|
|
+ bean.setEnable(exam.getEnable());
|
|
|
+ bean.setEndTime(exam.getEndTime());
|
|
|
+ bean.setExamTimes(exam.getExamTimes());
|
|
|
+ bean.setExamType(exam.getExamType().name());
|
|
|
+ bean.setName(exam.getName());
|
|
|
+ bean.setCode(exam.getCode());
|
|
|
+ bean.setRemark(exam.getRemark());
|
|
|
+ bean.setRootOrgId(exam.getRootOrgId());
|
|
|
+ bean.setExamLimit(exam.getExamLimit());
|
|
|
+
|
|
|
+ next = exam.getId();
|
|
|
+ list.add(bean);
|
|
|
+ has = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ GetExamsResp resp = new GetExamsResp();
|
|
|
+ if (has) {
|
|
|
+ next++;
|
|
|
+ }
|
|
|
+ resp.setNext(next);
|
|
|
+ resp.setExamBeanList(list);
|
|
|
+
|
|
|
+ return resp;
|
|
|
}
|
|
|
|
|
|
}
|