package com.ssj.service.sys.homework.request;

import com.ssj.bean.common.framework.core.domain.BaseRequest;
import com.ssj.service.kmt.dto.CompositionCommentDto;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;

import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;

public class CorrectionRequest extends BaseRequest {
    private static final long serialVersionUID = 1L;

    private String homeworkPictureId;

    private long correctBeginTime;

    private long correctEndTime;

    /**
     * 类型，2已反馈，4未勾选, 6作业不全
     */
    private int type;

    private String homeworkPictureEditPath;

    private List<CorrectionQuestionRequest> answerList = new ArrayList<>();

    private int knowledgeVersion;

    private String grade;

    private int semester;

    private List<CorrectionKnowledgeDetail> knowledgeDetails = new ArrayList<>();

    private List<CompositionCommentDto> compositionCommentList = new ArrayList<>();

    private String homeworkComment;

    public String getHomeworkComment() {
        return homeworkComment;
    }

    public void setHomeworkComment(String homeworkComment) {
        this.homeworkComment = homeworkComment;
    }

    public String getHomeworkPictureId() {
        return homeworkPictureId;
    }

    public void setHomeworkPictureId(String homeworkPictureId) {
        this.homeworkPictureId = homeworkPictureId;
    }

    public long getCorrectBeginTime() {
        return correctBeginTime;
    }

    public void setCorrectBeginTime(long correctBeginTime) {
        this.correctBeginTime = correctBeginTime;
    }

    public long getCorrectEndTime() {
        return correctEndTime;
    }

    public void setCorrectEndTime(long correctEndTime) {
        this.correctEndTime = correctEndTime;
    }

    public String getHomeworkPictureEditPath() {
        return homeworkPictureEditPath;
    }

    public void setHomeworkPictureEditPath(String homeworkPictureEditPath) {
        this.homeworkPictureEditPath = homeworkPictureEditPath;
    }

    public List<CorrectionQuestionRequest> getAnswerList() {
        return answerList;
    }

    public void setAnswerList(List<CorrectionQuestionRequest> answerList) {
        this.answerList = answerList.stream().collect(collectingAndThen(
                toCollection(() -> new TreeSet<>(Comparator.comparing(CorrectionQuestionRequest::getQuestionId))), ArrayList::new));
    }

    public int getKnowledgeVersion() {
        return knowledgeVersion;
    }

    public void setKnowledgeVersion(int knowledgeVersion) {
        this.knowledgeVersion = knowledgeVersion;
    }

    public List<CorrectionKnowledgeDetail> getKnowledgeDetails() {
        return knowledgeDetails;
    }

    public void setKnowledgeDetails(List<CorrectionKnowledgeDetail> knowledgeDetails) {
        this.knowledgeDetails = knowledgeDetails.stream().collect(collectingAndThen(
                toCollection(() -> new TreeSet<>(Comparator.comparing(CorrectionKnowledgeDetail::getDetailId))), ArrayList::new));
    }

    public int getType() {
        return type;
    }

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

    public List<CompositionCommentDto> getCompositionCommentList() {
        return compositionCommentList;
    }

    public void setCompositionCommentList(List<CompositionCommentDto> compositionCommentList) {
        this.compositionCommentList = compositionCommentList;
    }

    public String getGrade() {
        return grade;
    }

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

    public int getSemester() {
        return semester;
    }

    public void setSemester(int semester) {
        this.semester = semester;
    }
}
