/**
 * 设备管理接口
 */
import request from '../index'

// 列表
export function getDeviceList(params: object) {
  return request({
    url: '/api/device/page',
    method: 'get',
    params,
  })
}
// 列表不分页
export function getDeviceAll(params: object) {
  return request({
    url: '/api/device/list',
    method: 'get',
    params,
  })
}

// 新建
export function addDevice(data: object) {
  return request({
    url: '/api/device/add',
    method: 'post',
    data,
  })
}
// 编辑
export function updateDevice(data: object) {
  return request({
    url: '/api/device/update',
    method: 'post',
    data,
  })
}
// 删除
export function removeDevice(id: string) {
  return request({
    url: `/api/device/delete?device_id=${id}`,
    method: 'delete',
  })
}
// 更新模型和摄像头的绑定
export function updateModelRelations(data: any) {
  return request({
    url: `/api/device_model_relation/update_by_device?device_id=${data.id}`,
    method: 'post',
    data: data.list,
  })
}
// 获取模型和摄像头的绑定
export function getModelRelations(id: any) {
  return request({
    url: `/api/device_model_relation/list_by_device?device_id=${id}`,
    method: 'get',
  })
}
// 更新场景和摄像头的绑定
export function updateSceneRelations(data: any) {
  return request({
    url: `/api/device_scene_relation/update_by_device?device_id=${data.id}&scene_id=${data.scene_id}`,
    method: 'post',
  })
}
