import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FloorInfoForm, FloorInfoQuery, FloorInfoVO } from './types';

export const listFloorInfo = (query?: FloorInfoQuery): AxiosPromise<FloorInfoVO[]> => {
  return request({
    url: '/floorInfo/list',
    method: 'get',
    params: query
  });
};

export const getFloorInfo = (id: string | number): AxiosPromise<FloorInfoVO> => {
  return request({
    url: '/floorInfo/' + id,
    method: 'get'
  });
};

export const addFloorInfo = (data: FloorInfoForm) => {
  return request({
    url: '/floorInfo',
    method: 'post',
    data
  });
};

export const updateFloorInfo = (data: FloorInfoForm) => {
  return request({
    url: '/floorInfo',
    method: 'put',
    data
  });
};

export const mountFloorDevice = (data: FloorInfoForm) => {
  return request({
    url: '/floorInfo/mountDevice',
    method: 'post',
    data
  });
};

export const syncFloorMountedDevices = () => {
  return request({
    url: '/floorInfo/syncMountedDevices',
    method: 'post'
  });
};

export const delFloorInfo = (id: string | number) => {
  return request({
    url: '/floorInfo/' + id,
    method: 'delete'
  });
};
