import { request } from '@umijs/max';
import { downLoadXlsx } from '@/utils/downloadfile';
import { getDateTimeForFilename } from '@/utils/tools';

export async function getCmsFairList(params?: API.JobFairList.Params) {
  return request<API.JobFairList.JobFairListResult>(`/api/cms/fair/list`, {
    method: 'GET',
    params: params,
  });
}

export async function addCmsFairList(params?: API.JobFairList.JobFairListRows) {
  return request<API.JobFairList.JobFairListResult>(`/api/cms/fair`, {
    method: 'POST',
    data: params,
  });
}

export async function putCmsFairList(params?: API.JobFairList.Params) {
  return request<API.JobFairList.JobFairListResult>(`/api/cms/fair`, {
    method: 'PUT',
    data: params,
  });
}

export async function delCmsFairList(ids?: string) {
  return request<API.JobFairList.JobFairListResult>(`/api/cms/fair/${ids}`, {
    method: 'DELETE',
  });
}

export async function exportCmsFairList(params?: API.JobFairList.Params) {
  return downLoadXlsx(
    `/api/cms/fair/export`,
    { params },
    `招聘会_${getDateTimeForFilename()}.xlsx`,
  );
}

export async function getCmsFairId(jobFairId?: string) {
  return request<API.JobFairList.ListInfoResult>(`/api/cms/fair/${jobFairId}`, {
    method: 'GET',
  });
}

export async function getCmstitilelist(jobFairId?: string) {
  return request<API.JobFairList.ListInfoResult>(`/api/cms/industry/list`, {
    method: 'GET',
  });
}
