import request from '@/utils/request'

// 查询物资列表
export function listMaterial(query) {
  return request({
    url: '/resources/materials/list',
    method: 'get',
    params: query
  })
}

// 查询物资详细
export function getMaterial(id) {
  return request({
    url: '/resources/materials/' + id,
    method: 'get'
  })
}

// 新增物资
export function addMaterial(data) {
  return request({
    url: '/resources/materials',
    method: 'post',
    data: data
  })
}

// 修改物资
export function updateMaterial(data) {
  return request({
    url: '/resources/materials',
    method: 'put',
    data: data
  })
}

// 删除物资
export function delMaterial(ids) {
  return request({
    url: '/resources/materials/' + ids,
    method: 'delete'
  })
}

// 设置报警阈值
export function setMaterialAlert(id, threshold) {
  return request({
    url: '/resources/materials/' + id + '/alert',
    method: 'post',
    data: { threshold }
  })
}