import { ApiClientFactory } from '../../core/api.client.factory'; import { ProjectList } from '../../model/company/projectMap.model'; import { PushedInfoModel, TenantGroupModel } from '../../model/company/tenant.model'; export class TenantService { constructor(private factory: ApiClientFactory) {} /** * 集团数据推送 */ async fetchPushedInfoList(tenantId: string, thirdSystem: string, params: any = {}) { const result = await this.factory.entity.get(`/api/data/push/config/listByTenant`, { tenantId, thirdSystem, ...params, }); return result; } /** * 添加推送 * @param params */ async addPushedInfo(params: PushedInfoModel | PushedInfoModel[]) { let batch: string = ''; if (Array.isArray(params)) { batch = '/batch'; } const result = await this.factory.entity.post(`/api/data/push/config${batch}`, params); return result; } /** * 删除推送数据 */ async deletePushedInfo(id: string | string[]) { let ids = ''; if (Array.isArray(id)) { ids = id.join(','); } else { ids = id; } const result = await this.factory.entity.delete(`/api/data/push/config/deleteByIds?ids=${ids}`); return result; } /** * 推送数据 */ async pushInformation(projectId: string) { const result = await this.factory.entity.post(`/api/data/push/config/push?projectId=${projectId}`); return result; } /** * 批量推送 */ async pushInfomationByProjectIds(projectIds: string) { const result = await this.factory.entity.post( `/api/data/push/config/zwPushByProjectIds?projectIds=${projectIds}` ); return result; } /** * 按租户推送 */ async pushInfomationByTenantId(tenantId: string) { const result = await this.factory.entity.post(`/api/data/push/config/zwPushByTenantId?tenantId=${tenantId}`); return result; } /** * 租户 分组 * 创建分组 */ addGroup(id: string, params: TenantGroupModel) { return this.factory.surveillance.post(`/custom/devices/groups/${id}`, params); } updateGroup(id: string, params: TenantGroupModel[]) { return this.factory.surveillance.put(`/custom/devices/groups/${id}`, params); } /** * 查询分组 */ fetchGroup(id: string) { return this.factory.surveillance.get(`/custom/devices/groups/${id}`); } /** * 开启展示分组 */ showGroup(id: string, show: boolean) { return this.factory.surveillance.put(`/custom/devices/groups/${id}/${show ? 'showOn' : 'showOff'}`); } loadProjectList(params: { orgId: string; tenantId: string; projectStatus?: string }): Promise { return this.factory.surveillance.get(`/org/projects`, params); } /** * 前台分组查询 */ fetchGroupTree(tenantId: string, orgId: string, params?: any) { return this.factory.surveillance.get(`/custom/devices/groups/${tenantId}/${orgId}/tree`, params); } fetchGroupDevices(tenantId: string, orgId: string, groupId: string, params?: any) { return this.factory.surveillance.get(`/custom/devices/groups/${tenantId}/${orgId}/${groupId}/devices`, params); } }