package com.ssj.service.conch.teacher.dto;

import com.ssj.conch.constant.CourseConstant;

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

/**
 * @author chchen
 * @date 2018/9/26 9:28
 */
public class SubjectParamDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String subject;

    /**
     * 	1全部完成 2部分完成 3无作业
     */
    private int finishState;

    private int costTime;

    private long beginTime;

    private int type;

    /**
     * 用于前端，这里只做定义
     */
    private String timeStr;

    private List<LabelStateDto> unfinishedList;

    private List<HomeworkPictureDto> homeworkPictureList;

    public SubjectParamDto (){
        unfinishedList = new ArrayList<>();
        homeworkPictureList = new ArrayList<>();
    }

    public String getSubject() {
        return subject;
    }

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

    public int getFinishState() {
        return finishState;
    }

    public void setFinishState(int finishState) {
        this.finishState = finishState;
    }

    public int getCostTime() {
        return costTime;
    }

    public void setCostTime(int costTime) {
        this.costTime = costTime;
    }

    public long getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(long beginTime) {
        this.beginTime = beginTime;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTimeStr() {
        return timeStr;
    }

    public void setTimeStr(String timeStr) {
        this.timeStr = timeStr;
    }

    public List<LabelStateDto> getUnfinishedList() {
        return unfinishedList;
    }

    public void setUnfinishedList(List<LabelStateDto> unfinishedList) {
        this.unfinishedList = unfinishedList;
    }

    public List<HomeworkPictureDto> getHomeworkPictureList() {
        return homeworkPictureList;
    }

    public void setHomeworkPictureList(List<HomeworkPictureDto> homeworkPictureList) {
        this.homeworkPictureList = homeworkPictureList;
    }

    public void addHomeworkPicture(HomeworkPictureDto hpd){
        this.homeworkPictureList.add(hpd);
    }


    public void initUnfinishOption(){
        if (this.unfinishedList == null){
            this.unfinishedList = new ArrayList<LabelStateDto>();
        }
        for (Map<String, Object> map : CourseConstant.SUBJECT_ITEM_TITLE) {
             if (map.get("subject").toString().equals(this.subject)){
                 String[] list = (String[])map.get("list");
                 for (String key : list){
                     LabelStateDto item = new LabelStateDto();
                     item.setName(key);
                     item.setActive(0);
                     this.unfinishedList.add(item);
                 }
             }
        }
    }
}
