package com.ssj.service.kmt.request;

import com.ssj.bean.common.framework.core.domain.BaseRequest;
import io.swagger.annotations.ApiModelProperty;

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 AuditingV1Request extends BaseRequest{

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(name = "type", value = "类型， 0提交审核，1发布，4解析提交，5解析发布，6答案校对修改， 默认0", required = true)
    private int type;
    @ApiModelProperty(name = "questions", value = "题目ids", required = true)
    private List<QuestionUpdateRequest> questions;

    @ApiModelProperty(name = "detailIds", value = "关联的知识点", required = false)
    private List<HowDetailPointsRequest> detailIds;

    @ApiModelProperty(name = "parentId", value = "大题的id", required = false)
    private String parentId;

    public int getType() {
        return type;
    }

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

    public List<QuestionUpdateRequest> getQuestions() {
        return questions;
    }

    public void setQuestions(List<QuestionUpdateRequest> questions) {
        this.questions = questions;
    }

    public List<HowDetailPointsRequest> getDetailIds() {
        return detailIds;
    }

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

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
}