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

export async function getCmsAreaList(params?: API.AreaRegional.BusinessParams) {
  return request<API.AreaRegional.Regional>(`/api/cms/area/list`, {
    method: 'GET',
    params: params,
  });
}

export async function addCmsAreaListRow(params?: API.AreaRegional.BusinessParams) {
  return request<API.AreaRegional.Business>(`/api/cms/area`, {
    method: 'post',
    data: params,
  });
}

export async function updateCmsAreaListRow(params?: API.AreaRegional.BusinessParams) {
  return request<API.AreaRegional.Business>(`/api/cms/area`, {
    method: 'put',
    data: params,
  });
}

export async function deleteCmsAreaListRow(ids: number) {
  return request<API.AreaPlatForm.LinePageResult>(`/api/cms/area/${ids}`, {
    method: 'delete',
  });
}

export async function exportCmsAreaListRow(params?: API.AreaRegional.BusinessParams) {
  return downLoadXlsx(`/api/cms/area/export`, { params }, `区域_${getDateTimeForFilename()}.xlsx`);
}

//区划
// 获取
export async function getCmsRegionalList(params?: API.AreaRegional.RegionalParams) {
  return request<API.AreaRegional.Regional>(`/api/cms/regional/getList`, {
    method: 'GET',
    params: params,
  });
}

// 更新
export async function updateRegionalData(params?: API.AreaRegional.RegionalParams) {
  return request<API.AreaRegional.Regional>(`/api/cms/regional/updateRegionalData`, {
    method: 'POST',
    data: params,
  });
}

export async function addCmsSaveRegionalData(params?: API.AreaRegional.RegionalParams) {
  return request<API.AreaRegional.Regional>(`/api/cms/regional/saveRegionalData`, {
    method: 'post',
    data: params,
  });
}

// 删除
export async function deleteCmsRegionalData(ids: number) {
  return request<API.AreaRegional.Regional>(`/api/cms/regional/delRegionalData/${ids}`, {
    method: 'POST',
  });
}
