|
@@ -29,12 +29,13 @@ import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Example;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -75,24 +76,37 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
|
|
|
|
@Autowired
|
|
|
private ExamRecordQuestionsService examRecordQuestionsService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamRecordDataService examRecordDataService;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
@ApiOperation(value = "查询是否已经开考")
|
|
|
@PostMapping("/checkExamIsStarted")
|
|
|
- public CheckExamIsStartedResp checkExamIsStarted(@RequestBody CheckExamIsStartedReq examRecordReq) {
|
|
|
- Check.isNull(examRecordReq.getExamId(), "examId不能为空");
|
|
|
- ExamRecordDataEntity examRecordDataEntity = new ExamRecordDataEntity();
|
|
|
- examRecordDataEntity.setExamId(examRecordReq.getExamId());
|
|
|
- examRecordDataEntity.setCourseId(examRecordReq.getCourseId());
|
|
|
- examRecordDataEntity.setStudentId(examRecordReq.getStudentId());
|
|
|
- long examRecordNum = examRecordDataRepo.count(Example.of(examRecordDataEntity));
|
|
|
- CheckExamIsStartedResp checkExamIsStartedResp = new CheckExamIsStartedResp();
|
|
|
- checkExamIsStartedResp.setIsStarted(examRecordNum > 0);
|
|
|
- return checkExamIsStartedResp;
|
|
|
+ public CheckExamIsStartedResp checkExamIsStarted(@RequestBody CheckExamIsStartedReq req) {
|
|
|
+ Check.isNull(req.getExamId(), "examId不能为空");
|
|
|
+
|
|
|
+ Specification<ExamRecordDataEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("examId"), req.getExamId()));
|
|
|
+
|
|
|
+ if (req.getCourseId() != null) {
|
|
|
+ predicates.add(cb.equal(root.get("courseId"), req.getCourseId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (req.getStudentId() != null) {
|
|
|
+ predicates.add(cb.equal(root.get("studentId"), req.getStudentId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ long count = examRecordDataRepo.count(specification);
|
|
|
+
|
|
|
+ CheckExamIsStartedResp resp = new CheckExamIsStartedResp();
|
|
|
+ resp.setIsStarted(count > 0);
|
|
|
+ return resp;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -662,21 +676,21 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
|
return studentAnswer;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
+
|
|
|
+ @Override
|
|
|
@ApiOperation(value = "获取考试监考待审记录数")
|
|
|
@PostMapping("/getGetAwaitingAuditCount")
|
|
|
- public GetAwaitingAuditCountResp getGetAwaitingAuditCount(@RequestBody GetAwaitingAuditCountReq req) {
|
|
|
- if(req.getRootOrgId()==null) {
|
|
|
- throw new StatusException("500", "RootOrgId不允许为空");
|
|
|
- }
|
|
|
- if(req.getExamId()==null) {
|
|
|
- throw new StatusException("500", "ExamId不允许为空");
|
|
|
- }
|
|
|
- Long count=examRecordDataService.getGetAwaitingAuditCount(req.getRootOrgId(),req.getExamId());
|
|
|
- GetAwaitingAuditCountResp res=new GetAwaitingAuditCountResp();
|
|
|
- res.setCount(count);
|
|
|
- return res;
|
|
|
- }
|
|
|
+ public GetAwaitingAuditCountResp getGetAwaitingAuditCount(@RequestBody GetAwaitingAuditCountReq req) {
|
|
|
+ if (req.getRootOrgId() == null) {
|
|
|
+ throw new StatusException("500", "RootOrgId不允许为空");
|
|
|
+ }
|
|
|
+ if (req.getExamId() == null) {
|
|
|
+ throw new StatusException("500", "ExamId不允许为空");
|
|
|
+ }
|
|
|
+ Long count = examRecordDataService.getGetAwaitingAuditCount(req.getRootOrgId(), req.getExamId());
|
|
|
+ GetAwaitingAuditCountResp res = new GetAwaitingAuditCountResp();
|
|
|
+ res.setCount(count);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
}
|