mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 21:47:54 +00:00
propagate subspace allocations
This commit is contained in:
@@ -47,7 +47,7 @@ import { SpaceProductAllocationEntity } from '@app/common/modules/space/entities
|
||||
import { SubspaceEntity } from '@app/common/modules/space/entities/subspace/subspace.entity';
|
||||
import { SubspaceProductAllocationEntity } from '@app/common/modules/space/entities/subspace/subspace-product-allocation.entity';
|
||||
import { DeviceEntity } from '@app/common/modules/device/entities';
|
||||
import { ISingleSubspaceModel } from '../interfaces';
|
||||
import { ISingleSubspaceModel, ISubspaceModelUpdates } from '../interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceModelService {
|
||||
@@ -199,7 +199,7 @@ export class SpaceModelService {
|
||||
param.projectUuid,
|
||||
);
|
||||
await queryRunner.connect();
|
||||
let modifiedSubspaces: ISingleSubspaceModel[] = [];
|
||||
let modifiedSubspaces: ISubspaceModelUpdates;
|
||||
try {
|
||||
await queryRunner.startTransaction();
|
||||
const spaces = await this.fetchModelSpaces(spaceModel);
|
||||
|
||||
@@ -16,6 +16,7 @@ import { SubspaceModelProductAllocationService } from './subspace-model-product-
|
||||
import {
|
||||
IRelocatedAllocation,
|
||||
ISingleSubspaceModel,
|
||||
ISubspaceModelUpdates,
|
||||
} from 'src/space-model/interfaces';
|
||||
import { SpaceEntity } from '@app/common/modules/space/entities/space.entity';
|
||||
import { SubSpaceService } from 'src/space/services/subspace';
|
||||
@@ -118,7 +119,7 @@ export class SubSpaceModelService {
|
||||
projectUuid: string,
|
||||
spaceTagUpdateDtos?: ModifyTagModelDto[],
|
||||
spaces?: SpaceEntity[],
|
||||
): Promise<ISingleSubspaceModel[]> {
|
||||
): Promise<ISubspaceModelUpdates> {
|
||||
try {
|
||||
if (!dtos || dtos.length === 0) {
|
||||
return;
|
||||
@@ -160,13 +161,16 @@ export class SubSpaceModelService {
|
||||
spaceModel,
|
||||
spaceTagUpdateDtos,
|
||||
);
|
||||
return [
|
||||
createdSubspaces ?? [],
|
||||
updatedSubspaces ?? [],
|
||||
deletedSubspaces ?? [],
|
||||
]
|
||||
.filter((arr) => arr.length > 0)
|
||||
.flat();
|
||||
return {
|
||||
subspaceModels: [
|
||||
createdSubspaces ?? [],
|
||||
updatedSubspaces ?? [],
|
||||
deletedSubspaces ?? [],
|
||||
]
|
||||
.filter((arr) => arr.length > 0)
|
||||
.flat(),
|
||||
updatedAllocations: updatedAllocations,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error in modifySubspaceModels:', error);
|
||||
throw new HttpException(
|
||||
|
||||
Reference in New Issue
Block a user