package jnpf.model.cultivate.v2.question.req;

import jnpf.model.cultivate.po.question.FtbCultivateQuestion;
import jnpf.model.cultivate.req.questionbank.QuestionOptionReq;
import jnpf.model.enums.CourseEnums;
import jnpf.util.FtbUtil;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

@Data
public class V2AddQuestionReq {


    /**
     * 题型（1单选，2多选，3判断，4填空，5简答，6组合， 7、不定项选择题）
     */
    @NotNull(message = "题型-不能为空")
    private Integer type;


    /**
     * 难度（1易，2中，3难）
     */
    @NotNull(message = "题目难度-不能为空")
    private Integer difficulty;

    /**
     * 题目内容
     */
    @NotBlank(message = "题目内容-不能为空")
    private String content;


    /**
     * 解析
     */
    private String analysis;

    /**
     * 问答题答案
     */
    private String answer;
    /**
     * 题目选项列表
     */

    private List<QuestionOptionReq> optionList;


    public FtbCultivateQuestion convertData(String questionBankId) {
        FtbCultivateQuestion question = new FtbCultivateQuestion();
        question.setId(FtbUtil.getId());
        question.setClassifyId(questionBankId);
        question.setType(getType());
        question.setDifficulty(getDifficulty());
        question.setContent(getContent());
        question.setAnalysis(getAnalysis());
        question.setEnabledMark(CourseEnums.EnabledMarkType.VALID.getCode());
        question.setCreatorTime(new Date());
        question.setLastModifyTime(new Date());
        question.setAnswer(getAnswer());
        return question;
    }
}
