import axios, { AxiosResponse } from 'axios';
import type {
  TeachingListPageParam,
  TeachingListPageRes,
  TeachingUpdateParams,
  AgentListPageParam,
  AgentListPageRes,
  AgentUpdateParams,
  RoomListPageParam,
  RoomListPageRes,
  RoomUpdateParams,
} from './types/base';
import { AbleParams } from './types/common';

// 教学点管理
// 教学点管理-查询
export function teachingListPage(
  params: TeachingListPageParam
): Promise<TeachingListPageRes> {
  return axios.post('/api/admin/teaching/query', {}, { params });
}
// 教学点管理-新增编辑
export function updateTeaching(
  datas: TeachingUpdateParams
): Promise<{ id: number }> {
  return axios.post('/api/admin/teaching/save', datas);
}
// 教学点管理-启用禁用
export function ableTeaching(params: AbleParams): Promise<boolean> {
  return axios.post('/api/admin/teaching/enable', {}, { params });
}
// // 教学点管理-导入模板下载
export function teachingTemplate(): Promise<AxiosResponse<Blob>> {
  return axios.post(
    '/api/admin/teaching/template',
    {},
    {
      responseType: 'blob',
    }
  );
}

// 考点管理
// 考点管理-查询
export function agentListPage(
  params: AgentListPageParam
): Promise<AgentListPageRes> {
  return axios.post('/api/admin/agent/query', {}, { params });
}
// 考点管理-新增编辑
export function updateAgent(datas: AgentUpdateParams): Promise<{ id: number }> {
  return axios.post('/api/admin/agent/save', datas);
}
// 考点管理-启用禁用
export function ableAgent(params: AbleParams): Promise<boolean> {
  return axios.post('/api/admin/agent/enable', {}, { params });
}
// // 考点管理-导入模板下载
export function agentTemplate(): Promise<AxiosResponse<Blob>> {
  return axios.post(
    '/api/admin/agent/template',
    {},
    {
      responseType: 'blob',
    }
  );
}

// 考场管理
// 考场管理-查询
export function roomListPage(
  params: RoomListPageParam
): Promise<RoomListPageRes> {
  return axios.post('/api/admin/room/query', {}, { params });
}
// 考场管理-新增编辑
export function updateRoom(datas: RoomUpdateParams): Promise<{ id: number }> {
  return axios.post('/api/admin/room/save', datas);
}
// 考场管理-启用禁用
export function ableRoom(params: AbleParams): Promise<boolean> {
  return axios.post('/api/admin/room/enable', {}, { params });
}
// // 考场管理-导入模板下载
export function roomTemplate(): Promise<AxiosResponse<Blob>> {
  return axios.post(
    '/api/admin/room/template',
    {},
    {
      responseType: 'blob',
    }
  );
}
