import request from '@/config/axios'

// IOT组织 VO
export interface OrganizationVO {
  id: number // 组织id
  sort: number // 显示顺序
  workerUserId: number // 负责人/工人
  orgId: number // 绑定工位id
  name: string // 组织名称
  parentId: number // 父组织id
  status: number // 组织状态
  deviceType: string // 设备类型
  orgClass: string // 组织等级
  machineType: string // 机台类型
}

// IOT组织 API
export const OrganizationApi = {
  // 查询IOT组织列表
  getOrganizationList: async (params) => {
    return await request.get({ url: `/iot/organization/list`, params })
  },

  // 查询IOT组织详情
  getOrganization: async (id: number) => {
    return await request.get({ url: `/iot/organization/get?id=` + id })
  },

  // 新增IOT组织
  createOrganization: async (data: OrganizationVO) => {
    return await request.post({ url: `/iot/organization/create`, data })
  },

  // 修改IOT组织
  updateOrganization: async (data: OrganizationVO) => {
    return await request.put({ url: `/iot/organization/update`, data })
  },

  // 删除IOT组织
  deleteOrganization: async (id: number) => {
    return await request.delete({ url: `/iot/organization/delete?id=` + id })
  },

  // 导出IOT组织 Excel
  exportOrganization: async (params) => {
    return await request.download({ url: `/iot/organization/export-excel`, params })
  },
}
