import request from '@/utils/request'

// 创建设备信息
export function createDeviceInfo(data) {
  return request({
    url: '/product/device-info/create',
    method: 'post',
    data: data
  })
}

// 更新设备信息
export function updateDeviceInfo(data) {
  return request({
    url: '/product/device-info/update',
    method: 'put',
    data: data
  })
}

// 删除设备信息
export function deleteDeviceInfo(id) {
  return request({
    url: '/product/device-info/delete?id=' + id,
    method: 'delete'
  })
}

// 获得设备信息
export function getDeviceInfo(id) {
  return request({
    url: '/product/device-info/get?id=' + id,
    method: 'get'
  })
}

// 获得设备信息分页
export function getDeviceInfoPage(query) {
  return request({
    url: '/product/device-info/page',
    method: 'get',
    params: query
  })
}

// 导出设备信息 Excel
export function exportDeviceInfoExcel(query) {
  return request({
    url: '/product/device-info/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 更改是否启用
export function changeEnabled(data) {
  return request({
    url: `/product/device-info/changeEnabled?id=${data.id}&enabled=${data.enabled}`,
    method: 'put',
    data
  })
}

// 更改开关状态
export function changeSwitch(data) {
  return request({
    url: `/product/device-info/changeSwitch?id=${data.id}&switchOn=${data.switchOn}`,
    method: 'put',
  })
}

// 获得监控预览地址
export function getMonitorPreviewURL({ type, monitorCode }) {
  return request({
    url: `/product/device-info/getMonitorPreviewURL?type=${type}&monitorCode=${monitorCode}`,
    method: 'get',
  })
}

// 根据地块编码获取监控播放地址
export function getMonitorPreviewURLByLandId({ type, landId }) {
  return request({
    url: `/product/device-info/getMonitorPreviewURLByLandId?type=${type}&landId=${landId}`,
    method: 'get',
  })
}


