ils_front/src/apis/rtsp/index.js

34 lines
1.1 KiB
JavaScript

// src/apis/rtsp/index.js
import {
POST_SET_RTSP_ENABLE,
POST_SET_SAMBA_DIRECTORY,
POST_GET_RTSP_DEVICE,
} from "./api";
import instance from "@/util/request";
import apihandler from "@/util/apihandler";
/**
* 開關 RTSP
* Swagger: POST /api/rtsp/set-rtsp-enable
* body: { main_id: number, enable: boolean }
*/
export const setRtspEnable = async ({ main_id, enable }) => {
const res = await instance.post(POST_SET_RTSP_ENABLE, { main_id, enable });
return apihandler(res.code, res.data, { msg: res.msg, code: res.code });
};
/**
* 取得 RTSP 裝置清單
* Swagger: POST /api/rtsp/get-rtsp-device
* body: 可為空物件 {} 或依後端需求帶 building_guid 等參數
* response.data: [
* { main_id, device_number, full_name, device_ip, device_port, rtsp_url,
* enable_traffic, start_btn_enable, stop_btn_enable, alarm_message }
* ]
*/
export const getRtspDevices = async (payload = {}) => {
const res = await instance.post(POST_GET_RTSP_DEVICE, payload);
// 後端回傳格式如題:{ code, msg, data: [...] }
return apihandler(res.code, res.data, { msg: res.msg, code: res.code });
};