import request from '@/config/axios'

// 告警设置 VO
export interface IotAlarmSettingVO {
  id: number // 主键id
  classifyId: number // 分类id
  classifyName: string // 分类名称
  deviceId: number // 设备id
  deviceName: string // 设备名称
  maxValue: string // 上限
  minValue: string // 下限
  alarmProperty: number // 告警属性
}

// 告警设置 API
export const IotAlarmSettingApi = {
  // 查询告警设置分页
  getDeviceRange: async (devicecode: any, identifier:string) => {
    return await request.get({ url: `/rq/iot-alarm-setting/get-device-range?deviceName=` + devicecode+`&identifier=` + identifier })
  },
  getIotAlarmSettingPage: async (params: any, ifdevice:string) => {
    return await request.get({ url: `/rq/iot-alarm-setting/page/` + ifdevice, params })
  },
  batchUpdateAlarmSettings: async (alarms: any) => {
    debugger
    console.log(JSON.stringify(alarms))
    return await request.post({ url: `/rq/iot-alarm-setting/batch/update`, data:alarms })
  },
  // 查询告警设置详情
  getIotAlarmSetting: async (id: number) => {
    return await request.get({ url: `/rq/iot-alarm-setting/get?id=` + id })
  },

  // 新增告警设置
  createIotAlarmSetting: async (data: IotAlarmSettingVO) => {
    return await request.post({ url: `/rq/iot-alarm-setting/create`, data })
  },

  // 修改告警设置
  updateIotAlarmSetting: async (data: IotAlarmSettingVO) => {
    return await request.put({ url: `/rq/iot-alarm-setting/update`, data })
  },

  // 删除告警设置
  deleteIotAlarmSetting: async (id: number) => {
    return await request.delete({ url: `/rq/iot-alarm-setting/delete?id=` + id })
  },

  // 导出告警设置 Excel
  exportIotAlarmSetting: async (params) => {
    return await request.download({ url: `/rq/iot-alarm-setting/export-excel`, params })
  },
}
