import request from '@/utils/request'
import {parseStrEmpty} from "@/utils/ruoyi";

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

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

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

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

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


// 查询场景信息列表供选择使用（例如下拉列表）
export function getScenes(query) {
  return request({
    url: '/business/device/getScenes',
    method: 'get',
    params: query
  })
}


// 查询监控单元树
export function getMonitorTree(sceneId) {
  return request({
    url: '/business/device/monitorUnitTree/' + parseStrEmpty(sceneId),
    method: 'get'
  })
}


// 查询设备模型
export function getDeviceModes(sceneId) {
  return request({
    url: '/business/device/getDeviceModes/' + parseStrEmpty(sceneId),
    method: 'get'
  })
}

// 查询网关设备
export function getGatewayDevices(sceneId) {
  return request({
    url: '/business/device/getGatewayDevices/' + parseStrEmpty(sceneId),
    method: 'get'
  })
}


// 设备状态修改
export function changeDeviceStatus(deviceId, deviceStatus) {
  const data = {
    deviceId,
    deviceStatus
  }
  return request({
    url: '/business/device/changeDeviceStatus',
    method: 'put',
    data: data
  })
}
