mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
fixed allocating tag from subspace to space
This commit is contained in:
@ -192,7 +192,7 @@ export class SpaceModelProductAllocationService {
|
||||
modifySubspaceModels,
|
||||
spaces,
|
||||
),
|
||||
this.processDeleteActions(filteredDtos, queryRunner),
|
||||
this.processDeleteActions(filteredDtos, queryRunner, spaceModel),
|
||||
]);
|
||||
} catch (error) {
|
||||
throw this.handleError(error, 'Error while updating product allocations');
|
||||
@ -297,6 +297,7 @@ export class SpaceModelProductAllocationService {
|
||||
private async processDeleteActions(
|
||||
dtos: ModifyTagModelDto[],
|
||||
queryRunner: QueryRunner,
|
||||
spaceModel: SpaceModelEntity,
|
||||
): Promise<SpaceModelProductAllocationEntity[]> {
|
||||
try {
|
||||
if (!dtos || dtos.length === 0) {
|
||||
@ -312,7 +313,12 @@ export class SpaceModelProductAllocationService {
|
||||
const allocationsToUpdate = await queryRunner.manager.find(
|
||||
SpaceModelProductAllocationEntity,
|
||||
{
|
||||
where: { tags: { uuid: In(tagUuidsToDelete) } },
|
||||
where: {
|
||||
tags: { uuid: In(tagUuidsToDelete) },
|
||||
spaceModel: {
|
||||
uuid: spaceModel.uuid,
|
||||
},
|
||||
},
|
||||
relations: ['tags'],
|
||||
},
|
||||
);
|
||||
|
@ -243,17 +243,19 @@ export class SubspaceModelProductAllocationService {
|
||||
.delete()
|
||||
.from('subspace_model_product_tags')
|
||||
.where(
|
||||
'subspace_model_product_allocation_id NOT IN ' +
|
||||
'subspace_model_product_allocation_uuid NOT IN (' +
|
||||
queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.select('uuid')
|
||||
.select('allocation.uuid')
|
||||
.from(SubspaceModelProductAllocationEntity, 'allocation')
|
||||
.getQuery(),
|
||||
.getQuery() +
|
||||
')',
|
||||
)
|
||||
.execute();
|
||||
|
||||
return deletedAllocations;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw this.handleError(error, `Failed to delete tags in subspace model`);
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ export class SpaceProductAllocationService {
|
||||
modifySubspace,
|
||||
),
|
||||
|
||||
this.processDeleteActions(dtos, queryRunner),
|
||||
this.processDeleteActions(dtos, queryRunner, space),
|
||||
]);
|
||||
} catch (error) {
|
||||
throw this.handleError(error, 'Error while updating product allocations');
|
||||
@ -200,6 +200,7 @@ export class SpaceProductAllocationService {
|
||||
private async processDeleteActions(
|
||||
dtos: ModifyTagDto[],
|
||||
queryRunner: QueryRunner,
|
||||
space: SpaceEntity,
|
||||
): Promise<SpaceProductAllocationEntity[]> {
|
||||
try {
|
||||
if (!dtos || dtos.length === 0) {
|
||||
@ -215,7 +216,10 @@ export class SpaceProductAllocationService {
|
||||
const allocationsToUpdate = await queryRunner.manager.find(
|
||||
SpaceProductAllocationEntity,
|
||||
{
|
||||
where: { tags: { uuid: In(tagUuidsToDelete) } },
|
||||
where: {
|
||||
tags: { uuid: In(tagUuidsToDelete) },
|
||||
space: { uuid: space.uuid },
|
||||
},
|
||||
relations: ['tags'],
|
||||
},
|
||||
);
|
||||
|
@ -359,12 +359,13 @@ export class SubspaceProductAllocationService {
|
||||
.delete()
|
||||
.from('subspace_product_tags')
|
||||
.where(
|
||||
'subspace_product_allocation_id NOT IN ' +
|
||||
'subspace_product_allocation_uuid NOT IN ' +
|
||||
queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.select('uuid')
|
||||
.select('allocation.uuid')
|
||||
.from(SubspaceProductAllocationEntity, 'allocation')
|
||||
.getQuery(),
|
||||
.getQuery() +
|
||||
')',
|
||||
)
|
||||
.execute();
|
||||
|
||||
|
Reference in New Issue
Block a user