import request from '@/utils/request'

// 查询附件列表
export function listFile(query) {
  return request({
    url: '/system/file/list',
    method: 'get',
    params: query
  })
}

// 查询附件详细
export function getFile(id) {
  return request({
    url: '/system/file/' + id,
    method: 'get'
  })
}

// 新增附件
export function addFile(data) {
  return request({
    url: '/system/file',
    method: 'post',
    data: data
  })
}

// 修改附件
export function updateFile(data) {
  return request({
    url: '/system/file',
    method: 'put',
    data: data
  })
}

// 删除附件
export function delFile(id) {
  return request({
    url: '/system/file/' + id,
    method: 'delete'
  })
}

// 根据附件业务ID()获取附件详情信息列表
export function listFileBusinessId(id, uploadType) {
  let obj = { fileBusinessId: id };
  if (uploadType) {
    obj.uploadType = uploadType;
  }
  return request({
    url: '/system/file/listFileBusinessId',
    method: 'get',
    params: obj
  })
}
// 根据ID()获取附件详情信息列表
export function listFileById(id, uploadType) {
  let obj = { id: id };
  if (uploadType) {
    obj.uploadType = uploadType;
  }
  return request({
    url: '/system/file/listFileById',
    method: 'get',
    params: obj
  })
}
export function downloadFileById(id) {
  return request({
    url: '/system/file/download/' + id,
    method: 'get',
    responseType: "blob"
  })
}

// 根据fileId()获取项目中所有附件列表  fileId=项目id
export function listFileId(id) {
  return request({
    url: '/system/file/listFileId',
    method: 'get',
    params: { fileId: id }
  })
}
