/**
 * 到访门禁接口
 */
import request from '@/utils/request'
import qs from 'qs'

// 门禁查询
export function getDoorListPage(params) {
  return request({
    url: 'door/listPage',
    method: 'get',
    params
  })
}

// 添加门禁
export function addDoor(params) {
  return request({
    url: 'door/add',
    method: 'post',
    params
  })
}
// 修改门禁
export function updateDoor(params) {
  return request({
    url: 'door/update',
    method: 'post',
    params
  })
}
// 绑定设备
export function bindDevice(params) {
  return request({
    url: 'door/bindDevice',
    method: 'post',
    params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
// 删除门禁
export function delDoor(ids) {
  return request({
    url: 'door/delete',
    method: 'post',
    params: {
      ids: ids
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}

// 远程开门
export function openDoor(id) {
  return request({
    url: 'door/remoteOpen',
    method: 'post',
    params: {
      doorId: id
    }
  })
}

// 常开常闭
export function openDoorAlways(params) {
  return request({
    url: 'door/updateOpenStatus',
    method: 'post',
    params
  })
}
