package com.yidianling.im.session.extension;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yidianling.im.session.viewholder.bean.QuestionItemBean;

import java.util.ArrayList;

public class CustomAttachLingxiAnswerQuestion extends CustomAttachment{
    private final String ANSWERS = "answers";
    private final String QUESTIONID = "questionId";
    private final String EXAMID = "examId";


    public ArrayList<QuestionItemBean> answers;
    public String questionId;
    public String examId;

    public CustomAttachLingxiAnswerQuestion() {
        super(CustomAttachmentType.TYPE_LINGXI_ANSWER_QUESTION);
    }
    @Override
    protected void parseData(JSONObject data) {
        this.answers=(ArrayList<QuestionItemBean>) JSON.parseArray(data.getString(ANSWERS), QuestionItemBean.class);
        this.questionId = data.getString(QUESTIONID);
        this.examId = data.getString(EXAMID);
    }

    @Override
    protected JSONObject packData() {
        JSONObject data = new JSONObject();
        data.put(ANSWERS, answers);
        data.put(QUESTIONID, questionId);
        data.put(EXAMID, examId);
        return data;
    }
}
