import { defHttp } from '@/utils/http/axios';

enum Api {
  // 获取数据库表及视图字段
  GetTableColumnList = '/api/ApplicationData/GetTableColumnList',
  // 查询数据
  GetDataList = '/api/ApplicationData/GetDataList',
  // 批量修改
  Upload = '/api/Files/Upload',
  UpdateBatch = '/api/ApplicationData/UpdateBatch',
  // 批量导入shp
  UploadShape1 = '/api/Layer/UploadShape1',
  UploadExcelInsert = '/api/Layer/UploadExcelInsert',
  // 批量更新shp
  UploadShape2 = '/api/Layer/UploadShape2',
  AddUploadExcel = '/api/Layer/AddUploadExcel',
  // 批量更新
  UpdateTableOriginalData = '/api/Layer/UpdateTableOriginalData',
  // 列表导入
  UploadShape = '/api/Layer/UploadShape',
  UploadExcelAll = '/api/Layer/UploadExcelAll',
}

export const GetTableColumnList = ( params: { tableName: string } ) =>
  defHttp.get({ url: Api.GetTableColumnList, params });

export const GetDataList = ( params ) =>
  defHttp.post({ url: Api.GetDataList, data: params });

export const UpdateBatch = ( params ) =>
  defHttp.post({ url: Api.UpdateBatch, data: params });
export const Upload = (params) => 
  defHttp.post({
    url: Api.Upload,
    params,
    headers: {
      'Content-type': 'multipart/form-data',
    },
  })
export const UploadShape1 = (params: {zipFilePath: string, tableName: string}) =>
  defHttp.post({
    url: Api.UploadShape1,
    params,
    data: params
  })
export const UploadExcelInsert = (params: {File: FormData, tableName: string}) =>
  defHttp.post({
    url: Api.UploadExcelInsert,
    params: {tableName: params.tableName},
    data: params.File,
    headers: {
      'Content-type': 'multipart/form-data',
    },
  })
export const UploadShape2 = (params: {zipFilePath: string, tableName: string}) =>
  defHttp.post({
    url: Api.UploadShape2,
    params,
    data: params
  })
export const AddUploadExcel = (params: {File: FormData, tableName: string}) =>
  defHttp.post({
    url: Api.AddUploadExcel,
    params: {tableName: params.tableName},
    data: params.File,
    headers: {
      'Content-type': 'multipart/form-data',
    },
  })
export const UpdateTableOriginalData = (params: {tableName: string, list: Object}) =>
  defHttp.post({
    url: Api.UpdateTableOriginalData,
    data: params
  })
export const UploadShape = (params: {zipFilePath: string, tableName: string}) =>
  defHttp.post({
    url: Api.UploadShape,
    params,
    data: params
  })
export const UploadExcelAll = (params: {File: FormData, tableName: string}) =>
  defHttp.post({
    url: Api.UploadExcelAll,
    params: {tableName: params.tableName},
    data: params.File,
    headers: {
      'Content-type': 'multipart/form-data',
    },
  })