import request from '@/config/axios'

// 设备负责人分配 VO
export interface IotDevicePersonVO {
  id: number // 主键id
  deviceId: number // 设备id
  personId: number // 负责人id
  personName: string  // 负责人姓名
  status: number // 开启状态 0启用  1停用
  remark: string // 备注
}

// 设备负责人分配 API
export const IotDevicePersonApi = {
  // 查询设备负责人分配分页
  ifDuty: async (params: any) => {
    return await request.get({ url: `/pms/iot-device-person/if/duty/`+params })
  },
  // 查询设备负责人分配分页
  getIotDevicePersonPage: async (params: any) => {
    return await request.get({ url: `/pms/iot-device-person/page`, params })
  },

  // 根据设备id集合查询设备的负责人列表
  getPersonsByDeviceIds: async (params: any) => {
    return await request.get({ url: `/pms/iot-device-person/getPersonsByDeviceIds`, params })
  },

  // 查询设备负责人分配详情
  getIotDevicePerson: async (id: number) => {
    return await request.get({ url: `/pms/iot-device-person/get?id=` + id })
  },

  // 新增设备负责人分配
  createIotDevicePerson: async (data: IotDevicePersonVO) => {
    return await request.post({ url: `/pms/iot-device-person/create`, data })
  },

  // 保存 设备与人员 的关联关系
  saveDevicePersonRelation: async (data: any) => {
    return await request.post({ url: `/pms/iot-device-person/saveDevicePersons`, data })
  },

  // 修改设备负责人分配
  updateIotDevicePerson: async (data: IotDevicePersonVO) => {
    return await request.put({ url: `/pms/iot-device-person/update`, data })
  },

  // 删除设备负责人分配
  deleteIotDevicePerson: async (id: number) => {
    return await request.delete({ url: `/pms/iot-device-person/delete?id=` + id })
  },

  // 导出设备负责人分配 Excel
  exportIotDevicePerson: async (params) => {
    return await request.download({ url: `/pms/iot-device-person/export-excel`, params })
  },
}
