mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 16:44:55 +00:00
Merge branch 'dev' of https://github.com/SyncrowIOT/backend into feat/fix-propagation
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 { NewTagEntity } from '@app/common/modules/tag';
|
||||||
import { ProductEntity } from '@app/common/modules/product/entities';
|
import { ProductEntity } from '@app/common/modules/product/entities';
|
||||||
import { SpaceRepository } from '@app/common/modules/space';
|
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';
|
import { SpaceEntity } from '@app/common/modules/space/entities/space.entity';
|
||||||
import { ProjectEntity } from '@app/common/modules/project/entities';
|
import { ProjectEntity } from '@app/common/modules/project/entities';
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ export class SpaceModelProductAllocationService {
|
|||||||
private readonly tagService: NewTagService,
|
private readonly tagService: NewTagService,
|
||||||
private readonly spaceModelProductAllocationRepository: SpaceModelProductAllocationRepoitory,
|
private readonly spaceModelProductAllocationRepository: SpaceModelProductAllocationRepoitory,
|
||||||
private readonly spaceRepository: SpaceRepository,
|
private readonly spaceRepository: SpaceRepository,
|
||||||
private readonly spaceProductAllocationService: SpaceProductAllocationService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async createProductAllocations(
|
async createProductAllocations(
|
||||||
@ -115,23 +113,12 @@ export class SpaceModelProductAllocationService {
|
|||||||
} else if (!allocation.tags.some((t) => t.uuid === tag.uuid)) {
|
} else if (!allocation.tags.some((t) => t.uuid === tag.uuid)) {
|
||||||
allocation.tags.push(tag);
|
allocation.tags.push(tag);
|
||||||
await this.saveAllocation(allocation, queryRunner);
|
await this.saveAllocation(allocation, queryRunner);
|
||||||
await this.spaceProductAllocationService.addTagToAllocationFromModel(
|
|
||||||
allocation,
|
|
||||||
queryRunner,
|
|
||||||
tag,
|
|
||||||
spaces,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (productAllocations.length > 0) {
|
if (productAllocations.length > 0) {
|
||||||
await this.saveAllocations(productAllocations, queryRunner);
|
await this.saveAllocations(productAllocations, queryRunner);
|
||||||
await this.spaceProductAllocationService.createAllocationFromModel(
|
|
||||||
productAllocations,
|
|
||||||
queryRunner,
|
|
||||||
spaces,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return productAllocations;
|
return productAllocations;
|
||||||
|
|||||||
@ -170,10 +170,10 @@ export class ValidationService {
|
|||||||
where: { uuid: spaceModelUuid },
|
where: { uuid: spaceModelUuid },
|
||||||
relations: [
|
relations: [
|
||||||
'subspaceModels',
|
'subspaceModels',
|
||||||
'subspaceModels.tags',
|
'subspaceModels.productAllocations',
|
||||||
'tags',
|
'subspaceModels.productAllocations.tags',
|
||||||
'subspaceModels.tags.product',
|
'productAllocations.product',
|
||||||
'tags.product',
|
'productAllocations.tags',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,7 @@ export class SpaceService {
|
|||||||
this.validateUniqueTags(allTags);
|
this.validateUniqueTags(allTags);
|
||||||
if (spaceModelUuid) {
|
if (spaceModelUuid) {
|
||||||
const hasDependencies = subspaces?.length > 0 || tags?.length > 0;
|
const hasDependencies = subspaces?.length > 0 || tags?.length > 0;
|
||||||
if (!hasDependencies && !newSpace.spaceModel) {
|
if (!hasDependencies) {
|
||||||
await this.spaceModelService.linkToSpace(
|
await this.spaceModelService.linkToSpace(
|
||||||
newSpace,
|
newSpace,
|
||||||
spaceModel,
|
spaceModel,
|
||||||
@ -246,10 +246,11 @@ export class SpaceService {
|
|||||||
const spaces = await queryBuilder.getMany();
|
const spaces = await queryBuilder.getMany();
|
||||||
|
|
||||||
const transformedSpaces = spaces.map(this.transformSpace);
|
const transformedSpaces = spaces.map(this.transformSpace);
|
||||||
|
const spaceHierarchy = this.buildSpaceHierarchy(transformedSpaces);
|
||||||
|
|
||||||
return new SuccessResponseDto({
|
return new SuccessResponseDto({
|
||||||
message: `Spaces in community ${communityUuid} successfully fetched in hierarchy`,
|
message: `Spaces in community ${communityUuid} successfully fetched in hierarchy`,
|
||||||
data: onlyWithDevices ? spaces : transformedSpaces,
|
data: onlyWithDevices ? spaces : spaceHierarchy,
|
||||||
statusCode: HttpStatus.OK,
|
statusCode: HttpStatus.OK,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user