添加班级试卷重复检查功能
parent
a9a61e3e62
commit
46d9a5646d
|
|
@ -13,6 +13,7 @@ import com.zcloud.edu.dto.study.ClassExamPaperAddCmd;
|
||||||
import com.zcloud.edu.dto.study.ClassExamPaperAutoAddCmd;
|
import com.zcloud.edu.dto.study.ClassExamPaperAutoAddCmd;
|
||||||
import com.zcloud.edu.persistence.dataobject.QuestionDO;
|
import com.zcloud.edu.persistence.dataobject.QuestionDO;
|
||||||
import com.zcloud.edu.persistence.repository.resource.QuestionRepository;
|
import com.zcloud.edu.persistence.repository.resource.QuestionRepository;
|
||||||
|
import com.zcloud.edu.persistence.repository.study.ClassExamPaperRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -36,9 +37,16 @@ public class ClassExamPaperAddExe {
|
||||||
private final ClassExamPaperGateway classExamPaperGateway;
|
private final ClassExamPaperGateway classExamPaperGateway;
|
||||||
private final ExamPaperGateway examPaperGateway;
|
private final ExamPaperGateway examPaperGateway;
|
||||||
private final QuestionRepository questionRepository;
|
private final QuestionRepository questionRepository;
|
||||||
|
private final ClassExamPaperRepository classExamPaperRepository;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean execute(ClassExamPaperAddCmd cmd) {
|
public boolean execute(ClassExamPaperAddCmd cmd) {
|
||||||
|
Long count = classExamPaperRepository.countByClassId(cmd.getClassId());
|
||||||
|
if (count > 0) {
|
||||||
|
throw new BizException("该班级已存在试卷");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ClassExamPaperE classExamPaperE = new ClassExamPaperE();
|
ClassExamPaperE classExamPaperE = new ClassExamPaperE();
|
||||||
BeanUtils.copyProperties(cmd, classExamPaperE);
|
BeanUtils.copyProperties(cmd, classExamPaperE);
|
||||||
// 初始化字段,并判断题目分数是否符合要求
|
// 初始化字段,并判断题目分数是否符合要求
|
||||||
|
|
@ -58,6 +66,12 @@ public class ClassExamPaperAddExe {
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean executeAutoSave(ClassExamPaperAutoAddCmd cmd) {
|
public boolean executeAutoSave(ClassExamPaperAutoAddCmd cmd) {
|
||||||
|
|
||||||
|
Long count = classExamPaperRepository.countByClassId(cmd.getClassId());
|
||||||
|
if (count > 0) {
|
||||||
|
throw new BizException("该班级已存在试卷");
|
||||||
|
}
|
||||||
|
|
||||||
ClassExamPaperE classExamPaperE = new ClassExamPaperE();
|
ClassExamPaperE classExamPaperE = new ClassExamPaperE();
|
||||||
BeanUtils.copyProperties(cmd, classExamPaperE);
|
BeanUtils.copyProperties(cmd, classExamPaperE);
|
||||||
// 初始化字段,并判断题目分数是否符合要求
|
// 初始化字段,并判断题目分数是否符合要求
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue