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

import {
  ExamParams,
  ExamPageParams,
  ExamSubjectParams,
  RequestActionResult,
} from "./types/common";
import {
  BreachListItem,
  StudentStatusListItem,
  MarkSiteListPageResult,
  MarkSiteSaveParams,
  markSiteSetParams,
  dbfExportProgressResult,
} from "./types/resultExport";

// 违纪导入
export const breachList = (data: ExamParams): Promise<BreachListItem[]> =>
  request({
    url: "/api/admin/subject/breach/list",
    method: "post",
    data,
  });

export const breachTemplateDownload = (): Promise<AxiosResponse<Blob>> =>
  request({
    url: "/api/admin/student/breach/template",
    method: "post",
    data: {},
    download: true,
  });

// 考生状态
export const studentStatusList = (
  data: ExamParams
): Promise<StudentStatusListItem[]> =>
  request({
    url: "/api/admin/subject/cust-status/list",
    method: "post",
    data,
  });

export const statusTemplateDownload = (): Promise<AxiosResponse<Blob>> =>
  request({
    url: "/api/admin/student/cust-status/template",
    method: "post",
    data: {},
    download: true,
  });

// 评卷点
export const markSiteListPage = (
  data: ExamPageParams
): Promise<MarkSiteListPageResult> =>
  request({
    url: "/api/admin/mark-site/page",
    method: "post",
    data,
  });

export const markSiteSave = (
  data: MarkSiteSaveParams
): Promise<RequestActionResult> =>
  request({
    url: "/api/admin/mark-site/save",
    method: "post",
    data,
  });

export const markSiteDelete = (id: string): Promise<RequestActionResult> =>
  request({
    url: "/api/admin/mark-site/delete",
    method: "post",
    data: { id },
  });

// 扫描点代码
export const markSiteCodeSet = (
  data: markSiteSetParams
): Promise<RequestActionResult> =>
  request({
    url: "/api/admin/exam/scan-site/save",
    method: "post",
    data,
  });

export const markSiteCodeInfo = (data: ExamParams): Promise<string> =>
  request({
    url: "/api/admin/exam/scan-site",
    method: "post",
    data,
  });

// DBF导出
// 导出扫描答案DBF
export const dbfAnswerExport = (
  data: ExamSubjectParams
): Promise<{ taskId: string }> =>
  request({
    url: "/api/admin/subject/answer-data/export",
    method: "post",
    data,
  });
// 导出打包DBF
export const dbfPackageExport = (
  data: ExamSubjectParams
): Promise<{ taskId: string }> =>
  request({
    url: "/api/admin/subject/slice-data/export",
    method: "post",
    data,
  });

export const dbfExportProgress = (
  taskId: string
): Promise<dbfExportProgressResult> =>
  request({
    url: "/api/admin/subject/data/progress",
    method: "post",
    data: { taskId },
  });

export const dbfExportTaskDownload = (taskId: string): Promise<blob> =>
  request({
    url: "/api/admin/subject/data/down",
    method: "post",
    data: { taskId },
    download: true,
  });
