import request from '@/utils/request'

/**
 * 通过attachId删除文件
 * @param {*} attachId
 */
export function deleteFile(attachId) {
  return request({
    url: '/common/deleteFile/' + attachId,
    method: 'DELETE'
  })
}

/**
 * 通过fileId删除文件
 * @param {*} fileId
 */
export function deleteFileByFileId(fileId) {
  return request({
    url: '/common/deleteFileByFileId/' + fileId,
    method: 'DELETE'
  })
}

/**
 * 下载文件
 * @param {*} fileName 文件名
 */
export function download(fileName) {
  return request({
    url: '/common/download',
    method: 'GET',
    params: {
      fileName
    },
    responseType: 'blob'
  })
}

/**
 * 通过fileId查找附件列表
 * @param {*} fileId
 */
export function getAttachList(fileId) {
  return request({
    url: '/common/getAttachList/' + fileId,
    method: 'GET'
  })
}

/**
 * 通过fileIds获取附件列表
 * @param {string} fileIds
 */
export function getAttachListByFileIds(fileIds) {
  if (!fileIds) return { data: null }
  return request({
    url: '/common/getFileIdsByAttachVos',
    method: 'get',
    params: {
      fileIds
    }
  })
}

/**
 * 单文件上传
 */
export function uploadFile() {
  return request({
    url: '/common/upload',
    method: 'post'
  })
}

/**
 * 多文件上传
 */
export function uploadFiles() {
  return request({
    url: '/common/uploads',
    method: 'post'
  })
}
