mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:54:54 +00:00
add overwrite when update spaces with spacesModel
This commit is contained in:
@ -449,6 +449,9 @@ export class SpaceService {
|
||||
try {
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
const project = await this.spaceModelService.validateProject(
|
||||
params.projectUuid,
|
||||
);
|
||||
|
||||
const space =
|
||||
await this.validationService.validateSpaceWithinCommunityAndProject(
|
||||
@ -483,9 +486,15 @@ export class SpaceService {
|
||||
queryRunner,
|
||||
);
|
||||
} else if (hasDependencies) {
|
||||
throw new HttpException(
|
||||
`Space cannot be linked to a model because it has existing dependencies (devices, subspaces, or product allocations).`,
|
||||
HttpStatus.BAD_REQUEST,
|
||||
await this.spaceModelService.overwriteSpace(
|
||||
space,
|
||||
project,
|
||||
queryRunner,
|
||||
);
|
||||
await this.spaceModelService.linkToSpace(
|
||||
space,
|
||||
spaceModel,
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user