import { ApiClientFactory } from '../core'; import { CarouselConfig, CarouselGroup, FlvUrlCameraModel } from '../model'; /** * 页面轮播 / 视频轮播 */ export class PageCarouselService { constructor(public factory: ApiClientFactory, public type: 'project' | 'tenant' = 'project') {} /** * 查询数据 */ fetchGroups(mainId: string) { return this.factory.surveillance.get(`/${this.type}/${mainId}/carousel/list`); } /** * 添加分组 */ updateGroup(mainId: string, param: any) { return this.factory.surveillance.put(`/${this.type}/${mainId}/carousel/saveGroup`, param); } /** * 删除分组 */ deleteGroup(mainId: string, id: string) { return this.factory.surveillance.delete(`/${this.type}/${mainId}/carousel/${id}`); } /** * 启用分组 */ enableGroup(mainId: string, id: string, enable: boolean) { return this.factory.surveillance.put(`/${this.type}/${mainId}/carousel/groupOn/${id}`); } /** * 添加菜单 */ updateMenu(mainId: string, groupId: string, param: any) { return this.factory.surveillance.put(`/${this.type}/${mainId}/carousel/saveMenu/${groupId}`, param); } /** * 菜单移动 */ moveMenu(mainId: string, groupId: string, menuId: string, sort: 'up' | 'down') { return this.factory.surveillance.put(`/${this.type}/${mainId}/carousel/sortMenu/${groupId}`, { menuId, sort, }); } /** * 删除菜单 */ deleteMenu(mainId: string, groupId: string, menuId: string) { return this.factory.surveillance.delete(`/${this.type}/${mainId}/carousel/deleteMenu/${groupId}/${menuId}`); } /** * 获取Flv设备播放地址列表 */ fetchDeviceUrl(projectId: string) { return this.factory.surveillance.get(`/live/mse/urls`, { projectId, }); } /** * 获取Flv设备播放地址列表 */ fetchTenantDeviceUrl(mainId: string, deviceIds: any, method: string = 'get') { const params = this.type === 'project' ? { projectId: mainId, deviceIds, } : { tenantId: mainId, deviceIds, }; const url = `/${this.type}/live/flv/urls/devices`; if (method === 'post') { return this.factory.surveillance.post(url, params); } else { return this.factory.surveillance.get(url, params); } } /** * 获取轮播组Flv设备播放地址列表 */ fetchTenantDeviceUrlByGroupId(mainId: string, groupId: string) { const params = this.type === 'project' ? { projectId: mainId, groupId, } : { tenantId: mainId, groupId, }; return this.factory.surveillance.get(`/${this.type}/live/flv/urls`, params); } /** * 根据轮播组id获取设备信息 */ fetchDeviceListByGroupId(mainId: string, groupId: string) { return this.factory.surveillance.get(`/${this.type}/${mainId}/carousel/projectCamera/${groupId}`); } /** * 企业视频轮播 */ saveCarouselConfig(req: CarouselConfig) { return this.factory.surveillance.post(`/tenant25/carousel/config`, req); } deleteCarouselConfig(tenantId: string, treeId: string, userId: string) { return this.factory.surveillance.delete( `/tenant25/carousel/config?tenantId=${tenantId}&treeId=${treeId}&userId=${userId}` ); } loadCarouselConfig(tenantId: string, treeId: string, userId: string) { return this.factory.surveillance.get(`/tenant25/carousel/config/detail`, { tenantId, treeId, userId, }); } }