import request from '@/utils/request'

// 查询车辆列表
export function listVehicle(query) {
  return request({
    url: '/resources/vehicles/list',
    method: 'get',
    params: query
  })
}

// 查询车辆详情
export function getVehicle(id) {
  return request({
    url: '/resources/vehicles/' + id,
    method: 'get'
  })
}

// 根据队伍ID查询车辆列表
export function listVehicleByTeam(teamId) {
  return request({
    url: '/resources/vehicles/team/' + teamId,
    method: 'get'
  })
}

// 新增车辆
export function addVehicle(data) {
  return request({
    url: '/resources/vehicles',
    method: 'post',
    data: data
  })
}

// 修改车辆
export function updateVehicle(data) {
  return request({
    url: '/resources/vehicles',
    method: 'put',
    data: data
  })
}

// 更新车辆GPS位置
export function updateVehicleLocation(id, data) {
  return request({
    url: `/resources/vehicles/${id}/location`,
    method: 'post',
    data: data
  })
}

// 删除车辆
export function delVehicle(id) {
  return request({
    url: '/resources/vehicles/' + id,
    method: 'delete'
  })
}

// 设置车辆状态
export function updateVehicleStatus(id, status) {
  return request({
    url: '/resources/vehicles/' + id + '/status',
    method: 'put',
    data: { status }
  })
}