import httpClient from '@/utils/http';

import {
  ControllerResponse,
  ExamBatchChangePasswordRequest,
  ExamBatchCreateExamVirtualTeacherRequest,
  ExamBatchCreateResponse,
  ExamBatchDeleteExamVirtualTeacherRequest,
  ExamBatchDeleteResponse,
  ExamExamVirtualTeacherCountResponse,
  ExamExamVirtualTeacherListResponse
} from './data-contracts';
export default {
  /**
   * @description 根据考试ID获取考试虚拟阅卷老师列表，支持分页和多种筛选条件，返回用户姓名、账号、学科、题目、阅卷进度等信息
   */
  examVirtualTeachersList: (query: {
    /**
     * 页码，默认1
     * @min 1
     */
    page?: number;
    /**
     * 每页数量，默认10
     * @min 1
     */
    page_size?: number;
    /**
     * 考试ID
     * @min 1
     */
    exam_id: number;
    /**
     * 老师ID
     * @min 1
     */
    teacher_id?: number;
    /**
     * 科目ID
     * @min 1
     */
    subject_id?: number;
    /** 关键词搜索(账号或姓名) */
    keyword?: string;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        /** 考试虚拟阅卷老师列表响应结构 */
        data?: ExamExamVirtualTeacherListResponse;
      }
    >(`/exam-virtual-teachers`, { query: query });
  },
  /**
   * @description 批量创建考试虚拟阅卷老师关联记录
   */
  batchCreate: (teachers: ExamBatchCreateExamVirtualTeacherRequest) => {
    return httpClient.post<
      ControllerResponse & {
        /** 批量创建操作响应 */
        data?: ExamBatchCreateResponse;
      }
    >(`/exam-virtual-teachers/batch`, { params: teachers });
  },
  /**
   * @description 根据ID列表批量删除考试虚拟阅卷老师关联记录
   */
  batchDelete: (teachers: ExamBatchDeleteExamVirtualTeacherRequest) => {
    return httpClient.delete<
      ControllerResponse & {
        /** 批量删除操作响应 */
        data?: ExamBatchDeleteResponse;
      }
    >(`/exam-virtual-teachers/batch`, { params: teachers });
  },
  /**
   * @description 批量修改虚拟阅卷老师的登录密码
   */
  batchChangePasswordCreate: (request: ExamBatchChangePasswordRequest) => {
    return httpClient.post<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-virtual-teachers/batch-change-password`, { params: request });
  },
  /**
   * @description 获取指定考试的各个科目虚拟阅卷老师数量统计，返回考试ID、科目名称、科目ID和人数
   */
  countDetail: (examId: number) => {
    return httpClient.get<
      ControllerResponse & {
        /** 考试各科目虚拟教师数量统计响应 */
        data?: ExamExamVirtualTeacherCountResponse;
      }
    >(`/exam-virtual-teachers/count/${examId}`);
  },
  /**
   * @description 导出指定考试的所有虚拟阅卷老师信息
   */
  exportDetail: (examId: number) => {
    return httpClient.download<Blob>(`/exam-virtual-teachers/export/${examId}`);
  },
  /**
   * @description 根据ID删除单个虚拟阅卷老师
   */
  examVirtualTeachersDelete: (examId: number, id: number) => {
    return httpClient.delete<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-virtual-teachers/${examId}/${id}`);
  }
};
