From 46d9a5646d211b7c6d95bc3241da1e2b2f5f0635 Mon Sep 17 00:00:00 2001 From: zhangyue Date: Sat, 7 Mar 2026 10:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=8F=AD=E7=BA=A7=E8=AF=95?= =?UTF-8?q?=E5=8D=B7=E9=87=8D=E5=A4=8D=E6=A3=80=E6=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edu/command/study/ClassExamPaperAddExe.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web-app/src/main/java/com/zcloud/edu/command/study/ClassExamPaperAddExe.java b/web-app/src/main/java/com/zcloud/edu/command/study/ClassExamPaperAddExe.java index 07e431e..3d5fe95 100644 --- a/web-app/src/main/java/com/zcloud/edu/command/study/ClassExamPaperAddExe.java +++ b/web-app/src/main/java/com/zcloud/edu/command/study/ClassExamPaperAddExe.java @@ -13,6 +13,7 @@ import com.zcloud.edu.dto.study.ClassExamPaperAddCmd; import com.zcloud.edu.dto.study.ClassExamPaperAutoAddCmd; import com.zcloud.edu.persistence.dataobject.QuestionDO; import com.zcloud.edu.persistence.repository.resource.QuestionRepository; +import com.zcloud.edu.persistence.repository.study.ClassExamPaperRepository; import lombok.AllArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; @@ -36,9 +37,16 @@ public class ClassExamPaperAddExe { private final ClassExamPaperGateway classExamPaperGateway; private final ExamPaperGateway examPaperGateway; private final QuestionRepository questionRepository; + private final ClassExamPaperRepository classExamPaperRepository; @Transactional(rollbackFor = Exception.class) public boolean execute(ClassExamPaperAddCmd cmd) { + Long count = classExamPaperRepository.countByClassId(cmd.getClassId()); + if (count > 0) { + throw new BizException("该班级已存在试卷"); + } + + ClassExamPaperE classExamPaperE = new ClassExamPaperE(); BeanUtils.copyProperties(cmd, classExamPaperE); // 初始化字段,并判断题目分数是否符合要求 @@ -58,6 +66,12 @@ public class ClassExamPaperAddExe { @Transactional(rollbackFor = Exception.class) public boolean executeAutoSave(ClassExamPaperAutoAddCmd cmd) { + + Long count = classExamPaperRepository.countByClassId(cmd.getClassId()); + if (count > 0) { + throw new BizException("该班级已存在试卷"); + } + ClassExamPaperE classExamPaperE = new ClassExamPaperE(); BeanUtils.copyProperties(cmd, classExamPaperE); // 初始化字段,并判断题目分数是否符合要求