import { ApiClientFactory } from '../core/api.client.factory'; import { Project, ObjectConfig, CatchParam, GroupSortModel } from '../model/project.model'; import { CloudtProject } from '../model/cloudt/project'; import { VideoGroupItem } from '../model/surveillance.model'; import { ItemList } from '..'; export class ProjectService { constructor(private factory: ApiClientFactory) {} async loadProject(projectId: string): Promise { const project = await this.factory.entity.get(`/api/web/projects/${projectId}`); return project; } async loadCloudtProject(projectId: string): Promise { const cloudtProject = await this.factory.entity.get(`/api/projects/cloudt/project?id=${projectId}`); return cloudtProject; } /** * 项目过期情况 * @param projectId */ fetchProjectAuth(projectId: string) { return this.factory.entity.get('/api/auth/project', { projectId, }); } // 新 地图租户/企业/项目 地图信息 async loadObjectMap(objectType: string, objectId: string) { const response = await this.factory.entity.get(`/api/web/maps?objectType=${objectType}&objectId=${objectId}`); return response; } // 更新配置 async mergeConfig(objectType: string, objectId: string, data: any) { const response = await this.factory.entity.post( `/api/project/config/merge`, Object.assign(data, { objectType, objectId }) ); return response; } // 获取配置 async loadConfig(objectType: string, objectId: string) { const response = await this.factory.entity.get( `/api/project/config?objectType=${objectType}&objectId=${objectId}` ); return response; } // 抓取接口报错 async sendError(param: CatchParam) { const response = await this.factory.entity.post(`/api/system/exception/save`, param); return response; } /** * @function loadChannelsCount 获取通道总数 */ async loadChannelsCount(projectId: string): Promise { const result = await await this.factory.entity.get(`/api/devices/list/channels`, { projectId }); return result; } /** * @function saveSortType 保存列表排序类型 */ async saveSortType(projectId: string, sortType: 'auto' | 'custom'): Promise { const result = await this.factory.entity.put(`/api/devices/list/sort/type`, { projectId, sortType, }); return result; } /** * @function loadSortType 查询排序类型 */ async loadSortType(projectId: string): Promise { const result = await this.factory.entity.get(`/api/devices/list/sort/type?projectId=${projectId}`); return result; } /** * @function saveSortData 保存排序数据 */ async saveSortData(projectId: string, groupData: GroupSortModel[]): Promise { const result = await this.factory.entity.put(`/api/devices/list/sort/groups/${projectId}`, groupData); return result; } /** * @function loadGroupSortData 获取排序数据 */ async loadGroupSortData(projectId: string, params?: any): Promise { if (!params) { params = { includeEmpty: true, isIncludeGboxDevice: false, isIncludeUrlDevice: true, }; } const url = `/api/v2/devices/groups?objectType=project&objectId=${projectId}`; const response = await this.factory.entity.get(url, params); return response; } /** * 同步组织树 * @param tenantId * @returns */ async loadSyncAuth(tenantId: string): Promise { const url = `/api/org/syncProjects?tenantId=${tenantId}`; const response = await this.factory.entity.put(url); return response; } /** * 获取项目树for事件推送 */ async getProjectParentsTree(projectId: string) { const url = `/api/project/${projectId}/algorithmConfig/projectTree`; const response = await this.factory.entity.get>(url); return response; } /** * @function loadDeviceConfigList 获取设备配置列表 */ async loadDeviceConfigList(projectId: string) { const result = await this.factory.entity.get('/api/device/config/list', { projectId }) return result; } /** * @function loadChargeUserList 获取项目责任人列表 */ async loadChargeUserList(projectId: string) { const result = await this.factory.entity.get('/api/project/users/list', { projectId }) return result; } /** * 获取企业级责任人 * @param tenantId */ async loadTenantChargeUserList(tenantId: string) { const result = await this.factory.entity.get('/api/project/users/tenant/list', { tenantId }) return result; } /** * @function addChargeUser 添加项目负责人 */ async addChargeUser(param: object) { const result = await this.factory.entity.post('/api/project/users', param); return result; } /** * @function deleteChargeUser 删除项目负责人 */ async deleteChargeUser(projectId: string, userId: string) { const result = await this.factory.entity.delete(`/api/project/users?projectId=${projectId}&userId=${userId}`) return result; } /** * @function saveConfig 保存多个设备 */ async saveConfig(param: any[]) { const result = await this.factory.entity.put('/api/device/config/batch', param) return result; } /** * @function saveConfigSingle 保存单个设备 */ async saveConfigSingle(param: Object) { const result = await this.factory.entity.put('/api/device/config', param) return result; } }