import httpClient from '@/utils/http';

import {
  ControllerResponse,
  ExamBatchAbsentOperationResponse,
  ExamBatchSetAbsentToZeroRequest,
  ExamBatchSetZeroToAbsentRequest,
  ExamScoreOverviewResponse,
  ExamSetStudentAbsentRequest,
  ExamStatisticsClassAnalysisExcelExportRequestVO,
  ExamStatisticsClassAnalysisRequestVO,
  ExamStatisticsClassAnalysisResponseVO,
  ExamStatisticsClassExportRequestVO,
  ExamStatisticsClassReportExportRequestVO,
  ExamStatisticsExcelExportRequestVO,
  ExamStatisticsQuestionAnalysisExcelExportRequestVO,
  ExamStatisticsQuestionAnalysisRequestVO,
  ExamStatisticsQuestionAnalysisResponseVO,
  ExamStatisticsQuestionExcelExportRequestVO,
  ExamStatisticsQuestionRankingRequestVO,
  ExamStatisticsQuestionRankingResponseVO,
  ExamStatisticsSchoolExportRequestVO,
  ExamStatisticsScoreAnalysisExcelExportRequestVO,
  ExamStatisticsScoreAnalysisRequestVO,
  ExamStatisticsScoreAnalysisResponseVO,
  ExamStatisticsScoreRankingRequestVO,
  ExamStatisticsScoreRankingResponseVO,
  ExamStatisticsSetLevelConfigRequestVO,
  ExamStatisticsSetLevelConfigResponseVO,
  ExamStatisticsStatisticsAnalysisExcelExportRequestVO,
  ExamStatisticsStatisticsAnalysisRequestVO,
  ExamStatisticsStatisticsAnalysisResponseVO,
  ExamStatisticsSubjectClassAnalysisExcelExportRequestVO,
  ExamStatisticsSubjectClassAnalysisRequestVO,
  ExamStatisticsSubjectClassAnalysisResponseVO,
  ExamStudentAbsentOperationResponse,
  ExamStudentScoreListRequest,
  ExamStudentScoreListResponse,
  ScoreReportClassExamComparisonDataVO,
  ScoreReportClassExamComparisonRequestVO
} from './data-contracts';
export default {
  /**
   * @description 根据条件查询学科的试题统计数据，支持按班级、学校筛选，支持多种分析类型和指标
   */
  averageComparisonCreate: (request: ExamStatisticsQuestionAnalysisRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsQuestionAnalysisResponseVO;
      }
    >(`/exam-statistics/average-comparison`, { params: request });
  },
  /**
   * @description 将指定学校的缺考学生成绩设置为0分，用于统计计算
   */
  batchSetAbsentToZeroCreate: (request: ExamBatchSetAbsentToZeroRequest) => {
    return httpClient.post<
      ControllerResponse & {
        /** 批量缺考操作的响应结果 */
        data?: ExamBatchAbsentOperationResponse;
      }
    >(`/exam-statistics/batch-set-absent-to-zero`, { params: request });
  },
  /**
   * @description 将指定学校的0分学生标记为缺考状态，并删除成绩统计记录
   */
  batchSetZeroToAbsentCreate: (request: ExamBatchSetZeroToAbsentRequest) => {
    return httpClient.post<
      ControllerResponse & {
        /** 批量缺考操作的响应结果 */
        data?: ExamBatchAbsentOperationResponse;
      }
    >(`/exam-statistics/batch-set-zero-to-absent`, { params: request });
  },
  /**
   * @description 根据条件获取总分分档上线人数分布，支持按学校或班级分组统计
   */
  classAnalysisCreate: (request: ExamStatisticsClassAnalysisRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsClassAnalysisResponseVO;
      }
    >(`/exam-statistics/class-analysis`, { params: request });
  },
  /**
   * @description 获取指定班级的所有考试对比数据，包括班级平均分、排名、标准分和年级前50名人数
   */
  classExamComparisonCreate: (request: ScoreReportClassExamComparisonRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ScoreReportClassExamComparisonDataVO;
      }
    >(`/exam-statistics/class-exam-comparison`, { params: request });
  },
  /**
   * @description 按班级导出成绩数据，每个班级一个sheet，文件名使用考试名称+成绩表
   */
  exportByClassesCreate: (request: ExamStatisticsClassExportRequestVO) => {
    return httpClient.download<Blob>(`/exam-statistics/export-by-classes`, { params: request });
  },
  /**
   * @description 按学校分别导出成绩数据，返回压缩包，每个学校一个文件夹
   */
  exportBySchoolsCreate: (request: ExamStatisticsSchoolExportRequestVO) => {
    return httpClient.download<Blob>(`/exam-statistics/export-by-schools`, { params: request });
  },
  /**
   * @description 导出总分分档分析数据到Excel文件
   */
  exportClassAnalysisExcelCreate: (request: ExamStatisticsClassAnalysisExcelExportRequestVO) => {
    return httpClient.download<Blob>(`/exam-statistics/export-class-analysis-excel`, {
      params: request
    });
  },
  /**
   * @description 导出班级成绩单ZIP文件，每个班级一个Excel，每个科目一个sheet，包含小分排名的所有指标
   */
  exportClassReportsCreate: (request: ExamStatisticsClassReportExportRequestVO) => {
    return httpClient.download<Blob>(`/exam-statistics/export-class-reports`, { params: request });
  },
  /**
   * @description 根据条件导出学生成绩排名Excel文件，支持复合表头格式
   */
  exportExcelCreate: (request: ExamStatisticsExcelExportRequestVO) => {
    return httpClient.download<Blob>(`/exam-statistics/export-excel`, { params: request });
  },
  /**
   * @description 导出试题分析数据到Excel文件，包含各题目的统计指标和对比数据
   */
  exportQuestionAnalysisExcelCreate: (
    request: ExamStatisticsQuestionAnalysisExcelExportRequestVO
  ) => {
    return httpClient.download<Blob>(`/exam-statistics/export-question-analysis-excel`, {
      params: request
    });
  },
  /**
   * @description 根据条件导出学生题目级成绩排名Excel文件
   */
  exportQuestionRankingExcelCreate: (request: ExamStatisticsQuestionExcelExportRequestVO) => {
    return httpClient.download<Blob>(`/exam-statistics/export-question-ranking-excel`, {
      params: request
    });
  },
  /**
   * @description 导出均分分析数据到Excel文件，包含各班级/学校的统计指标对比
   */
  exportScoreAnalysisExcelCreate: (request: ExamStatisticsScoreAnalysisExcelExportRequestVO) => {
    return httpClient.download<Blob>(`/exam-statistics/export-score-analysis-excel`, {
      params: request
    });
  },
  /**
   * @description 导出统计分析数据到Excel文件，支持名次统计、分数段统计、比例段统计
   */
  exportStatisticsAnalysisExcelCreate: (
    request: ExamStatisticsStatisticsAnalysisExcelExportRequestVO
  ) => {
    return httpClient.download<Blob>(`/exam-statistics/export-statistics-analysis-excel`, {
      params: request
    });
  },
  /**
   * @description 导出学科分档分析数据到Excel文件
   */
  exportSubjectClassAnalysisExcelCreate: (
    request: ExamStatisticsSubjectClassAnalysisExcelExportRequestVO
  ) => {
    return httpClient.download<Blob>(`/exam-statistics/export-subject-class-analysis-excel`, {
      params: request
    });
  },
  /**
   * @description 根据考试ID和学科ID查询学生的题目级成绩排名
   */
  questionRankingCreate: (request: ExamStatisticsQuestionRankingRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsQuestionRankingResponseVO;
      }
    >(`/exam-statistics/question-ranking`, { params: request });
  },
  /**
   * @description 根据条件查询学校或班级的均分分析数据，包括各类统计指标和排名
   */
  scoreAnalysisCreate: (request: ExamStatisticsScoreAnalysisRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsScoreAnalysisResponseVO;
      }
    >(`/exam-statistics/score-analysis`, { params: request });
  },
  /**
   * @description 获取指定考试科目的成绩总览，包括基本统计信息和排名列表（联考显示学校排名，单校显示班级排名）
   */
  scoreOverviewDetail: (examId: number, examSubjectId: number) => {
    return httpClient.get<
      ControllerResponse & {
        /** 考试科目成绩总览响应 */
        data?: ExamScoreOverviewResponse;
      }
    >(`/exam-statistics/score-overview/${examId}/${examSubjectId}`);
  },
  /**
   * @description 根据条件查询学生成绩排名，支持按班级、学校筛选，支持联考模式和赋分计算，支持按姓名、学号、考号搜索
   */
  scoreRankingCreate: (request: ExamStatisticsScoreRankingRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsScoreRankingResponseVO;
      }
    >(`/exam-statistics/score-ranking`, { params: request });
  },
  /**
   * @description 设置单个学生为缺考或取消缺考状态
   */
  setStudentAbsentCreate: (request: ExamSetStudentAbsentRequest) => {
    return httpClient.post<
      ControllerResponse & {
        /** 单个学生缺考操作的响应结果 */
        data?: ExamStudentAbsentOperationResponse;
      }
    >(`/exam-statistics/set-student-absent`, { params: request });
  },
  /**
   * @description 设置考试的统计配置，支持多种配置类型和规则
   */
  statisConfigCreate: (request: ExamStatisticsSetLevelConfigRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsSetLevelConfigResponseVO;
      }
    >(`/exam-statistics/statis-config`, { params: request });
  },
  /**
   * @description 获取指定考试的统计配置信息，支持多种配置类型
   */
  statisConfigList: (query: {
    /** 考试ID */
    exam_id: number;
    /** 配置类型 */
    config_type: string;
    /** 科目ID（可选，不传则返回所有科目配置） */
    subject_id?: number;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        data?: any;
      }
    >(`/exam-statistics/statis-config`, { query: query });
  },
  /**
   * @description 根据分析类型获取统计分析数据，支持名次统计、分数段统计、比例段统计
   */
  statisticsAnalysisCreate: (request: ExamStatisticsStatisticsAnalysisRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsStatisticsAnalysisResponseVO;
      }
    >(`/exam-statistics/statistics-analysis`, { params: request });
  },
  /**
   * @description 根据考试ID和学科ID查询学生成绩列表，支持按学校、类型、关键词筛选
   */
  studentScoreListCreate: (request: ExamStudentScoreListRequest) => {
    return httpClient.post<
      ControllerResponse & {
        /** 学生成绩列表的响应结果 */
        data?: ExamStudentScoreListResponse;
      }
    >(`/exam-statistics/student-score-list`, { params: request });
  },
  /**
   * @description 根据条件获取学科分档上线人数分布，支持按学校或班级分组统计
   */
  subjectClassAnalysisCreate: (request: ExamStatisticsSubjectClassAnalysisRequestVO) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamStatisticsSubjectClassAnalysisResponseVO;
      }
    >(`/exam-statistics/subject-class-analysis`, { params: request });
  }
};
