import request from '@/utils/request'

// 通用GET请求（用于动态API路径）
export function getRequest(url, params) {
  return request({
    url: url,
    method: 'get',
    params: params
  })
}

// 通用POST请求
export function postRequest(url, data) {
  return request({
    url: url,
    method: 'post',
    data: data
  })
}

// 通用列表请求
export function listData(url, query) {
  return request({
    url: url + '/list',
    method: 'get',
    params: query
  })
}

// 通用DELETE请求
export function delRequest(url, params) {
  return request({
    url: url,
    method: 'delete',
    params: params
  })
}


export function getTask(taskId) {
  return request({
    url: '/common/getTask/'+taskId,
    method: 'get'
  })
}

export function getSignature() {
    return request({
      url: '/common/getSignature',
      method: 'post',
    })
  }

export function uploadHuaWeiVod(file) {
  const formData = new FormData();
  formData.append('file', file);

  return request({
    url: '/hwcloud/uploadHuaWeiVod',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

export function uploadHuaWeiObs(file, progressCallback) {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/hwcloud/uploadHuaWeiObs',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

export function cdnStatistics(query) {
  return request({
    url: '/hwcloud/cdnStatistics',
    method: 'get',
    params:query
  })
}

export function getTmpSecretKey(query) {
  return request({
    url: '/common/getTmpSecretKey',
    method: 'get',
    params:query
  })
}
