import request from '@/config/axios'

// 设备关系 VO
export interface RelationVO {
  id: number // 主键
  parentId: number // 父设备ID
  deviceId: number // 设备ID
}

// 设备关系 API
export const RelationApi = {
  // 查询设备关系分页
  getRelationPage: async (params: any) => {
    return await request.get({ url: `/device/relation/page`, params })
  },

  // 查询设备关系详情
  getRelation: async (id: number) => {
    return await request.get({ url: `/device/relation/get?id=` + id })
  },

  // 新增设备关系
  createRelation: async (data: RelationVO) => {
    return await request.post({ url: `/device/relation/create`, data })
  },

  // 修改设备关系
  updateRelation: async (data: RelationVO) => {
    return await request.put({ url: `/device/relation/update`, data })
  },

  // 删除设备关系
  deleteRelation: async (id: number) => {
    return await request.delete({ url: `/device/relation/delete?id=` + id })
  },

  // 导出设备关系 Excel
  exportRelation: async (params) => {
    return await request.download({ url: `/device/relation/export-excel`, params })
  },
}
