mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 00:34:54 +00:00
fix the issue in unliking
This commit is contained in:
@ -190,6 +190,8 @@ export class SpaceProductAllocationService {
|
||||
queryRunner: QueryRunner,
|
||||
modifySubspace?: ModifySubspaceDto[],
|
||||
): Promise<void> {
|
||||
if (!dtos || dtos.length === 0) return;
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
this.processAddActions(
|
||||
@ -343,10 +345,7 @@ export class SpaceProductAllocationService {
|
||||
space: SpaceEntity,
|
||||
): Promise<SpaceProductAllocationEntity[]> {
|
||||
try {
|
||||
if (!dtos || dtos.length === 0) {
|
||||
throw new Error('No DTOs provided for deletion.');
|
||||
}
|
||||
|
||||
if (!dtos || dtos.length === 0) return;
|
||||
const tagUuidsToDelete = dtos
|
||||
.filter((dto) => dto.action === ModifyAction.DELETE && dto.tagUuid)
|
||||
.map((dto) => dto.tagUuid);
|
||||
|
||||
@ -133,6 +133,7 @@ export class ValidationService {
|
||||
'subspaces.productAllocations.product',
|
||||
'subspaces.tags',
|
||||
'subspaces.devices',
|
||||
'spaceModel',
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@ -449,6 +449,11 @@ export class SpaceService {
|
||||
);
|
||||
}
|
||||
|
||||
if (space.spaceModel && !updateSpaceDto.spaceModelUuid) {
|
||||
space.spaceModel = null;
|
||||
await this.unlinkSpaceFromModel(space, queryRunner);
|
||||
}
|
||||
|
||||
this.updateSpaceProperties(space, updateSpaceDto);
|
||||
|
||||
if (updateSpaceDto.spaceModelUuid) {
|
||||
@ -535,15 +540,6 @@ export class SpaceService {
|
||||
queryRunner: QueryRunner,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await queryRunner.manager.update(
|
||||
this.spaceRepository.target,
|
||||
{ uuid: space.uuid },
|
||||
{
|
||||
spaceModel: null,
|
||||
},
|
||||
);
|
||||
|
||||
// Unlink subspaces and tags if they exist
|
||||
if (space.subspaces || space.tags) {
|
||||
if (space.tags) {
|
||||
await this.spaceProductAllocationService.unlinkModels(
|
||||
|
||||
Reference in New Issue
Block a user