Преглед на файлове

去除考生课程和试卷类型

WANG преди 6 години
родител
ревизия
894d13e55a

+ 30 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

@@ -126,6 +126,21 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 				throw new StatusException("E-150112", examStudent.getName() + "已开始考试,不能删除");
 			}
 			examStudentRepo.delete(examStudent);
+
+			int countCourseId = examStudentRepo.countByExamIdAndCourseId(examStudent.getExamId(),
+					examStudent.getCourseId());
+			if (1 > countCourseId) {
+				examCourseRelationRepo.deleteByExamIdAndCourseId(examStudent.getExamId(),
+						examStudent.getCourseId());
+			}
+
+			int countPaperType = examStudentRepo.countByExamIdAndCourseIdAndPaperType(
+					examStudent.getExamId(), examStudent.getCourseId(), examStudent.getPaperType());
+			if (1 > countPaperType) {
+				examPaperTypeRelationRepo.deleteByExamIdAndCourseIdAndPageType(
+						examStudent.getExamId(), examStudent.getCourseId(),
+						examStudent.getPaperType());
+			}
 		}
 
 		for (ExamStudentEntity cur : examStudents) {
@@ -247,6 +262,21 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 		if (null == examStudent) {
 			examStudent = new ExamStudentEntity();
 			examStudent.setEnable(true);
+		} else {
+			int countCourseId = examStudentRepo.countByExamIdAndCourseId(examStudent.getExamId(),
+					examStudent.getCourseId());
+			if (2 > countCourseId) {
+				examCourseRelationRepo.deleteByExamIdAndCourseId(examStudent.getExamId(),
+						examStudent.getCourseId());
+			}
+
+			int countPaperType = examStudentRepo.countByExamIdAndCourseIdAndPaperType(
+					examStudent.getExamId(), examStudent.getCourseId(), examStudent.getPaperType());
+			if (2 > countPaperType) {
+				examPaperTypeRelationRepo.deleteByExamIdAndCourseIdAndPageType(
+						examStudent.getExamId(), examStudent.getCourseId(),
+						examStudent.getPaperType());
+			}
 		}
 
 		examStudent.setInfoCollector(examStudentInfo.getInfoCollector());