import { request } from "@/utils/request";

import {
  AbsentCheckListParams,
  AbsentCheckListFilter,
  AbsentCheckListResult,
  ExamStatusSaveParams,
  ExamStatusSaveResult,
  AbsentResetParams,
} from "./types/absentCheck";
import { RequestActionResult } from "./types/common";

// 缺考校验列表
export const absentCheckList = (
  data: AbsentCheckListParams
): Promise<AbsentCheckListResult> =>
  request({
    url: "/api/admin/check/exam-status/list",
    method: "post",
    data,
  });

// 提交
export const examStatusSave = (
  data: ExamStatusSaveParams
): Promise<ExamStatusSaveResult> =>
  request({
    url: "/api/admin/check/exam-status/save",
    method: "post",
    data,
  });

// 按考生导出缺考校验
export const absentCheckStudentExport = (
  data: AbsentCheckListFilter
): Promise<AxiosResponse<Blob>> =>
  request({
    url: "/api/admin/check/exam-status/student/export",
    method: "post",
    data,
    download: true,
  });

// 按考场导出缺考校验
export const absentCheckRoomExport = (
  data: AbsentCheckListFilter
): Promise<AxiosResponse<Blob>> =>
  request({
    url: "/api/admin/check/exam-status/exam-room/export",
    method: "post",
    data,
    download: true,
  });

// 缺考校验导入模版
export const absentTemplateDownload = (): Promise<Blob> =>
  request({
    url: "/api/admin/check/exam-status/template",
    method: "post",
    download: true,
  });

// 缺考校验导入进度
export const absentImportStatus = (
  examId: number
): Promise<{ synching: boolean }> =>
  request({
    url: "/api/admin/check/exam-status/import/status",
    method: "post",
    data: { examId },
  });

// 缺考校验导入进度
export const absentReset = (
  data: AbsentResetParams
): Promise<{ synching: boolean }> =>
  request({
    url: "/api/admin/check/exam-status/reset",
    method: "post",
    data,
  });

export const absentResetStatus = (
  examId: number
): Promise<{ synching: boolean }> =>
  request({
    url: "/api/admin/check/exam-status/reset/status",
    method: "post",
    data: { examId },
  });
