import request from '@/config/axios'

// 相机 VO
export interface CameraVO {
  id: number // id
  name: string // 名称
  type: number // 类型
  ip: string // ip
  port: number // 端口
  user: string // 用户名
  password: string // 密码
  rtcServer: string // 流媒体ip
  rtcServerPort: number // 流媒体端口
  rtspPort: number // rtsp端口
  channel: string // 通道
  recorderIp: string // 录像机ip
}

// 相机 VO
export interface CameraIOVO {
  id: number // id
  cameraId: number // 相机id
  ptzId: number // 预置点id
  name: string // 名称
  code: number // 预支点code
}


// 相机 API
export const CameraApi = {
  // 查询相机分页
  getCameraPage: async (params: any) => {
    return await request.get({ url: `/logistics/camera/page`, params })
  },
   // 查询相机分页
   getTree: async () => {
    return await request.post({ url: `/logistics/camera/tree` })
  },
  //查询相机列表
  getCameraList:  () => {
    return  request.get({ url: `/logistics/camera/list` })
  },
  // 查询相机详情
  getCamera: (id: number) => {
    return request.get({ url: `/logistics/camera/get?id=` + id })
  },

  // 新增相机
  createCamera: async (data: CameraVO) => {
    return await request.post({ url: `/logistics/camera/create`, data })
  },

  // 修改相机
  updateCamera: async (data: CameraVO) => {
    return await request.put({ url: `/logistics/camera/update`, data })
  },

  // 删除相机
  deleteCamera: async (id: number) => {
    return await request.delete({ url: `/logistics/camera/delete?id=` + id })
  },

  // 导出相机 Excel
  exportCamera: async (params) => {
    return await request.download({ url: `/logistics/camera/export-excel`, params })
  },
}

// 相机 API
export const CameraIoApi = {
 
  //查询相机io列表
  getCameraIoList: async  (data): Promise<CameraIOVO[]> => {
    return  request.post({ url: `/logistics/camera-io/list`,data })
  },

  // 新增相机io
  createCameraIo: async (data: CameraIOVO) => {
    return await request.post({ url: `/logistics/camera-io/create`, data })
  },

  // 修改相机io
  updateCameraIo: async (data: CameraVO) => {
    return await request.put({ url: `/logistics/camera-io/update`, data })
  },

  // 删除相机io
  deleteCameraIo: async (id: number) => {
    return await request.delete({ url: `/logistics/camera-io/delete?id=` + id })
  },
  // 调用预置点位
  callPtz: async (data: CameraIOVO) => {
    return await request.post({ url: `/logistics/camera-io/callPtz`, data })
  },
  // 覆盖预置点位
  overwritePtz: async (data: CameraIOVO) => {
    return await request.post({ url: `/logistics/camera-io/overwritePtz`, data })
  },

}