import axios, { AxiosResponse } from 'axios';

import {
  ScoreSegmentListRes,
  TotalAnalysisListRes,
  CollegeAnalysisListParam,
  CollegeAnalysisFilter,
  CollegeAnalysisListRes,
  TeacherAnalysisListParam,
  TeacherAnalysisFilter,
  TeacherAnalysisListRes,
  ClassAnalysisListParam,
  ClassAnalysisFilter,
  ClassAnalysisListRes,
  QuestionAnalysisListParam,
  QuestionAnalysisFilter,
  QuestionAnalysisListRes,
  BigQuestionAnalysisListRes,
  ScoreSegmentListParam,
  ScoreSegmentFilter,
  AnalysisListPageParam,
  AnalysisListFilter,
  TeacherClassAnalysisListParam,
  TeacherClassAnalysisFilter,
  TeacherClassAnalysisListRes,
} from './types/analysis';

// 总量分析列表
export function getTotalAnalysisList(
  params: AnalysisListPageParam
): Promise<TotalAnalysisListRes> {
  return axios.post('/api/admin/report/subject', params);
}
// 总量分析导出
export function exportTotalAnalysisList(
  params: AnalysisListFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/subject/export', params, {
    responseType: 'blob',
  });
}
// TODO:总量分析总结表导出
export function exportTotalAnalysisSummaryList(
  params: AnalysisListFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/subject/export/summary', params, {
    responseType: 'blob',
  });
}

// 分段统计列表
export function getSegmentAnalysisList(
  params: ScoreSegmentListParam
): Promise<ScoreSegmentListRes> {
  return axios.post('/api/admin/report/range', params);
}

// 分段统计导出
export function exportSegmentAnalysisList(
  params: ScoreSegmentFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/range/export', params, {
    responseType: 'blob',
  });
}

// 学院分析列表
export function getCollegeAnalysisList(
  params: CollegeAnalysisListParam
): Promise<CollegeAnalysisListRes> {
  return axios.post('/api/admin/report/college', params);
}
// 学院分析导出
export function exportCollegeAnalysisList(
  params: CollegeAnalysisFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/college/export', params, {
    responseType: 'blob',
  });
}

// 任课老师分析列表
export function getTeacherAnalysisList(
  params: TeacherAnalysisListParam
): Promise<TeacherAnalysisListRes> {
  return axios.post('/api/admin/report/teacher', params);
}
// 任课老师分析导出
export function exportTeacherAnalysisList(
  params: TeacherAnalysisFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/teacher/export', params, {
    responseType: 'blob',
  });
}

// 任课老师班级分析列表
export function getTeacherClassAnalysisList(
  params: TeacherClassAnalysisListParam
): Promise<TeacherClassAnalysisListRes> {
  return axios.post('/api/admin/report/teacher/class', params);
}
// 任课老师班级分析导出
export function exportTeacherClassAnalysisList(
  params: TeacherClassAnalysisFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/teacher/class/export', params, {
    responseType: 'blob',
  });
}

// 班级分析列表
export function getClassAnalysisList(
  params: ClassAnalysisListParam
): Promise<ClassAnalysisListRes> {
  return axios.post('/api/admin/report/class', params);
}
// 班级分析导出
export function exportClassAnalysisList(
  params: ClassAnalysisFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/class/export', params, {
    responseType: 'blob',
  });
}

// 主客观题分析列表
export function getQuestionAnalysisList(
  params: QuestionAnalysisListParam
): Promise<QuestionAnalysisListRes> {
  return axios.post('/api/admin/report/question', params);
}

// 主客观题分析导出
export function exportQuestionAnalysisList(
  params: QuestionAnalysisFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/question/export', params, {
    responseType: 'blob',
  });
}

// 大题分析列表
export function getBigQuestionAnalysisList(
  params: AnalysisListPageParam
): Promise<BigQuestionAnalysisListRes> {
  return axios.post('/api/admin/report/group', params);
}

// 大题分析导出
export function exportBigQuestionAnalysisList(
  params: AnalysisListFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post('/api/admin/report/group/export', params, {
    responseType: 'blob',
  });
}
