package cn.com.qmth.examcloud.core.questions.service.bean.dto;

import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
import cn.com.qmth.examcloud.core.questions.dao.entity.Question;

import java.io.Serializable;
import java.util.List;

/**
 * 试卷小题导出dto Created by songyue on 17/3/15.
 */
public class PaperDetailUnitExp implements Serializable, Comparable<PaperDetailUnitExp> {

    private static final long serialVersionUID = 6507445685386413261L;

    private String id;

    private Integer number;// 小题序号

    private Double score;// 小题分数

    private QuesStructType questionType;// 小题类型

    private Question question;// 关联试题

    private String quesId;// 关联试题Id

    private List<Double> subScoreList;// 对应套题的情况下，各子题的分数分布

    private String optionOrder;

    /**
     * 一级属性名称（默认取question中第一个）
     */
    private String firstName;
    private String firstCode;

    /**
     * 二级属性名称（默认取question中第一个）
     */
    private String secondName;
    private String secondCode;

    /**
     * 公开，非公开
     */
    private String publicity;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public PaperDetailUnitExp() {

    }

    public PaperDetailUnitExp(QuesStructType type, Integer number) {
        this.questionType = type;
        this.score = (double) 0;
        this.number = number;
        Question question = new Question();
        question.setQuesAnswer("#");
        this.question = question;
    }

    public PaperDetailUnitExp(QuesStructType type, Question subQuestion) {
        this.questionType = type;
        this.score = subQuestion.getScore();
        this.number = subQuestion.getNumber();
        this.question = subQuestion;
    }

    public String getId() {
        return id;
    }

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

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    public QuesStructType getQuestionType() {
        return questionType;
    }

    public void setQuestionType(QuesStructType questionType) {
        this.questionType = questionType;
    }

    public Question getQuestion() {
        return question;
    }

    public void setQuestion(Question question) {
        this.question = question;
    }

    public String getQuesId() {
        return quesId;
    }

    public void setQuesId(String quesId) {
        this.quesId = quesId;
    }

    public List<Double> getSubScoreList() {
        return subScoreList;
    }

    public void setSubScoreList(List<Double> subScoreList) {
        this.subScoreList = subScoreList;
    }

    public String getOptionOrder() {
        return optionOrder;
    }

    public void setOptionOrder(String optionOrder) {
        this.optionOrder = optionOrder;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getSecondName() {
        return secondName;
    }

    public void setSecondName(String secondName) {
        this.secondName = secondName;
    }

    public String getPublicity() {
        return publicity;
    }

    public void setPublicity(String publicity) {
        this.publicity = publicity;
    }
    

    public String getFirstCode() {
		return firstCode;
	}

	public void setFirstCode(String firstCode) {
		this.firstCode = firstCode;
	}

	public String getSecondCode() {
		return secondCode;
	}

	public void setSecondCode(String secondCode) {
		this.secondCode = secondCode;
	}

	/**
     * 按照number排序
     *
     * @param paperDetailUnitExp
     * @return
     */
    @Override
    public int compareTo(PaperDetailUnitExp paperDetailUnitExp) {
        if (paperDetailUnitExp != null) {
            if (this.getNumber() == null) return -1;
            if (paperDetailUnitExp.getNumber() == null) return 1;
            if (this.getNumber() > paperDetailUnitExp.getNumber()) {
                return 1;
            } else if (this.getNumber() < paperDetailUnitExp.getNumber()) {
                return -1;
            } else {
                return 0;
            }
        }
        return -1;
    }
}
