import request from '@/utils/request'

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

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

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

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

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

// 获取设备按头使用统计
export function getDeviceHeadUsage(deviceId) {
  return request({
    url: `/device/device/${deviceId}/head-usage`,
    method: 'get'
  })
}

// 导出设备
export function exportDevice(query) {
  return request({
    url: '/device/export',
    method: 'post',
    data: query
  })
}

// 同步设备列表
export function syncDeviceList() {
  return request({
    url: '/device/syncDeviceList',
    method: 'post'
  })
}

// 获取设备运行统计
export function getDeviceRuntimeStats(deviceId) {
  return request({
    url: '/device/' + deviceId + '/runtime-stats',
    method: 'get'
  })
}

// 查询设备总数及在线离线设备数量
export function getDeviceTotal() {
  return request({
    url: '/device/device/getTotal',
    method: 'get'
  })
}


// 获取设备坐标点数据
export function getDeviceCoordinate() {
  return request({
    url: '/device/device/getDeviceCoordinate',
    method: 'get'
  })
}

// 获取设备按摩统计
export function getDeviceMassageStats(deviceId, timeRange) {
  return request({
    url: '/device/' + deviceId + '/massage-stats',
    method: 'get',
    params: { timeRange }
  })
}

// 获取设备实时状态
export function getDeviceRealtimeStatus(deviceId) {
  return request({
    url: '/device/' + deviceId + '/realtime-status',
    method: 'get'
  })
}

// 获取设备状态历史
export function getDeviceStatusHistory(deviceId, limit) {
  return request({
    url: '/device/' + deviceId + '/status-history',
    method: 'get',
    params: { limit }
  })
}

// 获取设备按摩历史
export function getDeviceMassageHistory(deviceId, limit) {
  return request({
    url: '/device/' + deviceId + '/massage-history',
    method: 'get',
    params: { limit }
  })
}

// 刷新设备状态
export function refreshDeviceStatus(deviceId) {
  return request({
    url: '/device/' + deviceId + '/refresh-status',
    method: 'post'
  })
}