import { ApiClientFactory } from '../core/api.client.factory'; import { GbVideoList, CreateCamera, CreateLocalVideo, Docs, CreateNVR, VendorList, CategoryList, DeviceDetail, } from '../model/gbConfig.model'; export class GbConfigService { constructor(private factory: ApiClientFactory) {} /** * @function loadDocs 获取文档 * @param projectId 项目ID */ async loadDocs(projectId: string): Promise { const result = await this.factory.surveillance.get( `/config/gb/projects/${projectId}/devices/download/getUrl` ); return result; } /** * @function loadGbVideoList 获取国标NVR或设备列表 * @param projectId 项目ID * @param type NVR,Camera */ async loadGbVideoList(projectId: string, type: string, params?: object): Promise { const result = await this.factory.surveillance.get( `/config/gb/projects/${projectId}/devices/list?type=${type}`, params ); return result; } /** * @function createVideoNVR 新建和更新NVR * @param projectId 项目ID * @param nvrData 更新的数据,具体参数查看CreateNVR */ async createVideoNVR(projectId: string, nvr: CreateNVR): Promise { return await this.factory.surveillance.put(`/config/gb/projects/${projectId}/devices/nvr`, nvr); } /** * @function createVideoCamera 新建和更新camera * @param projectId 项目ID * @param camera 更新的数据,具体参数查看CreateCamera */ async createVideoCamera(projectId: string, camera: CreateCamera): Promise { return await this.factory.surveillance.put(`/config/gb/projects/${projectId}/devices/ipc`, camera); } /** * @function createLocalVideo 新建和更新本地camera或nvr * @param projectId 项目ID */ async createLocalVideo(projectId: string, req: CreateLocalVideo): Promise { return await this.factory.surveillance.put(`/config/gb/projects/${projectId}/devices/rtsp`, req); } /** * @function deleteDevice 删除nvr或camera,通用接口 * @param projectId * @param id */ async deleteDevice(projectId: string, id: string): Promise { return await this.factory.surveillance.delete(`config/gb/projects/${projectId}/devices/${id}`); } /** * @function deleteDeviceLocalConfig 删除设备本地配置 * @param projectId * @param id */ async deleteDeviceLocalConfig(projectId: string, id: string): Promise { return await this.factory.surveillance.delete(`config/gb/projects/${projectId}/devices/rtsp/${id}`); } /** * @function syncGbData 同步筑联的数据 * @param projectId 项目ID */ async syncGbData(projectId: string): Promise { return await this.factory.surveillance.put(`/config/gb/projects/${projectId}/devices/syncDeviceInfo`); } /** * @function loadVendorList 获取vendor厂家信息列表 */ async loadVendorList(): Promise { const result = await this.factory.surveillance.get(`/system/dict/vendors`); return result; } /** * @function loadCategoryList 获取Category信息列表 */ async loadCategoryList(): Promise { const result = await this.factory.surveillance.get(`/system/dict/cameraTypes`); return result; } /** * @function loadDeviceDetail 获取设备详情信息 * @param projectId 项目ID * @param deviceId 设备ID */ async loadDeviceDetail(projectId: string, deviceId: string): Promise { const result = await this.factory.surveillance.get( `/config/gb/projects/${projectId}/devices/${deviceId}` ); return result; } /** * @function 监控全部 */ async addAllMonitor(projectId: string) { return await this.factory.surveillance.put(`/config/gb/projects/${projectId}/devices/monitor`); } /** * @function 取消监控全部 */ async cancelAllMonitor(projectId: string) { return await this.factory.surveillance.put(`/config/gb/projects/${projectId}/devices/cancelMonitor`); } /** * @function 加入监控 */ async addMonitor(projectId: string, deviceId: string) { return await this.factory.surveillance.put(`config/gb/projects/${projectId}/devices/${deviceId}/monitor`); } /** * @function 取消监控 */ async cancelMonitor(projectId: string, deviceId: string) { return await this.factory.surveillance.put( `config/gb/projects/${projectId}/devices/${deviceId}/cancelMonitor` ); } /** * @function 同步截图 */ async syncDeviceImage(projectId: string) { return await this.factory.surveillance.put(`config/gb/projects/${projectId}/devices/syncDeviceImage`); } /** * @function 分享设备到其他项目 */ async shareDevices(projectId: string, destProjectId: string) { return await this.factory.surveillance.get( `config/gb/projects/${projectId}/devices/copyDevice/${destProjectId}` ); } }