import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceVO, DeviceForm, DeviceQuery } from '@/api/system/device/types';

/**
 * 查询设备-摄像机列表
 * @param query
 * @returns {*}
 */

export const listDevice = (query) => {
  return request({
    url: '/system/device/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备-摄像机详细
 * @param id
 */
export const getDevice = (id: string | number): AxiosPromise<DeviceVO> => {
  return request({
    url: '/system/device/' + id,
    method: 'get'
  });
};

/**
 * 新增设备-摄像机
 * @param data
 */
export const addDevice = (data) => {
  return request({
    url: '/system/device',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备-摄像机
 * @param data
 */
export const updateDevice = (data) => {
  return request({
    url: '/system/device',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备-摄像机
 * @param id
 */
export const delDevice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/device/' + id,
    method: 'delete'
  });
};
/**
 * 获取摄像机视频流
 * @param from
 */
export const getHlsCode = (from) => {
  return request({
    url: `/system/device/rtmp/${from}`,
    method: 'get'
  });
};
/**
 * 关闭摄像机视频流
 * @param from
 */
export const closeHlsCode = (from) => {
  return request({
    url: `/system/device/rtmp/close/${from}`,
    method: 'get'
  });
};
