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

export async function getCmsJobList(params?: API.ManagementList.ListParams) {
  return request<API.ManagementList.ManagePageResult>(`/api/cms/job/list`, {
    method: 'GET',
    params: params,
  });
}

export async function addCmsJobList(params?: API.ManagementList.AddParams) {
  return request<API.ManagementList.ManagePageResult>(`/api/cms/job`, {
    method: 'POST',
    data: params,
  });
}

export async function updateCmsJobList(params?: API.ManagementList.AddParams) {
  return request<API.ManagementList.ManagePageResult>(`/api/cms/job`, {
    method: 'PUT',
    data: params,
  });
}

export async function getCmsJobIds(ids: string) {
  return request<API.ManagementList.ManageIdResult>(`/api/cms/job/${ids}`, {
    method: 'GET',
  });
}

export async function delCmsJobIds(ids: string) {
  return request<API.ManagementList.ManagePageResult>(`/api/cms/job/${ids}`, {
    method: 'DELETE',
  });
}

export async function exportCmsJob(params?: API.ManagementList.ListParams) {
  return downLoadXlsx(
    `/api/cms/job/export`,
    { params },
    `岗位数据_${getDateTimeForFilename()}.xlsx`,
  );
}

export async function exportCmsJobCandidates(ids: string) {
  return request<API.ManagementList.ManageIdResult>(`/api/cms/job/candidates`, {
    method: 'GET',
    params: {
      jobId: ids,
    },
  });
}
export async function getJobTrend(params) {
  return request(`/api/cms/jobTrend/list`, {
    method: 'GET',
    params: params
  });
}

export async function cmsfileupload(params) {
  return request(`/api/cms/file/upload`, {
    method: 'POST',
    data: params
  });
}

export async function getJobCompetitiveness(params: { userId: number | string; jobId: string }) {
  return request<API.ManagementList.CompetitivenessResult>(`/api/cms/job/competitiveness`, {
    method: 'GET',
    params: params,
  });
}
