xiangpei
2024-07-09 9a7ee496344f044c89deddb70600b7e4d6017e1f
src/main/java/com/ycl/jxkg/service/impl/QuestionServiceImpl.java
@@ -5,19 +5,22 @@
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycl.jxkg.domain.entity.Question;
import com.ycl.jxkg.domain.enums.QuestionTypeEnum;
import com.ycl.jxkg.domain.enums.general.StatusEnum;
import com.ycl.jxkg.domain.other.KeyValue;
import com.ycl.jxkg.domain.question.QuestionItemObject;
import com.ycl.jxkg.domain.question.QuestionObject;
import com.ycl.jxkg.domain.vo.admin.exam.QuestionExportVO;
import com.ycl.jxkg.domain.vo.admin.exam.QuestionImportVO;
import com.ycl.jxkg.domain.vo.admin.question.QuestionEditItemVO;
import com.ycl.jxkg.domain.vo.admin.question.QuestionEditRequestVO;
import com.ycl.jxkg.domain.vo.admin.question.QuestionPageRequestVO;
import com.ycl.jxkg.domain.vo.admin.question.QuestionResponseVO;
import com.ycl.jxkg.enums.QuestionTypeEnum;
import com.ycl.jxkg.enums.general.StatusEnum;
import com.ycl.jxkg.mapper.QuestionMapper;
import com.ycl.jxkg.service.QuestionService;
import com.ycl.jxkg.utils.DateTimeUtil;
import com.ycl.jxkg.utils.ExamUtil;
import com.ycl.jxkg.utils.HtmlUtil;
import com.ycl.jxkg.utils.JsonUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
@@ -60,6 +63,9 @@
        question.setDifficult(model.getDifficult());
        question.setContent(questionObject);
        question.setCreateUser(userId);
        question.setTitle(HtmlUtil.clear(model.getTitle()));
        question.setAudioFile(model.getAudioFile());
        question.setOriginalFile(model.getOriginalFile());
        questionMapper.insert(question);
        return question;
    }
@@ -74,6 +80,9 @@
        //题干、解析、选项等 更新
        String questionObject = setQuestionInfoFromVM(model);
        question.setContent(questionObject);
        question.setTitle(HtmlUtil.clear(model.getTitle()));
        question.setAudioFile(model.getAudioFile());
        question.setOriginalFile(model.getOriginalFile());
        questionMapper.updateById(question);
        return question;
    }
@@ -98,6 +107,7 @@
        switch (questionTypeEnum) {
            case SingleChoice:
            case TrueFalse:
            case Audio:
                questionEditRequestVO.setCorrect(question.getCorrect());
                break;
            case MultipleChoice:
@@ -108,6 +118,8 @@
                questionEditRequestVO.setCorrectArray(correctContent);
                break;
            case ShortAnswer:
            case Calculate:
            case Analysis:
                questionEditRequestVO.setCorrect(questionObject.getCorrect());
                break;
            default:
@@ -169,4 +181,9 @@
                .update();
    }
    @Override
    public List<QuestionImportVO> export(QuestionExportVO query) {
        return questionMapper.export(query);
    }
}