import request from '@/utils/request'

// 查询设备列表
export function listDevice(query) {
  return request({
    url: '/bst/device/list',
    method: 'get',
    params: query
  })
}

// 查询设备详细
export function getDevice(deviceId) {
  return request({
    url: '/bst/device/' + deviceId,
    method: 'get'
  })
}

// 新增设备
export function addDevice(data) {
  return request({
    url: '/bst/device',
    method: 'post',
    data: data
  })
}

// 修改设备
export function updateDevice(data) {
  return request({
    url: '/bst/device',
    method: 'put',
    data: data
  })
}

// 删除设备
export function logicDelDevice(deviceId) {
  return request({
    url: '/bst/device/logic/' + deviceId,
    method: 'delete'
  })
}

// 删除设备
export function delDevice(deviceId) {
  return request({
    url: '/bst/device/' + deviceId,
    method: 'delete'
  })
}

// 设置设备开启时间
export function deviceSetTime(deviceId, duration) {
  return request({
    url: `/bst/device/setTime/${deviceId}?duration=${duration}`,
    method: 'put'
  })
}

// 设备绑定商户
export function bindMch(device,mchId) {
  return request({
    url: `/bst/device/bindMch?mchId=${mchId}`,
    method: 'put',
    data: device,
  })
}

// 设备解绑商户
export function unbindMch(deviceId) {
  return request({
    url: `/bst/device/${deviceId}/unbind`,
    method: 'delete',
  })
}


// 设备解绑商户
export function changeStore(device) {
  return request({
    url: `/bst/device/changeStore`,
    method: 'put',
    data:device
  })
}
