import service from '@/utils/request'

// 创建设备
export const addDevice = (data) => {
  return service({
    url: '/parking/device/create',
    method: 'post',
    data
  })
}

// 更新设备
export const editDevice = (data) => {
  return service({
    url: '/parking/device/update',
    method: 'put',
    data
  })
}

// 根据ID获取设备
export const obtainDeviceId = (id) => {
  return service({
    url: '/parking/device/get?id=' + id,
    method: 'get'
  })
}

// 根据编码获取设备
export const obtainDeviceCode = (code) => {
  return service({
    url: '/parking/device/get-by-code?code=' + code,
    method: 'get'
  })
}

// 获取设备列表
export const obtainDeviceList = (params) => {
  return service({
    url: '/parking/device/list',
    method: 'get',
    params
  })
}

// 删除设备
export const deleteDevice = (id) => {
  return service({
    url: '/parking/device/delete?id=' + id,
    method: 'delete'
  })
}

// 连接设备
export const joinDevice = (id) => {
  return service({
    url: '/parking/device/connectedDevice?id=' + id,
    method: 'get'
  })
}
