import axios, { AxiosResponse } from 'axios';
import {
  ReviewStatInfo,
  ReviewStatListPageParams,
  FullReviewListFilter,
  ReviewStatListPageRes,
  FullReviewListPageParams,
  FullReviewListPageRes,
  ScoreCheckListPageRes,
  CheckReviewRes,
  SubjectStatusInfo,
} from './types/review';

// 复核进度 -------->
// 获取复核进度统计信息
export function getReviewStatInfo(): Promise<ReviewStatInfo> {
  return axios.post('/api/admin/exam/inspected/chat', {});
}

// 获取复核进度列表信息
export function getReviewStatList(
  params: ReviewStatListPageParams
): Promise<ReviewStatListPageRes> {
  return axios.post('/api/admin/exam/inspected/info', {}, { params });
}

// 导出复核进度
export function exportReviewStatList(
  params: ReviewStatListPageParams
): Promise<AxiosResponse<Blob>> {
  return axios.post(
    '/api/admin/exam/inspected/info/export',
    {},
    { params, responseType: 'blob' }
  );
}

// 全卷复核 ------->
// 获取全卷复核列表信息
export function getFullReviewList(
  params: FullReviewListPageParams
): Promise<FullReviewListPageRes> {
  return axios.post('/api/admin/exam/inspected/list', {}, { params });
}
// 导出全卷复核列表
export function exportFullReviewList(
  params: FullReviewListFilter
): Promise<AxiosResponse<Blob>> {
  return axios.post(
    '/api/admin/exam/inspected/list/export',
    {},
    { params, responseType: 'blob' }
  );
}

// 再次复核
export function reReview(subjectCode: string): Promise<boolean> {
  return axios.post(
    '/api/admin/exam/inspected/nextround',
    {},
    {
      params: { subjectCode },
    }
  );
}
// 校验是否可以开启再次复核
export function checkReReview(subjectCode: string): Promise<CheckReviewRes> {
  return axios.post(
    '/api/admin/exam/inspected/nextround/check',
    {},
    {
      params: { subjectCode },
    }
  );
}

// 取消复核
export function cancelReview(studentIds: number[]): Promise<CancelReviewRes> {
  return axios.post(
    '/api/admin/exam/inspected/batch-cancel',
    {},
    {
      params: { studentIds },
    }
  );
}

// 复核轮数列表
export function getReviewRoundList(
  params: FullReviewListPageParams
): Promise<number[]> {
  return axios.post(
    '/api/admin/exam/inspected/round/list',
    {},
    {
      params,
    }
  );
}

// 科目状态信息
export function getSubjectStatusInfo(
  params: FullReviewListPageParams
): Promise<SubjectStatusInfo> {
  return axios.post(
    '/api/admin/exam/inspected/subject/status',
    {},
    {
      params,
    }
  );
}

// 复核工作量导出
export function exportReviewWorkload(): Promise<AxiosResponse<Blob>> {
  return axios.post(
    '/api/admin/exam/inspected/work/export',
    {},
    { params, responseType: 'blob' }
  );
}

// TODO: 复核导入模板下载
export function reviewImportTemplate(): Promise<AxiosResponse<Blob>> {
  return axios.post(
    '/api/admin/exam/inspected/import/template/export',
    {},
    { params, responseType: 'blob' }
  );
}

// 获取成绩校验列表信息
export function getScoreCheckList(): Promise<ScoreCheckListPageRes> {
  return axios.post('/api/review/score/check/list', {});
}
