package org.xyzh.common.vo;

import org.xyzh.common.dto.BaseDTO;
import org.xyzh.common.dto.study.TbLearningTask;
import org.xyzh.common.dto.study.TbTaskItem;
import org.xyzh.common.dto.study.TbTaskUser;

import java.util.List;
import java.util.stream.Collectors;

public class TaskVO extends BaseDTO{
    private static final long serialVersionUID = 1L;

    private TbLearningTask learningTask;
    private List<TaskItemVO> taskCourses;
    private List<TaskItemVO> taskResources;
    private List<TaskItemVO> taskUsers;
    private Integer totalTaskNum;
    private Integer completedTaskNum;
    private Integer learningTaskNum;
    private Integer notStartTaskNum;
    private Integer taskStatus;

    public TbLearningTask getLearningTask() {
        return learningTask;
    }
    public void setLearningTask(TbLearningTask learningTask) {
        this.learningTask = learningTask;
    }
    public List<TaskItemVO> getTaskCourses() {
        return taskCourses;
    }
    public void setTaskCourses(List<TaskItemVO> taskCourses) {
        this.taskCourses = taskCourses;
    }
    public List<TaskItemVO> getTaskResources() {
        return taskResources;
    }
    public void setTaskResources(List<TaskItemVO> taskResources) {
        this.taskResources = taskResources;
    }
    public List<TaskItemVO> getTaskUsers() {
        return taskUsers;
    }
    public void setTaskUsers(List<TaskItemVO> taskUsers) {
        this.taskUsers = taskUsers;
    }
    
    public Integer getTotalTaskNum() {
      return totalTaskNum;
    }
    public void setTotalTaskNum(Integer totalTaskNum) {
      this.totalTaskNum = totalTaskNum;
    }
    public Integer getCompletedTaskNum() {
      return completedTaskNum;
    }
    public void setCompletedTaskNum(Integer completedTaskNum) {
      this.completedTaskNum = completedTaskNum;
    }
    public Integer getLearningTaskNum() {
      return learningTaskNum;
    }
    public void setLearningTaskNum(Integer learningTaskNum) {
      this.learningTaskNum = learningTaskNum;
    }
    public Integer getNotStartTaskNum() {
      return notStartTaskNum;
    }
    public void setNotStartTaskNum(Integer notStartTaskNum) {
      this.notStartTaskNum = notStartTaskNum;
    }
    public Integer getTaskStatus() {
      return taskStatus;
    }
    public void setTaskStatus(Integer taskStatus) {
      this.taskStatus = taskStatus;
    }
    public List<TbTaskItem> toTaskCourses() {
      return getTaskCourses().stream().map(TaskItemVO::toTaskItem).collect(Collectors.toList());
    }
    public List<TbTaskItem> toTaskResources() {
      return getTaskResources().stream().map(TaskItemVO::toTaskItem).collect(Collectors.toList());
    }
    public List<TbTaskUser> toTaskUsers() {
      return getTaskUsers().stream().map(TaskItemVO::toTaskUser).collect(Collectors.toList());
    }

    public void setTaskItemList(List<TbTaskItem> taskItems) {
        if (taskItems == null) {
            return;
        }
        this.taskCourses = taskItems.stream()
                .filter(item -> item.getItemType() == 2)
                .map(TaskItemVO::new)
                .collect(Collectors.toList());
        this.taskResources = taskItems.stream()
                .filter(item -> item.getItemType() == 1)
                .map(TaskItemVO::new)
                .collect(Collectors.toList());
    }
    public void setTaskUserList(List<TbTaskUser> taskUsers) {
        if (taskUsers == null) {
            return;
        }
        this.taskUsers = taskUsers.stream().map(item -> {
            return new TaskItemVO(item);
        }).collect(Collectors.toList());
    }
    
    
}
