修改班级试卷添加逻辑以支持覆盖旧试卷

dev
zhangyue 2026-03-10 18:23:53 +08:00
parent ffaea5a15c
commit 1707e3907b
1 changed files with 12 additions and 9 deletions

View File

@ -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);