package com.ssj.service.kmt.dto;


import com.ssj.conch.constant.CourseConstant;

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

public class KnowledgeGradeDto implements Serializable {

    private static final long serialVersionUID = 1L;

    private String name;

    private int subjectIndex = 0;

    private List<KnowledgeSubjectDto> subjectList = new ArrayList<>();

    private int volumeIndex = 0;

    private List<KnowledgeBaseDto> volumeList = new ArrayList<>();

    public KnowledgeGradeDto (String grade) {
        this.name = grade;
        this.createVolumes();
        this.createSubjectList();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSubjectIndex() {
        return subjectIndex;
    }

    public void setSubjectIndex(int subjectIndex) {
        this.subjectIndex = subjectIndex;
    }

    public List<KnowledgeSubjectDto> getSubjectList() {
        return subjectList;
    }

    public void setSubjectList(List<KnowledgeSubjectDto> subjectList) {
        this.subjectList = subjectList;
    }

    public int getVolumeIndex() {
        return volumeIndex;
    }

    public void setVolumeIndex(int volumeIndex) {
        this.volumeIndex = volumeIndex;
    }

    public List<KnowledgeBaseDto> getVolumeList() {
        return volumeList;
    }

    public void setVolumeList(List<KnowledgeBaseDto> volumeList) {
        this.volumeList = volumeList;
    }

    public void createVolumes () {
        KnowledgeBaseDto temp = new KnowledgeBaseDto(1, "上册");
        this.volumeList.add(temp);
        temp = new KnowledgeBaseDto(2, "下册");
        this.volumeList.add(temp);
    }

    public void createSubjectList () {
        List<String> subjects = CourseConstant.getSubjectList(this.name);
        subjects.forEach(subject -> {
            this.subjectList.add(new KnowledgeSubjectDto(subject));
        });
    }
}
