import request from '@/utils/request'

export function listTsbDevice(query) {
  return request({
    url: '/tsb/device/list',
    method: 'get',
    params: query
  })
}

/** 首页调试宝设备卡片列表 */
export function listTsbDeviceHome() {
  return request({
    url: '/tsb/device/home/list',
    method: 'get'
  })
}

export function getTsbDevice(deviceId) {
  return request({
    url: '/tsb/device/' + deviceId,
    method: 'get'
  })
}

export function addTsbDevice(data) {
  return request({
    url: '/tsb/device',
    method: 'post',
    data: data
  })
}

export function updateTsbDevice(data) {
  return request({
    url: '/tsb/device',
    method: 'put',
    data: data
  })
}

export function changeTsbDeviceStatus(deviceId, status) {
  return request({
    url: '/tsb/device/changeStatus',
    method: 'put',
    data: { deviceId, status }
  })
}

export function delTsbDevice(deviceId) {
  return request({
    url: '/tsb/device/' + deviceId,
    method: 'delete'
  })
}

/** 强制删除：先解绑再逻辑删设备 */
export function forceDelTsbDevice(deviceIds) {
  return request({
    url: '/tsb/device/force/' + deviceIds,
    method: 'delete'
  })
}

export function listTsbBind(query) {
  return request({
    url: '/tsb/device/bind/list',
    method: 'get',
    params: query
  })
}

export function listTsbUnboundUsers() {
  return request({
    url: '/tsb/device/unbindUsers',
    method: 'get'
  })
}

export function getTsbBindByDevice(deviceId) {
  return request({
    url: '/tsb/device/bindByDevice/' + deviceId,
    method: 'get'
  })
}

export function bindTsbUserDevice(userId, deviceId) {
  return request({
    url: '/tsb/device/bindUserDevice',
    method: 'put',
    params: { userId, deviceId }
  })
}

export function unbindTsbUserDevice(userId, deviceId) {
  return request({
    url: '/tsb/device/unbindUserDevice',
    method: 'put',
    params: { userId, deviceId }
  })
}
