import axios from '@/http/file.request';
const callGet = (url) => (params, cancelId) =>
  axios.request({ url, params, method: 'get', cancelId });

// transformRequest： 接口请求前修改参数
const callPost = (url) => (data, cancelId, transformRequest) =>
  axios.request({ url, data, method: 'post', transformRequest, cancelId });

const callPut = (url) => (data, cancelId, transformRequest) =>
  axios.request({ url, data, method: 'put', transformRequest, cancelId });

const callDel = (url) => (params, cancelId) =>
  axios.request({ url, params, method: 'delete', cancelId });

const callPostFormFile = (url) => (data, cancelId, transformRequest) =>
  axios.request({
    url,
    data,
    method: 'post',
    responseType: 'blob',
    ContentType: 'multipart/form-data',
  });
const callPostAll = (url) => (data) =>
  axios.request({ url, data, method: 'post', ContentType: 'multipart/form-data' });

const callGetFile = (url) => (params, cancelId) =>
  axios.request({
    url,
    params,
    method: 'get',
    contentType: 'application/x-www-form-urlencoded',
    responseType: 'blob',
    cancelId,
  });
const callPostFile = (url) => (data, cancelId, transformRequest) =>
  axios.request({ url, data, method: 'post', responseType: 'blob', transformRequest, cancelId });

export {
  callGet,
  callPost,
  callPut,
  callDel,
  callPostAll,
  callGetFile,
  callPostFile,
  callPostFormFile,
};
