import request from '@/config/axios'

// 设备分类 VO
export interface IotYfClassifyVO {
  id: number // 主键id
  parentId: number // 父分类id
  name: string // 分类名称
  code: string // 分类编码
  sort: number // 分类排序
  status: number // 开启状态
}

// 设备分类 API
export const IotYfClassifyApi = {
  // 查询设备分类分页
  getChildrenList: async () => {
    return await request.get({ url: `/rq/iot-yf-classify/children-list`})
  },
  // 查询设备分类分页
  getIotYfClassifyPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-yf-classify/list`, params })
  },

  // 查询设备分类详情
  getIotYfClassify: async (id: number) => {
    return await request.get({ url: `/rq/iot-yf-classify/get?id=` + id })
  },

  // 新增设备分类
  createIotYfClassify: async (data: IotYfClassifyVO) => {
    return await request.post({ url: `/rq/iot-yf-classify/create`, data })
  },

  // 修改设备分类
  updateIotYfClassify: async (data: IotYfClassifyVO) => {
    return await request.put({ url: `/rq/iot-yf-classify/update`, data })
  },

  // 删除设备分类
  deleteIotYfClassify: async (id: number) => {
    return await request.delete({ url: `/rq/iot-yf-classify/delete?id=` + id })
  },

  // 导出设备分类 Excel
  exportIotYfClassify: async (params) => {
    return await request.download({ url: `/rq/iot-yf-classify/export-excel`, params })
  },
  getSimpleYfClassifyList: async (): Promise<IotYfClassifyVO[]> => {
    return await request.get({ url: '/rq/iot-yf-classify/simple-list' })
  }
}
