import httpClient from '@/utils/http';

import {
  ControllerResponse,
  ExamCreateExamAdminRequest,
  ExamDeleteExamAdminRequest,
  ExamExamAdminListResponse,
  ExamExamAdminResponse,
  ExamUpdateExamAdminRequest
} from './data-contracts';
export default {
  /**
   * @description 创建新的考试管理员，需要指定考试ID、学校ID、教师ID、角色ID等信息
   */
  examAdminsCreate: (examId: number, request: ExamCreateExamAdminRequest) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ExamExamAdminResponse;
      }
    >(`/exam-admins/${examId}`, { params: request });
  },
  /**
   * @description 根据考试ID获取该考试的所有管理员数据，支持分页和筛选条件
   */
  examAdminsDetail: (
    examId: number,
    query: {
      /**
       * 页码，默认1
       * @min 1
       */
      page?: number;
      /**
       * 每页数量，默认10，最大100
       * @min 1
       * @max 100
       */
      page_size?: number;
      /**
       * 学校ID
       * @min 1
       */
      school_id?: number;
      /**
       * 姓名（模糊查询）
       * @maxLength 50
       */
      name?: string;
      /** 角色ID */
      role_id?: string;
      /**
       * 科目
       * @maxLength 100
       */
      subject?: string;
    }
  ) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ExamExamAdminListResponse;
      }
    >(`/exam-admins/${examId}`, { query: query });
  },
  /**
   * @description 批量删除指定考试的管理员，支持单个或多个ID
   */
  examAdminsDelete: (examId: number, request: ExamDeleteExamAdminRequest) => {
    return httpClient.delete<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-admins/${examId}`, { params: request });
  },
  /**
   * @description 更新指定考试的管理员信息
   */
  examAdminsUpdate: (examId: number, id: number, request: ExamUpdateExamAdminRequest) => {
    return httpClient.put<
      ControllerResponse & {
        data?: ExamExamAdminResponse;
      }
    >(`/exam-admins/${examId}/${id}`, { params: request });
  }
};
