import httpClient from '@/utils/http';

import {
  ControllerResponse,
  ExamDeletePaperRequest,
  ExamExamSubjectInfoResponse,
  ExamSplitCompositeSubjectRequest,
  ExamSplitCompositeSubjectResponse,
  ExamUploadPaperAnswerRequest,
  ExamUploadPaperRequest
} from './data-contracts';
export default {
  /**
   * @description 根据type参数删除考试科目的试卷路径或答案路径，type=1清空paper_url，type=2清空paper_answer_url
   */
  deletePaperDelete: (body: ExamDeletePaperRequest) => {
    return httpClient.delete<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-subjects/delete-paper`, { params: body });
  },
  /**
   * @description 创建新科目并替换指定考试科目的绑定关系，实现修改科目功能
   */
  updateExamSubjectCreate: (request: ExamSplitCompositeSubjectRequest) => {
    return httpClient.post<
      ControllerResponse & {
        /** 综合科拆分的响应数据 */
        data?: ExamSplitCompositeSubjectResponse;
      }
    >(`/exam-subjects/update-exam-subject`, { params: request });
  },
  /**
   * @description 根据考试科目ID查询考试科目详细信息，如果是综合科类型会包含其组成的单科信息
   */
  examSubjectsDetail: (id: number) => {
    return httpClient.get<
      ControllerResponse & {
        /** 考试科目详细信息响应，包含考试科目基本信息和关联的科目信息 */
        data?: ExamExamSubjectInfoResponse;
      }
    >(`/exam-subjects/${id}`);
  },
  /**
   * @description 上传考试的原试卷答案文件路径
   */
  uploadAnswerCreate: (id: number, body: ExamUploadPaperAnswerRequest) => {
    return httpClient.post<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-subjects/${id}/upload-answer`, { params: body });
  },
  /**
   * @description 上传考试的原试卷文件路径
   */
  uploadPaperCreate: (id: number, body: ExamUploadPaperRequest) => {
    return httpClient.post<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-subjects/${id}/upload-paper`, { params: body });
  }
};
