import httpClient from '@/utils/http';

import {
  ControllerResponse,
  ExamQuestionSubjectDivisionResponse,
  ExamSetQuestionSubjectRequest,
  ModelCreateExamMarkingSettingRequest,
  ModelExamMarkingSettingResponse,
  ModelExamMarkingSettingTopicResponse,
  ModelSchool,
  ModelSetReviewTimeRequest,
  ModelTeacher,
  ServiceIntelligentMarkingRequest,
  ServiceObjectiveAnswerSettingRequest,
  ServiceTaskAllocationRequest,
  ServiceTaskAllocationReuseRequest
} from './data-contracts';
export default {
  /**
   * @description 创建新的阅卷设置，包含考试ID、模板ID等基本信息和题目设置。如果已存在相同的考试和模板设置，会先删除旧的设置再创建新的。
   */
  examMarkingSettingsCreate: (setting: ModelCreateExamMarkingSettingRequest) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ModelExamMarkingSettingResponse;
      }
    >(`/exam-marking-settings`, { params: setting });
  },
  /**
   * @description 根据考试ID和模板ID查询阅卷设置详情
   */
  examMarkingSettingsList: (query: {
    /**
     * 考试ID
     * @min 1
     */
    exam_id: number;
    /**
     * 模板ID
     * @min 1
     */
    template_id: number;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ModelExamMarkingSettingResponse;
      }
    >(`/exam-marking-settings`, { query: query });
  },
  /**
   * @description 设置综合科题目对应的单科类型
   */
  questionsSetSubjectCreate: (request: ExamSetQuestionSubjectRequest) => {
    return httpClient.post<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-marking-settings/questions/set-subject`, { params: request });
  },
  /**
   * @description 根据exam_id和exam_subject_id查询综合科的题目拆分科目列表
   */
  questionsSubjectDivisionList: (query: {
    /**
     * 考试ID
     * @format int64
     */
    exam_id: number;
    /**
     * 考试科目ID
     * @format int64
     */
    exam_subject_id: number;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ExamQuestionSubjectDivisionResponse[];
      }
    >(`/exam-marking-settings/questions/subject-division`, { query: query });
  },
  /**
   * @description 根据考试科目ID查询参加该科目的所有学校信息
   */
  schoolsList: (query: {
    /**
     * 考试科目ID
     * @min 1
     */
    exam_subject_id?: number;
    /**
     * 考试ID（兼容性参数）
     * @min 1
     */
    exam_id?: number;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ModelSchool[];
      }
    >(`/exam-marking-settings/schools`, { query: query });
  },
  /**
   * @description 参数为考试科目ID与可选姓名，返回与该考试科目绑定的年级/班级的教师
   */
  teachersByExamSubjectList: (query: {
    /** 考试科目ID */
    exam_subject_id: number;
    /** 学校ID（可选） */
    school_id?: number;
    /** 教师姓名（模糊） */
    name?: string;
    /**
     * 是否查询虚拟教师，默认false
     * @default false
     */
    is_virtual?: boolean;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ModelTeacher[];
      }
    >(`/exam-marking-settings/teachers/by-exam-subject`, { query: query });
  },
  /**
   * @description 根据学校、年级、学科、姓名查询可用于阅卷的教师
   */
  teachersSearchList: (query: {
    /** 考试科目ID */
    exam_subject_id?: number;
    /** 学校ID */
    school_id?: number;
    /** 年级 */
    grade?: string;
    /** 学科 */
    subject?: string;
    /** 教师姓名（模糊搜索） */
    name?: string;
    /**
     * 是否查询虚拟教师，默认false
     * @default false
     */
    is_virtual?: boolean;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ModelTeacher[];
      }
    >(`/exam-marking-settings/teachers/search`, { query: query });
  },
  /**
   * @description 根据考试ID和模板ID查询阅卷设置中的所有题目，按大题号+小题号排序
   */
  topicsList: (query: {
    /**
     * 考试科目ID
     * @min 1
     */
    exam_subject_id: number;
    /**
     * 模板ID
     * @min 1
     */
    template_id: number;
  }) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ModelExamMarkingSettingTopicResponse[];
      }
    >(`/exam-marking-settings/topics`, { query: query });
  },
  /**
   * @description 批量更新智能批改信息
   */
  topicsIntelligentMarkingUpdate: (markings: ServiceIntelligentMarkingRequest[]) => {
    return httpClient.put<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-marking-settings/topics/intelligent-marking`, { params: markings });
  },
  /**
   * @description 批量更新客观题答案设置信息
   */
  topicsObjectiveAnswerSettingsUpdate: (settings: ServiceObjectiveAnswerSettingRequest[]) => {
    return httpClient.put<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-marking-settings/topics/objective-answer-settings`, { params: settings });
  },
  /**
   * @description 设置批阅时长
   */
  topicsSetReviewTimeUpdate: (request: ModelSetReviewTimeRequest) => {
    return httpClient.put<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-marking-settings/topics/set-review-time`, { params: request });
  },
  /**
   * @description 批量更新题目的任务分配信息，包括阅卷老师、仲裁老师、组长分配以及任务分配方式配置
   */
  topicsTaskAllocationUpdate: (allocations: ServiceTaskAllocationRequest[]) => {
    return httpClient.put<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-marking-settings/topics/task-allocation`, { params: allocations });
  },
  /**
   * @description 批量更新题目的任务分配信息，包括阅卷老师、仲裁老师、组长分配以及任务分配方式配置
   */
  topicsTaskAllocationReuseUpdate: (request: ServiceTaskAllocationReuseRequest) => {
    return httpClient.put<
      ControllerResponse & {
        message?: string;
      }
    >(`/exam-marking-settings/topics/task-allocation-reuse`, { params: request });
  }
};
