import request from '@/utils/request'

export function REQUEST(url, method, data, headers) {
    return request({
        url: url,
        method: method,
        data: data || {},
        headers: headers || {}
    })
}



/*
推荐用法：cw.GET("company-service/company/list").then()
*/
export function GET(url, data, headers) {
    return request.get(url, {
        params: data,
        headers: headers || {}
    })
}

// 同上
export function POST(url, data, headers) {
    return REQUEST(url, 'POST', data, headers)
}

// 同上
export function PUT(url, data, headers) {
    return REQUEST(url, 'PUT', data, headers)
}

// 同上
export function DELETE(url, data, headers) {
    return REQUEST(url, 'DELETE', data, headers)
}

// 同上
export function PATCH(url, data, headers) {
    return REQUEST(url, 'PATCH', data, headers)
}
/*
文件导入接口 cw.IMPORT(url, file)
*/
export function IMPORT(url, files) {
    const formData = new FormData()
    formData.append('file', files.file)
  
    return request({
      url: url,
      method: 'POST',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  }