WANG 6 жил өмнө
parent
commit
7c0567e06c

+ 31 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamCloudServiceProvider.java

@@ -36,11 +36,13 @@ import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgSettingsRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgSettingsEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPaperTypeRelationEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
 import cn.com.qmth.examcloud.core.examwork.service.impl.ExamServiceImpl;
@@ -48,6 +50,7 @@ import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamCourseRelationBean;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamPaperTypeRelation;
+import cn.com.qmth.examcloud.examwork.api.request.CountExamStudentReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamCourseListReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamCoursePaperTypeListReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamListReq;
@@ -58,6 +61,7 @@ import cn.com.qmth.examcloud.examwork.api.request.LockExamStudentsReq;
 import cn.com.qmth.examcloud.examwork.api.request.SaveExamReq;
 import cn.com.qmth.examcloud.examwork.api.request.SetExamPropertyReq;
 import cn.com.qmth.examcloud.examwork.api.request.UnlockExamStudentsReq;
+import cn.com.qmth.examcloud.examwork.api.response.CountExamStudentResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamCourseListResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamCoursePaperTypeListResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamListResp;
@@ -93,6 +97,9 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 	@Autowired
 	ExamRepo examRepo;
 
+	@Autowired
+	ExamStudentRepo examStudentRepo;
+
 	@Autowired
 	ExamPropertyRepo examPropertyRepo;
 
@@ -529,7 +536,31 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 		resp.setRelationList(list);
 
 		return resp;
+	}
+
+	@Override
+	public CountExamStudentResp countExamStudent(CountExamStudentReq req) {
+
+		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
 
+			if (null != req.getExamId()) {
+				predicates.add(cb.equal(root.get("examId"), req.getExamId()));
+			}
+			if (null != req.getCourseId()) {
+				predicates.add(cb.equal(root.get("courseId"), req.getCourseId()));
+			}
+			if (StringUtils.isNotEmpty(req.getPaperType())) {
+				predicates.add(cb.equal(root.get("paperType"), req.getPaperType()));
+			}
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
+		long count = examStudentRepo.count(specification);
+		CountExamStudentResp resp = new CountExamStudentResp();
+		resp.setCount(count);
+		return resp;
 	}
 
 }