package com.ssj.service.kmt.dto;


import com.ssj.framework.basic.utils.DateHelper;
import org.apache.commons.lang3.StringUtils;

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

public class SubjectStudentDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String name;
    /**
     * 日期 yyyy-MM-dd
     */
    private String time;
    private List<StudentProblemDto> list;

    public SubjectStudentDto (String subject, Date date) {
        this.name = subject;
        this.setTime(date);
        list = new ArrayList<StudentProblemDto>();
    }

    public String getName() {
        return name;
    }

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

    public String getTime() {
        return this.time;
    }

    public void setTime(Date date) {
        this.time = DateHelper.getDateTime(date);
    }

    public List<StudentProblemDto> getList() {
        return list;
    }

    public void setList(List<StudentProblemDto> list) {
        this.list = list;
    }

    public void addStudent (StudentProblemDto student) {
        this.list.add(student);
    }

    public void addProblem (String vipId, ProblemDto problem) {
        if (StringUtils.isNotEmpty(vipId)){
            for (StudentProblemDto sp : list){
                if (sp.getVipId().equals(vipId)){
                    sp.getpList().add(problem);
                    break;
                }
            }
        }
    }

    public boolean containStudent (String vipId) {
        boolean result = false;
        if (StringUtils.isNotEmpty(vipId)){
            for (StudentProblemDto sp : list){
                if (sp.getVipId().equals(vipId)){
                    result = true;
                    break;
                }
            }
        }
        return result;
    }
}
