Bladeren bron

。。。

wangwei 6 jaren geleden
bovenliggende
commit
a633120037

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

@@ -8,6 +8,7 @@ import java.util.Map;
 
 import javax.persistence.criteria.Predicate;
 
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -272,33 +273,49 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 
 	@Override
 	public LockExamStudentsResp lockExamStudents(@RequestBody LockExamStudentsReq req) {
-		Long examId = req.getExamId();
-		if (null == examId) {
-			throw new StatusException("E-002001", "examId is null");
+
+		LockExamStudentsResp resp = new LockExamStudentsResp();
+
+		List<Long> examIdList = req.getExamIdList();
+		if (CollectionUtils.isEmpty(examIdList)) {
+			return resp;
 		}
-		ExamEntity exam = examRepo.findOne(examId);
-		if (null == exam) {
-			throw new StatusException("E-002002", "ExamEntity is null");
+		for (Long examId : examIdList) {
+			if (null == examId) {
+				throw new StatusException("E-002001", "examId is null");
+			}
+			ExamEntity exam = examRepo.findOne(examId);
+			if (null == exam) {
+				throw new StatusException("E-002002", "ExamEntity is null");
+			}
+			exam.setExamStudentLocked(false);
+			examRepo.save(exam);
 		}
-		exam.setExamStudentLocked(true);
-		examRepo.save(exam);
-		LockExamStudentsResp resp = new LockExamStudentsResp();
+
 		return resp;
 	}
 
 	@Override
 	public UnlockExamStudentsResp unlockExamStudents(@RequestBody UnlockExamStudentsReq req) {
-		Long examId = req.getExamId();
-		if (null == examId) {
-			throw new StatusException("E-002001", "examId is null");
+
+		UnlockExamStudentsResp resp = new UnlockExamStudentsResp();
+
+		List<Long> examIdList = req.getExamIdList();
+		if (CollectionUtils.isEmpty(examIdList)) {
+			return resp;
 		}
-		ExamEntity exam = examRepo.findOne(examId);
-		if (null == exam) {
-			throw new StatusException("E-002002", "ExamEntity is null");
+		for (Long examId : examIdList) {
+			if (null == examId) {
+				throw new StatusException("E-002001", "examId is null");
+			}
+			ExamEntity exam = examRepo.findOne(examId);
+			if (null == exam) {
+				throw new StatusException("E-002002", "ExamEntity is null");
+			}
+			exam.setExamStudentLocked(false);
+			examRepo.save(exam);
 		}
-		exam.setExamStudentLocked(false);
-		examRepo.save(exam);
-		UnlockExamStudentsResp resp = new UnlockExamStudentsResp();
+
 		return resp;
 	}