import request from '@/utils/request'

// 查询物资库存列表（按物资ID）
export function listMaterialInventory(materialId, query) {
  return request({
    url: '/resources/materials/' + materialId + '/inventory',
    method: 'get',
    params: query
  })
}

// 查询库存详情
export function getMaterialInventory(inventoryId) {
  return request({
    url: '/resources/materials/inventory/' + inventoryId,
    method: 'get'
  })
}

// 添加库存
export function addMaterialInventory(materialId, data) {
  return request({
    url: '/resources/materials/' + materialId + '/inventory',
    method: 'post',
    data: data
  })
}

// 占用库存
export function lockMaterialInventory(materialId, data) {
  return request({
    url: '/resources/materials/' + materialId + '/lock',
    method: 'post',
    data: data
  })
}

// 释放库存
export function unlockMaterialInventory(materialId, data) {
  return request({
    url: '/resources/materials/' + materialId + '/unlock',
    method: 'post',
    data: data
  })
}

// 消耗结算
export function consumeMaterialInventory(materialId, data) {
  return request({
    url: '/resources/materials/' + materialId + '/consume',
    method: 'post',
    data: data
  })
}

// 归还入库
export function returnMaterialInventory(materialId, data) {
  return request({
    url: '/resources/materials/' + materialId + '/return',
    method: 'post',
    data: data
  })
}

// 库存调整
export function adjustMaterialInventory(materialId, data) {
  return request({
    url: '/resources/materials/' + materialId + '/adjust',
    method: 'post',
    data: data
  })
}

// 查询使用记录
export function listMaterialUsages(materialId, query) {
  return request({
    url: '/resources/materials/' + materialId + '/usages',
    method: 'get',
    params: query
  })
}

// 查询使用记录详情
export function getMaterialUsage(usageId) {
  return request({
    url: '/resources/materials/usages/' + usageId,
    method: 'get'
  })
}