import request from '@/utils/request'

// 查询设备列表
export function listDevice(query) {
  return request({
    url: '/system/device/list',
    method: 'get',
    params: query
  })
}

// 查询设备详细
export function getDevice(deviceId) {
  return request({
    url: '/system/device/' + deviceId,
    method: 'get'
  })
}

// 新增设备
export function addDevice(data) {
  return request({
    url: '/system/device',
    method: 'post',
    data: data
  })
}

// 修改设备
export function updateDevice(data) {
  return request({
    url: '/system/device',
    method: 'put',
    data: data
  })
}

// 删除设备
export function delDevice(deviceId) {
  return request({
    url: '/system/device/' + deviceId,
    method: 'delete'
  })
}

// 一键上线
export function oneClickOnline(deviceId) {
  return request({
    url: '/system/device/oneClickOnline/' + deviceId,
    method: 'post'
  })
}

// 一键下线
export function oneClickOffline(deviceId) {
  return request({
    url: '/system/device/oneClickOffline/' + deviceId,
    method: 'post'
  })
}


// 一键出仓
export function oneClickListing(deviceId) {
  return request({
    url: '/system/device/oneClickListing/' + deviceId,
    method: 'post'
  })
}

// 一键入仓
export function oneClickWarehousing(deviceId) {
  return request({
    url: '/system/device/oneClickWarehousing/' + deviceId,
    method: 'post'
  })
}

// 更新设备
export function refreshDevice(deviceId) {
  return request({
    url: '/system/device/refreshDevice/' + deviceId,
    method: 'post'
  })
}


// 查询所有车辆信息
export function allDevice() {
  return request({
    url: '/appVerify/allVehicleInfo',
    method: 'get'
  })
}

// 开锁
export function handleUnlocking(data){
  return request({
    url: '/system/device/admin/unlockingByMac?mac='+data.mac,
    method: 'post'
  })
}

// 关锁
export function handleLock(data){
  return request({
    url: '/system/device/admin/lockByMac?mac='+data.mac,
    method: 'post'
  })
}

// 响铃寻车
export function ring(data){
  return request({
    url: '/app/device/ringByMac?mac='+data.mac,
    method: 'post'
  })
}

// 坐垫锁
export function seatCushionLock(data){
  return request({
    url: '/appVerify/device/seatCushionLockByMac?mac='+data.mac,
    method: 'post'
  })
}

// 重启设备
export function reboot(data){
  return request({
    url: '/system/device/device/reboot?mac='+data.mac,
    method: 'post'
  })
}
// 根据sn查询设备
export function getDeviceBySn(sn){
  return request({
    url: '/app/device/info?sn='+sn,
    method: 'get'
  })
}

