|
@@ -10,6 +10,8 @@ import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
+import javax.persistence.criteria.Subquery;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -74,6 +76,7 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgPropertyEntity;
|
|
|
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.bean.ExamOrgSettingsInfo;
|
|
@@ -303,6 +306,8 @@ public class ExamController extends ControllerSupport {
|
|
|
* @param name
|
|
|
* @param examType
|
|
|
* @param enable
|
|
|
+ * @param studentId
|
|
|
+ * 筛选学生关联的考试
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "查询考试批次")
|
|
@@ -310,7 +315,8 @@ public class ExamController extends ControllerSupport {
|
|
|
public List<ExamDomain> query(@RequestParam(required = true) String name,
|
|
|
@RequestParam(required = false) String examType,
|
|
|
@RequestParam(required = false) Boolean enable,
|
|
|
- @RequestParam(required = false) String propertyKeys) {
|
|
|
+ @RequestParam(required = false) String propertyKeys,
|
|
|
+ @RequestParam(required = false) Long studentId) {
|
|
|
|
|
|
Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
@@ -325,6 +331,16 @@ public class ExamController extends ControllerSupport {
|
|
|
predicates.add(cb.equal(root.get("examType"), ExamType.valueOf(examType)));
|
|
|
}
|
|
|
|
|
|
+ if (null != studentId) {
|
|
|
+ Subquery<ExamStudentEntity> subquery = query.subquery(ExamStudentEntity.class);
|
|
|
+ Root<ExamStudentEntity> subRoot = subquery.from(ExamStudentEntity.class);
|
|
|
+ subquery.select(subRoot.get("id"));
|
|
|
+ Predicate p1 = cb.equal(subRoot.get("studentId"), studentId);
|
|
|
+ Predicate p2 = cb.equal(subRoot.get("examId"), root.get("id"));
|
|
|
+ subquery.where(cb.and(p1, p2));
|
|
|
+ predicates.add(cb.exists(subquery));
|
|
|
+ }
|
|
|
+
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
};
|
|
|
|