package com.zd.exam.domain;

import com.zd.common.core.annotation.Excel;
import com.zd.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 问题题目(ElQu)实体类
 *
 * @author liubo
 * @since 2021-08-30 15:26:29
 */
@ApiModel(value = "问题题目", description = "题目以及选项")
public class ElQu extends BaseEntity {
    private static final long serialVersionUID = -20894074460230846L;
    /**
     * 题目ID
     */
    @ApiModelProperty(value = "题目ID")
    private Long id;
    /**
     * 学科类别
     */
    @ApiModelProperty(value = "学科类别")
    private Integer code;
    /**
     * 题目类型
     */
    @ApiModelProperty(value = "题目类型")
    @Excel(name = "题目类型", readConverterExp = "1=单选题,2=多选题,3=判断题")
    private Integer quType;
    /**
     * 适用范围(1. 安全准入考试，2. 负面清单考试，3. 黑名单考试，4.模拟考试)
     */
    @ApiModelProperty(value = "适用范围")
    @Excel(name = "适用范围", readConverterExp = "1. 安全准入考试，2. 负面清单考试，3. 黑名单考试，4.模拟考试")
    private Integer scopeType;
    /**
     * 题目难度 1中等,2较难,3难
     */
    @ApiModelProperty(value = "题目难度 1中等,2较难,3难")
    @Excel(name = "题目难度")
    private Integer level;
    /**
     * 题目内容
     */
    @ApiModelProperty(value = "题目内容")
    @Excel(name = "题目内容")
    private String content;
    /**
     * 整题解析
     */
    @ApiModelProperty(value = "整题解析")
    @Excel(name = "整题解析")
    private String analysis;

    @ApiModelProperty(value = "选项列表")
    private List<ElQuAnswer> answerList;

    /**
     * 通过题库ID 查询相关的题目
     */
    @ApiModelProperty(value = "题库ID 检索用")
    private Long poId;

    @ApiModelProperty(value = "题库列表")
    @Deprecated // 2.1 需求删除
    private List<Long> repoIds;

    /**
     * 分类ID 多个以逗号分隔
     */
    @ApiModelProperty(value = "分类ID 多个以逗号分隔")
    private String classifyIds;

    private List<Long> cIds;

    @ApiModelProperty(value = "分类名称 多个以逗号分隔")
    private String classifyNames;

    /**
     * 专业ID 多个以逗号分隔
     */
    @ApiModelProperty(value = "专业ID 多个以逗号分隔")
    private String majorIds;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getQuType() {
        return quType;
    }

    public void setQuType(Integer quType) {
        this.quType = quType;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAnalysis() {
        return analysis;
    }

    public void setAnalysis(String analysis) {
        this.analysis = analysis;
    }

    public List<ElQuAnswer> getAnswerList() {
        return answerList;
    }

    public void setAnswerList(List<ElQuAnswer> answerList) {
        this.answerList = answerList;
    }

    public Integer getScopeType() {
        return scopeType;
    }

    public void setScopeType(Integer scopeType) {
        this.scopeType = scopeType;
    }

    public Long getPoId() {
        return poId;
    }

    public void setPoId(Long poId) {
        this.poId = poId;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getClassifyIds() {
        return classifyIds;
    }

    public void setClassifyIds(String classifyIds) {
        this.classifyIds = classifyIds;
        if(StringUtils.isNotBlank(classifyIds)){
            this.setcIds(Arrays.asList(classifyIds .split(",")).stream().map(s -> (Long.parseLong(s.trim()))).collect(Collectors.toList()));
        }
    }

    public String getMajorIds() {
        return majorIds;
    }

    public void setMajorIds(String majorIds) {
        this.majorIds = majorIds;
    }

    public String getClassifyNames() {
        return classifyNames;
    }

    public void setClassifyNames(String classifyNames) {
        this.classifyNames = classifyNames;
    }

    public List<Long> getcIds() {
        return cIds;
    }

    public void setcIds(List<Long> cIds) {
        this.cIds = cIds;
    }
}
