mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 10:24:53 +00:00
added service to delete space model
This commit is contained in:
@ -1,3 +1,2 @@
|
|||||||
export * from './space-model.service';
|
export * from './space-model.service';
|
||||||
export * from './subspace';
|
export * from './subspace';
|
||||||
export * from './tag-model.service';
|
|
||||||
|
|||||||
@ -311,16 +311,6 @@ export class SpaceModelProductAllocationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getAllocationByTagUuid(
|
|
||||||
tagUuid: string,
|
|
||||||
queryRunner: QueryRunner,
|
|
||||||
): Promise<SpaceModelProductAllocationEntity | null> {
|
|
||||||
return queryRunner.manager.findOne(SpaceModelProductAllocationEntity, {
|
|
||||||
where: { tags: { uuid: tagUuid } },
|
|
||||||
relations: ['tags'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private async validateTagWithinSpaceModel(
|
private async validateTagWithinSpaceModel(
|
||||||
queryRunner: QueryRunner,
|
queryRunner: QueryRunner,
|
||||||
tag: NewTagEntity,
|
tag: NewTagEntity,
|
||||||
@ -351,4 +341,29 @@ export class SpaceModelProductAllocationService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async clearAllAllocations(spaceModelUuid: string, queryRunner: QueryRunner) {
|
||||||
|
try {
|
||||||
|
await queryRunner.manager
|
||||||
|
.createQueryBuilder()
|
||||||
|
.delete()
|
||||||
|
.from(SpaceModelProductAllocationEntity, 'allocation')
|
||||||
|
.relation(SpaceModelProductAllocationEntity, 'tags')
|
||||||
|
.of(
|
||||||
|
await queryRunner.manager.find(SpaceModelProductAllocationEntity, {
|
||||||
|
where: { spaceModel: { uuid: spaceModelUuid } },
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
await queryRunner.manager
|
||||||
|
.createQueryBuilder()
|
||||||
|
.delete()
|
||||||
|
.from(SpaceModelProductAllocationEntity)
|
||||||
|
.where('spaceModelUuid = :spaceModelUuid', { spaceModelUuid })
|
||||||
|
.execute();
|
||||||
|
} catch (error) {
|
||||||
|
throw this.handleError(error, `Failed to clear all allocations`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,7 @@ import { SpaceRepositoryModule } from '@app/common/modules/space/space.repositor
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { SpaceModelController } from './controllers';
|
import { SpaceModelController } from './controllers';
|
||||||
import {
|
import { SpaceModelService, SubSpaceModelService } from './services';
|
||||||
SpaceModelService,
|
|
||||||
SubSpaceModelService,
|
|
||||||
TagModelService,
|
|
||||||
} from './services';
|
|
||||||
import {
|
import {
|
||||||
SpaceModelProductAllocationRepoitory,
|
SpaceModelProductAllocationRepoitory,
|
||||||
SpaceModelRepository,
|
SpaceModelRepository,
|
||||||
@ -64,7 +60,6 @@ const CommandHandlers = [
|
|||||||
SubspaceModelRepository,
|
SubspaceModelRepository,
|
||||||
ProductRepository,
|
ProductRepository,
|
||||||
SubspaceRepository,
|
SubspaceRepository,
|
||||||
TagModelService,
|
|
||||||
TagModelRepository,
|
TagModelRepository,
|
||||||
SubSpaceService,
|
SubSpaceService,
|
||||||
ValidationService,
|
ValidationService,
|
||||||
|
|||||||
Reference in New Issue
Block a user