import request from '@/utils/request'

// 查询装备列表
export function listEquipment(query) {
  return request({
    url: '/resources/equipment/list',
    method: 'get',
    params: query
  })
}

// 查询装备详情
export function getEquipment(id) {
  return request({
    url: '/resources/equipment/' + id,
    method: 'get'
  })
}

// 根据队伍ID查询装备列表
export function listEquipmentByTeam(teamId) {
  return request({
    url: '/resources/equipment/team/' + teamId,
    method: 'get'
  })
}

// 新增装备
export function addEquipment(data) {
  return request({
    url: '/resources/equipment',
    method: 'post',
    data: data
  })
}

// 修改装备
export function updateEquipment(data) {
  return request({
    url: '/resources/equipment',
    method: 'put',
    data: data
  })
}

// 删除装备
export function delEquipment(ids) {
  return request({
    url: '/resources/equipment/' + ids,
    method: 'delete'
  })
}

// 分配占用（available → busy）
export function assignEquipment(id, data) {
  return request({
    url: '/resources/equipment/' + id + '/assign',
    method: 'post',
    data: data
  })
}

// 解除占用（busy → available）
export function releaseEquipment(id, data) {
  return request({
    url: '/resources/equipment/' + id + '/release',
    method: 'post',
    data: data
  })
}

// 送修（available/busy → repair）
export function sendRepair(id, data) {
  return request({
    url: '/resources/equipment/' + id + '/send-repair',
    method: 'post',
    data: data
  })
}

// 修复完成（repair → available）
export function finishRepair(id, data) {
  return request({
    url: '/resources/equipment/' + id + '/finish-repair',
    method: 'post',
    data: data
  })
}

// 报废（→ scrap，终态）
export function scrapEquipment(id, data) {
  return request({
    url: '/resources/equipment/' + id + '/scrap',
    method: 'post',
    data: data
  })
}

// 查询操作日志
export function listEquipmentLogs(id, query) {
  return request({
    url: '/resources/equipment/' + id + '/logs',
    method: 'get',
    params: query
  })
}

