import request from '@/config/axios'

// 数采记录 VO
export interface MqttRecordVO {
  id: number // ID
  machineId: number // 机台ID
  machineName: string // 机台
  deviceDataTime: Date // 采集时间
  deviceData: string // 数据
  deviceId: number // 设备id
  deviceCode: string // 设备编码
  deviceName: string // 设备名称
  workerId: number // 用户id
  workerName: string // 用户
  gatewayCode: string // 网关
}

// 数采记录 API
export const MqttRecordApi = {
  // 查询数采记录分页
  getMqttRecordPage: async (params: any) => {
    return await request.get({ url: `/iot/mqtt-record/page`, params })
  },

  // 查询数采记录详情
  getMqttRecord: async (id: number) => {
    return await request.get({ url: `/iot/mqtt-record/get?id=` + id })
  },
// 查询设备属性
  getDeviceAttr: async (code: any) => {
    return await request.get({ url: `/iot/mqtt-record/getDeviceAttr?code=` + code })
  },
  // 新增数采记录
  createMqttRecord: async (data: MqttRecordVO) => {
    return await request.post({ url: `/iot/mqtt-record/create`, data })
  },

  // 修改数采记录
  updateMqttRecord: async (data: MqttRecordVO) => {
    return await request.put({ url: `/iot/mqtt-record/update`, data })
  },

  // 删除数采记录
  deleteMqttRecord: async (id: number) => {
    return await request.delete({ url: `/iot/mqtt-record/delete?id=` + id })
  },

  // 导出数采记录 Excel
  exportMqttRecord: async (params) => {
    return await request.download({ url: `/iot/mqtt-record/export-excel`, params })
  },
}
