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 3d5fe95..5f50b6a 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 @@ -41,10 +41,12 @@ public class ClassExamPaperAddExe { @Transactional(rollbackFor = Exception.class) public boolean execute(ClassExamPaperAddCmd cmd) { - Long count = classExamPaperRepository.countByClassId(cmd.getClassId()); - if (count > 0) { - throw new BizException("该班级已存在试卷"); - } + // 先删除老试卷。 + classExamPaperRepository.deleteByClassId(cmd.getClassId()); +// Long count = classExamPaperRepository.countByClassId(cmd.getClassId()); +// if (count > 0) { +// throw new BizException("该班级已存在试卷"); +// } ClassExamPaperE classExamPaperE = new ClassExamPaperE(); @@ -66,11 +68,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("该班级已存在试卷"); - } + // 先删除老试卷。 + classExamPaperRepository.deleteByClassId(cmd.getClassId()); +// Long count = classExamPaperRepository.countByClassId(cmd.getClassId()); +// if (count > 0) { +// throw new BizException("该班级已存在试卷"); +// } ClassExamPaperE classExamPaperE = new ClassExamPaperE(); BeanUtils.copyProperties(cmd, classExamPaperE);