import fetch from '@/utils/fetch'

/**
 * -----------------------设备分类-----------------------
 * 【查】 - 获取所有设备分类
 */
export const getDeviceClassifyApi = () =>
  fetch({ url: '/train/device/classify', method: 'get' })

/**
 * 【查】 - 新增设备分类
 * @param {object} data
 */

export const createDeviceClassifyApi = (data) =>
  fetch({ url: '/train/device/classify', method: 'post', data })

/**
 * 【改】 - 编辑设备分类
 * @param {object} data
 * @returns
 */
export const editorDeviceClassifyApi = (id, data) =>
  fetch({ url: '/train/device/classify/' + id, method: 'patch', data })

/**
* 【删】 - 删除设备分类
* @param {object} data
* @returns
*/
export const deleteDeviceClassifyApi = (id) =>
  fetch({ url: '/train/device/classify/' + id, method: 'delete' })

/**
 * -----------------------设备-----------------------
 * 【查】 - 分页查询设备
 * @param {object} data
 */

export const paginggetDeviceApi = (params) =>
  fetch({ url: '/train/device/device/paging', method: 'get', params })

/**
 * 【查】 - 查询所有设备
 */

export const getDeviceApi = () =>
  fetch({ url: '/train/device/device', method: 'get' })

/**
 * 【查】 - 查询设备详情
 * @param {object} data
 */

export const getDeviceDetailsApi = (id) =>
  fetch({ url: '/train/device/device/details/' + id, method: 'get' })

/**
 * 【增】 - 增加设备
 * @param {object} data
 */

export const createDevicesApi = (data) =>
  fetch({ url: '/train/device/device', method: 'post', data })

/**
 * 【改】 - 增加设备
 * @param {object} data
 */

export const editorDevicesApi = (id, data) =>
  fetch({ url: '/train/device/device/' + id, method: 'patch', data })

/**
* 【查】 - 查询设备拥有的部件及对应的部件状态
* @param {Array<Number>} data
*/

export const getDevicesInfoApi = (data) =>
  fetch({ url: '/train/device/device/findOperationContent', method: 'post', data: { devices: data } })

/**
* 【查】 - 删除设备
* @param {object} data
*/

export const deleteDevicesApi = (data) =>
  fetch({ url: '/train/device/device/all', method: 'delete', data })

/**
* 【删】 - 删除设备
* @param {object} data
*/

export const testConnectDeviceApi = (params) =>
  fetch({ url: '/train/device/device/ping', method: 'get', params })
