import request from '@/utils/request'

// 查询消防设施列表
export function listFacility(query) {
  return request({
    url: '/fire/facility/list',
    method: 'get',
    params: query
  })
}

// 查询消防设施详细
export function getFacility(id) {
  return request({
    url: '/fire/facility/' + id,
    method: 'get'
  })
}

// 新增消防设施
export function addFacility(data) {
  return request({
    url: '/fire/facility',
    method: 'post',
    data: data
  })
}

// 修改消防设施
export function updateFacility(data) {
  return request({
    url: '/fire/facility',
    method: 'put',
    data: data
  })
}

// 删除facilities
export function delFacility(id) {
  return request({
    url: '/fire/facility/' + id,
    method: 'delete'
  })
}

// 导出消防设施
export function exportFacility(query) {
  return request({
    url: '/fire/facility/export',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 导入消防设施数据
export function importFacility(data, updateSupport) {
  const formData = new FormData()
  formData.append('file', data)
  formData.append('updateSupport', updateSupport)
  return request({
    url: '/fire/facility/importData',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 下载导入模板
export function downloadImportTemplate() {
  return request({
    url: '/fire/facility/importTemplate',
    method: 'get',
    responseType: 'blob'
  })
}


export function checkAndUpdateStatus(id) {
  return request({
  
    url: `/fire/facility/check-status/${id}`, 
    method: 'get'
  })
}