mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
fixed get spaces
This commit is contained in:
@ -14,7 +14,6 @@ import { ModifyAction } from '@app/common/constants/modify-action.enum';
|
||||
import { NewTagEntity } from '@app/common/modules/tag';
|
||||
import { ProductEntity } from '@app/common/modules/product/entities';
|
||||
import { SpaceRepository } from '@app/common/modules/space';
|
||||
import { SpaceProductAllocationService } from 'src/space/services/space-product-allocation.service';
|
||||
import { SpaceEntity } from '@app/common/modules/space/entities/space.entity';
|
||||
|
||||
@Injectable()
|
||||
@ -23,7 +22,6 @@ export class SpaceModelProductAllocationService {
|
||||
private readonly tagService: NewTagService,
|
||||
private readonly spaceModelProductAllocationRepository: SpaceModelProductAllocationRepoitory,
|
||||
private readonly spaceRepository: SpaceRepository,
|
||||
private readonly spaceProductAllocationService: SpaceProductAllocationService,
|
||||
) {}
|
||||
|
||||
async createProductAllocations(
|
||||
@ -114,23 +112,12 @@ export class SpaceModelProductAllocationService {
|
||||
} else if (!allocation.tags.some((t) => t.uuid === tag.uuid)) {
|
||||
allocation.tags.push(tag);
|
||||
await this.saveAllocation(allocation, queryRunner);
|
||||
await this.spaceProductAllocationService.addTagToAllocationFromModel(
|
||||
allocation,
|
||||
queryRunner,
|
||||
tag,
|
||||
spaces,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (productAllocations.length > 0) {
|
||||
await this.saveAllocations(productAllocations, queryRunner);
|
||||
await this.spaceProductAllocationService.createAllocationFromModel(
|
||||
productAllocations,
|
||||
queryRunner,
|
||||
spaces,
|
||||
);
|
||||
}
|
||||
|
||||
return productAllocations;
|
||||
|
@ -276,10 +276,11 @@ export class SpaceService {
|
||||
const spaces = await queryBuilder.getMany();
|
||||
|
||||
const transformedSpaces = spaces.map(this.transformSpace);
|
||||
const spaceHierarchy = this.buildSpaceHierarchy(transformedSpaces);
|
||||
|
||||
return new SuccessResponseDto({
|
||||
message: `Spaces in community ${communityUuid} successfully fetched in hierarchy`,
|
||||
data: onlyWithDevices ? spaces : transformedSpaces,
|
||||
data: onlyWithDevices ? spaces : spaceHierarchy,
|
||||
statusCode: HttpStatus.OK,
|
||||
});
|
||||
} catch (error) {
|
||||
|
Reference in New Issue
Block a user