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

// 教学点管理
// 教学点管理-查询
export function teachingListPage(
  params: TeachingListPageParam
): Promise<TeachingListPageRes> {
  return axios.post('/api/admin/teaching/page', 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/import/template',
    {},
    {
      responseType: 'blob',
    }
  );
}

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

// 考场管理
// 考场管理-查询
export function roomListPage(
  params: RoomListPageParam
): Promise<RoomListPageRes> {
  return axios.post('/api/admin/room/page', 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/import/template',
    {},
    {
      responseType: 'blob',
    }
  );
}
