package com.yidianling.im.session.extension;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean;
import com.yidianling.im.session.viewholder.bean.QuestionItemBean;
import com.yidianling.uikit.custom.http.response.RecommendExpertBean;

import java.util.ArrayList;
import java.util.List;

public class CustomAttachLingxiWhichQuestion extends CustomAttachment {
    private final String XQUESTIONPAPERID = "xquestionPaperId";//试卷id
    private final String XQUESTIONPAPERNAME = "xquestionPaperName";//试卷名称
    private final String QUESTIONID = "questionId";//问题id
    private final String QUESTIONTITLE = "questionTitle";//问题题目
    private final String SELECTTYPE = "selectType";//选项类型：1单选，2多选
    private final String SELECTVALS = "selectVals";//选项


    public String xquestionPaperId;
    public String xquestionPaperName;
    public String questionId;
    public String questionTitle;
    public String selectType;
    public List<QuestionItemBean> selectVals;

    public CustomAttachLingxiWhichQuestion() {
        super(CustomAttachmentType.TYPE_LINGXI_WHICH_QUESTION);
    }

    @Override
    protected void parseData(JSONObject data) {
        this.xquestionPaperId = data.getString(XQUESTIONPAPERID);
        this.xquestionPaperName = data.getString(XQUESTIONPAPERNAME);
        this.questionId = data.getString(QUESTIONID);
        this.questionTitle = data.getString(QUESTIONTITLE);
        this.selectType = data.getString(SELECTTYPE);
        this.selectVals=(ArrayList<QuestionItemBean>)JSON.parseArray(data.getString(SELECTVALS), QuestionItemBean.class);

    }

    @Override
    protected JSONObject packData() {
        JSONObject data = new JSONObject();
        data.put(XQUESTIONPAPERID, xquestionPaperId);
        data.put(XQUESTIONPAPERNAME, xquestionPaperName);
        data.put(QUESTIONID, questionId);
        data.put(QUESTIONTITLE, questionTitle);
        data.put(SELECTTYPE, selectType);
        data.put(SELECTVALS, selectVals);
        return data;
    }
}
