import httpClient from '@/utils/http';

import {
  ControllerResponse,
  ExamCreateExamSubjectAnswerSheetTemplateRequest,
  ExamCreateExamSubjectAnswerSheetTemplateResponse,
  ExamExamSubjectAnswerSheetTemplate,
  ExamExamSubjectAnswerSheetTemplateDetailResponse,
  ExamUpdateExamSubjectAnswerSheetTemplateRequest
} from './data-contracts';
export default {
  /**
   * @description 创建考试科目答题卡模板信息，支持从raw_info中自动提取答题卡图片和考号位数
   */
  examSubjectAnswerSheetTemplateCreate: (
    template: ExamCreateExamSubjectAnswerSheetTemplateRequest
  ) => {
    return httpClient.post<
      ControllerResponse & {
        /** 创建考试答题卡模板的响应体 */
        data?: ExamCreateExamSubjectAnswerSheetTemplateResponse;
      }
    >(`/exam-subject-answer-sheet-template/`, { params: template });
  },
  /**
   * @description 获取考试科目答题卡模板列表
   */
  examSubjectAnswerSheetTemplateList: () => {
    return httpClient.get<
      ControllerResponse & {
        data?: ExamExamSubjectAnswerSheetTemplate[];
      }
    >(`/exam-subject-answer-sheet-template/`);
  },
  /**
   * @description 根据考试科目ID获取该科目下的所有答题卡模板
   */
  examSubjectDetail: (examSubjectId: number) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ExamExamSubjectAnswerSheetTemplate[];
      }
    >(`/exam-subject-answer-sheet-template/exam-subject/${examSubjectId}`);
  },
  /**
   * @description 根据ID更新考试科目答题卡模板信息，支持从raw_info中自动提取答题卡图片和考号位数
   */
  examSubjectAnswerSheetTemplateUpdate: (
    id: number,
    template: ExamUpdateExamSubjectAnswerSheetTemplateRequest
  ) => {
    return httpClient.put<
      ControllerResponse & {
        data?: object;
      }
    >(`/exam-subject-answer-sheet-template/${id}`, { params: template });
  },
  /**
   * @description 根据ID删除考试科目答题卡模板
   */
  examSubjectAnswerSheetTemplateDelete: (id: number) => {
    return httpClient.delete<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-subject-answer-sheet-template/${id}`);
  },
  /**
   * @description 根据模板ID获取模板的详细信息，包括模板基本信息和题目列表
   */
  detailDetail: (id: number) => {
    return httpClient.get<
      ControllerResponse & {
        /** 考试科目答题卡模板详情响应体，包含模板信息和题目列表 */
        data?: ExamExamSubjectAnswerSheetTemplateDetailResponse;
      }
    >(`/exam-subject-answer-sheet-template/${id}/detail`);
  }
};
