import { ApiClientFactory } from '../core/api.client.factory'; import { BroadcastList, CreateBroadcastData, Vendors, Groups, BroadcastDetail, Doc, BroadcastReq, BroadcastInfo, TextAudioData, SipOnlineReq, } from '../model/sipBroadcastConfig.model'; export class SipBroadcastConfigService { constructor(private factory: ApiClientFactory) {} /** * @function syncBroadcastData 同步广播数据 * @param projectId 项目ID */ async syncBroadcastData(projectId: string): Promise { return await this.factory.surveillance.put(`/sip/bc/sync/${projectId}`); } /** * @function loadBroadcastList 获取广播列表 * @param projectId 项目ID */ async loadBroadcastList(projectId: string, params?: object): Promise { const result = await this.factory.surveillance.get(`/sip/broadcast/list`, { projectId, ...params, }); return result; } /** * @function createBroadcast 新建和更新广播 * @param broadcastData 更新的数据,具体参数查看CreateBroadcastData */ async createBroadcast(broadcastData: CreateBroadcastData): Promise { return await this.factory.surveillance.put(`/sip/broadcast`, broadcastData); } /** * @function deleteBroadcast 删除广播 * @param projectId * @param id */ async deleteBroadcast(projectId: string, id: string): Promise { return await this.factory.surveillance.delete(`sip/broadcast`, { projectId, id }); } /** * @function updateBroadcastStatus 修改广播启用状态 * @param projectId * @param id * @param status // 启用:on,关闭:off */ async updateBroadcastStatus(projectId: string, id: string, status: string): Promise { return await this.factory.surveillance.put(`sip/broadcast/${status}`, { projectId, id }); } /** * @function updateBroadcastAllStatus 批量修改广播启用状态 * @param projectId * @param id * @param status // 启用:on,关闭:off */ async updateBroadcastAllStatus(projectId: string, status: string): Promise { return await this.factory.surveillance.put(`sip/broadcast/${status}`, { projectId }); } /** * @function loadBroadcastVendor 获取厂商 */ async loadBroadcastVendor(): Promise { const result = await this.factory.surveillance.get(`/sip/bc/vendors`); return result; } /** * @function loadBroadcastGroup 获取分组 */ async loadBroadcastGroup(): Promise { const result = await this.factory.surveillance.get(`/sip/bc/groups`); return result; } /** * @function loadBroadcastDetail 获取广播详情 */ async loadBroadcastDetail(id: string): Promise { const result = await this.factory.surveillance.get(`/sip/broadcast/${id}`); return result; } /** * @function loadDoc 获取配置手册 */ async loadDoc(): Promise { const result = await this.factory.surveillance.get(`/sip/bc/download/getUrl`); return result; } // /** // * @function loadConfig 下发配置 // */ // async loadConfig(projectId: string): Promise { // const result = await this.factory.surveillance.put(`/sip/broadcast/syncConfig/${projectId}`); // return result; // } /** * @function createBroadcastTest 创建播放测试 */ async createBroadcastTest(broadcastReq: BroadcastReq): Promise { const result = await this.factory.surveillance.post(`/sip/play/test`, broadcastReq); return result; } /** * @function getBroadcastAudio 获取文字转语音文件 */ async getBroadcastAudio(broadcastReq: BroadcastReq): Promise { const result = await this.factory.surveillance.post(`/sip/play/voice/url`, broadcastReq); return result; } /** * @function syncConfig 下发事件规 则 */ async syncConfig(projectId: string, gatewayId: string, version?: 1 | 2): Promise { const result = await this.factory.surveillance.put(`/edge/v2/syncConfig/${projectId}/${gatewayId}`); return result; } /** * @function loadBroadcastInfo 获取广播信息 */ async loadBroadcastInfo(projectId: string): Promise { const result = await this.factory.surveillance.get(`/sip/voice/${projectId}`); return result; } /** * @function syncBroadcastDevice 下发广播设备 */ async syncBroadcastDevice(projectId: string, gatewayId: string): Promise { const result = await this.factory.surveillance.put(`/edge/v2/syncSipDeviceToBox/${projectId}/${gatewayId}`); return result; } /** * @function loadDeviceBroadcastInfo 获取设备关联的广播 * @param projectId 项目ID */ async loadDeviceBroadcastInfo(projectId: string, cameraId: string): Promise { const result = await this.factory.surveillance.get(`/sip/broadcast/listByCamera?`, { projectId, cameraId, }); return result; } async fetchGateWayList(projectId: string) { return this.factory.surveillance.get(`/sip/broadcast/listGateway`, { projectId, }); } /** * 更新广播设备状态 * @param param * @returns */ async setSipOnline(param: SipOnlineReq) { return this.factory.surveillance.post(`/sip/callback/updateOnline`, param); } }