package com.ruoyi.learn.domain;

import com.google.common.collect.Maps;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

public class TestPaperVO {
    public static enum PaperBuildType {
        Manual, Auto
    }

    @ApiModel("基本组卷请求")
    @Data
    public static class TestPapersBuildReq {
        @ApiModelProperty("名称")
        String title;
        @ApiModelProperty("总分")
        Integer total;

        @ApiModelProperty("批次")
        Integer batchId;
        @ApiModelProperty("省份")
        String location;
        @ApiModelProperty("组卷方式")
        PaperBuildType buildType;
        @ApiModelProperty("是否定向")
        Boolean directType;

        @ApiModelProperty("科目")
        Long subjectId;

        @ApiModelProperty("考生类型")
        List<String> examTypes;
        @ApiModelProperty("班级")
        List<Long> classIds;
        @ApiModelProperty("院校")
        List<Long> universityIds;
        @ApiModelProperty("专业组(单院校有效)")
        List<String> groups;
        @ApiModelProperty("专业组(单专业组有效)")
        List<Long> planIds;

        public Map<String, Object> toMap() {
            Map<String, Object> map = Maps.newHashMap();
            map.put("batchId", batchId);
            map.put("location", location);
            map.put("examTypes", examTypes);
            map.put("classIds", classIds);
            map.put("universityIds", universityIds);
            map.put("groups", groups);
            map.put("planIds", planIds);
            return map;
        }
    }

    @ApiModel("手动组卷请求")
    @Data
    public static class TestPapersBuildManualReq extends TestPapersBuildReq {
        @ApiModelProperty("试题列表")
        List<LearnPaperQuestion> questions;
    }
    @ApiModel("智能组卷请求")
    @Data
    public static class TestPapersBuildAutoReq extends TestPapersBuildReq {
        @ApiModelProperty("试卷要求")
        PaperDef paperDef;
    }

    @ApiModel("批量查询请求")
    @Data
    public static class TestPapersQueryReq {
        @ApiModelProperty("测试卷批次")
        Long batchId;
        @ApiModelProperty("考生类型")
        List<String> examTypes;
        @ApiModelProperty("组卷类型")
        PaperBuildType buildType;
        @ApiModelProperty("发送情况")
        Boolean publicType;

        @ApiModelProperty("班级")
        List<Long> classIds;
        @ApiModelProperty("学生")
        List<Long> studentIds;
    }

    @ApiModel("批量发布请求")
    @Data
    public static class TestPapersPublishReq {
        @ApiModelProperty("测试卷批次")
        Long batchId;
        @ApiModelProperty("考生类型")
        List<String> examTypes;
        @ApiModelProperty("组卷类型")
        PaperBuildType buildType;
        @ApiModelProperty("定向类型 null是全部")
        Boolean directType;
        @ApiModelProperty("试卷ID")
        Long paperId;

        @ApiModelProperty("班级")
        List<Long> classIds;
        @ApiModelProperty("学生")
        List<Long> studentIds;
    }


    @ApiModel("试卷发布请求")
    @Data
    public static class TestPaperPublishReq {
        @ApiModelProperty("测试卷批次")
        Long batchId;
        @ApiModelProperty("试卷ID")
        Long paperId;
        @ApiModelProperty("班级")
        List<Long> classIds;
        @ApiModelProperty("学生")
        List<Long> studentIds;
    }


    @Data
    public static class PaperDef {
        Long total;
        List<Long> knowIds;
        Boolean fillExclude; // 不足时是否填充排除的
        List<TestPaperVO.TypeDef> types;
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class TypeDef {
        String title;
        String type;
        Integer count;
        Integer score;
    }
}
