package com.ssj.service.kmt.dto;


import com.ssj.framework.basic.utils.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ProblemDetailDto implements Serializable {
    private static final long serialVersionUID = 1L;
    private String pictureId;
    private String studentName;
    private String subject;
    private String grade;
    private String createTime;
    private String problemImage;
    private String[] texts;
    private Object[] images;
    private List<Map<String, Object>> knowledgeList;
    private Map<String, Object> voiceData;
    private List<Map<String, String>> voices;

    public ProblemDetailDto () {
        this.texts = new String[4];
        this.images = new Object[4];
        this.voices = new ArrayList<Map<String, String>>();
        for (int i = 0; i < this.images.length; i++){
            this.images[i] = new ArrayList<String>();
        }
        this.knowledgeList = new ArrayList<Map<String, Object>>();
        this.voiceData = new HashMap<String, Object>();
    }


    public String getPictureId() {
        return pictureId;
    }

    public void setPictureId(String pictureId) {
        this.pictureId = pictureId;
    }

    public Map<String, Object> getVoiceData() {
        return voiceData;
    }

    public void setVoiceData(Map<String, Object> voiceData) {
        this.voiceData = voiceData;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getProblemImage() {
        return problemImage;
    }

    public void setProblemImage(String problemImage) {
        this.problemImage = problemImage;
    }

    public String[] getTexts() {
        return texts;
    }

    public void setTexts(String[] texts) {
        this.texts = texts;
    }

    public void addText (int index, String text){
        if (index > 0 && index <= texts.length){
            this.texts[index - 1] = text;
        }
    }

    public Object[] getImages() {
        return images;
    }

    public void setImages(Object[] images) {
        this.images = images;
    }

    public void addImg (int index, String url) {
        if (index > 0 && index <= images.length && StringUtils.isNotEmpty(url)){
            ((List)this.images[index - 1]).add(url);
        }
    }

    public List<Map<String, Object>> getKnowledgeList() {
        return knowledgeList;
    }

    public void setKnowledgeList(List<Map<String, Object>> knowledgeList) {
        this.knowledgeList = knowledgeList;
    }
    public void addKnowledge(Map<String, Object> knowledge){
        this.knowledgeList.add(knowledge);
    }

    public List<Map<String, String>> getVoices() {
        return voices;
    }

    public void setVoices(List<Map<String, String>> voices) {
        this.voices = voices;
    }

    public void addVoice (String url, String duration, int type){
        Map<String, String> result = new HashMap<String, String>();
        result.put("type", type + "");
        result.put("key", url);
        result.put("duration", duration);
        this.voices.add(result);

    }
}
