import request from '@/config/axios'

// 安防前端设备 VO
export interface CameraVO {
  id: number // 设备ID
  name: string // 名称
  code: string // 编号
  sort: number // 排序
  type: string // 类型
  serverId: number // 后端设备
  aiMode: string // AI模型
  warn: string // 报警状态
  warnApi: string // 报警接口
  desc: string // 描述
}

// 安防前端设备 API
export const CameraApi = {
  // 查询安防前端设备分页
  getCameraPage: async (params: any) => {
    return await request.get({ url: `/safe/camera/page`, params })
  },

  // 查询安防前端设备详情
  getCamera: async (id: number) => {
    return await request.get({ url: `/safe/camera/get?id=` + id })
  },

  // 新增安防前端设备
  createCamera: async (data: CameraVO) => {
    return await request.post({ url: `/safe/camera/create`, data })
  },

  // 修改安防前端设备
  updateCamera: async (data: CameraVO) => {
    return await request.put({ url: `/safe/camera/update`, data })
  },

  // 删除安防前端设备
  deleteCamera: async (id: number) => {
    return await request.delete({ url: `/safe/camera/delete?id=` + id })
  },

  // 导出安防前端设备 Excel
  exportCamera: async (params) => {
    return await request.download({ url: `/safe/camera/export-excel`, params })
  },

  // 根据后端设备id查询前端设备
  getCameras: async (id: number) => {
    return await request.get({ url: `/safe/camera/cameras?serverId=` + id })
  },
}
