import request from '@/config/axios'

// 电表监测类型定义
export interface ElectricityMonitoring {
  id?: number | string
  deviceCode: string
  deviceName: string
  location?: string
  currentKWh: number
  lastKWh?: number
  lastDate?: string
  status: 'online' | 'offline' | 'maintenance'
  remark?: string
  text1?: string
  text2?: string
  text3?: string
  createTime?: string
  updateTime?: string
  creator?: string
  updater?: string
  deleted?: boolean
  tenantId?: number
}

// 分页查询参数
export enum ElectricityMonitoringStatus {
  Online = 'online',
  Offline = 'offline',
  Maintenance = 'maintenance',
}

export interface ElectricityMonitoringPageParams {
  pageNo: number
  pageSize: number
  deviceCode?: string
  deviceName?: string
  location?: string
  status?: ElectricityMonitoringStatus | string
}

// 分页查询
export const getElectricityMonitoringPage = (params: ElectricityMonitoringPageParams) => {
  return request.get({ url: '/energy/electricity-monitoring/page', params })
}

// 新增电表监测
export const createElectricityMonitoring = (data: ElectricityMonitoring) => {
  return request.post({ url: '/energy/electricity-monitoring/create', data })
}

// 更新电表监测
export const updateElectricityMonitoring = (data: ElectricityMonitoring) => {
  return request.put({ url: '/energy/electricity-monitoring/update', data })
}

// 删除电表监测
export const deleteElectricityMonitoring = (id: number | string) => {
  return request.delete({ url: `/energy/electricity-monitoring/delete?id=${id}` })
}

// 获取电表监测详情
export const getElectricityMonitoring = (id: number | string) => {
  return request.get({ url: `/energy/electricity-monitoring/get?id=${id}` })
}
