|
@@ -1,9 +1,11 @@
|
|
package cn.com.qmth.examcloud.core.examwork.service.impl;
|
|
package cn.com.qmth.examcloud.core.examwork.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Example;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
@@ -171,15 +173,21 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
if ((!forceDeleteExamStudent()) && isStarted(exam.getId(), null, null)) {
|
|
if ((!forceDeleteExamStudent()) && isStarted(exam.getId(), null, null)) {
|
|
throw new StatusException("150113", "该考试已开始,不能删除");
|
|
throw new StatusException("150113", "该考试已开始,不能删除");
|
|
}
|
|
}
|
|
- examStudentRepo.deleteByExamId(examId);
|
|
|
|
- examCourseRelationRepo.deleteByExamId(examId);
|
|
|
|
- examPaperTypeRelationRepo.deleteByExamId(examId);
|
|
|
|
|
|
|
|
- // 同步操作
|
|
|
|
- SyncExamStudentReq req = new SyncExamStudentReq();
|
|
|
|
- req.setSyncType("deleteByExamId");
|
|
|
|
- req.setExamId(examId);
|
|
|
|
- dataSyncCloudService.syncExamStudent(req);
|
|
|
|
|
|
+ ExamStudentEntity entity = new ExamStudentEntity();
|
|
|
|
+ entity.setExamId(examId);
|
|
|
|
+ Example<ExamStudentEntity> example = Example.of(entity);
|
|
|
|
+ long count = examStudentRepo.count(example);
|
|
|
|
+ if (1000 < count) {
|
|
|
|
+ throw new StatusException("150116", "考生数量超过1000,无法删除");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<ExamStudentEntity> list = examStudentRepo.findAll(example);
|
|
|
|
+
|
|
|
|
+ List<Long> IdList = list.stream().map(ExamStudentEntity::getId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ deleteExamStudentsByStudentIds(IdList);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|