import request from '@/utils/request'

// 查询视频轮询规则列表
export async function getVideoRulePage(data) {
  const res = await request.post('/eam/video-rule/page', data)
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}

// 查询视频轮询规则详情
export async function getVideoRule(id) {
  const res = await request.get(`/eam/video-rule/getById/${id}`)
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}

// 查询视频轮询规则列表
export async function getVideoRuleList() {
  const res = await request.get('/eam/video-rule/list')
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}

// 新增视频轮询规则
export async function createVideoRule(data) {
  const res = await request.post('/eam/video-rule/add', data)
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}

// 修改视频轮询规则
export async function updateVideoRule(data) {
  const res = await request.post('/eam/video-rule/update', data)
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}

// 删除视频轮询规则
export async function deleteVideoRule(id) {
  const res = await request.delete('/eam/video-rule/delete?id=' + id)
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}

// 导出视频轮询规则 Excel
export async function exportVideoRule(params) {
  const res = await request.download('/isp/video-rule/export-excel', { params })
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}

// 获取摄像头列表
export async function listByType() {
  const res = await request.get('/main/camera-info/listByType')
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message))
}
