fixed deleting subspace

This commit is contained in:
hannathkadher
2025-01-30 21:52:59 +04:00
parent 11faa52283
commit f77d52b6be
2 changed files with 12 additions and 7 deletions

View File

@ -211,6 +211,7 @@ export class SpaceModelService {
); );
if (dto.subspaceModels) { if (dto.subspaceModels) {
console.log(JSON.stringify(modifiedSubspaces));
modifiedSubspaceModels = modifiedSubspaceModels =
await this.subSpaceModelService.modifySubSpaceModels( await this.subSpaceModelService.modifySubSpaceModels(
modifiedSubspaces, modifiedSubspaces,

View File

@ -243,15 +243,19 @@ export class SubSpaceModelService {
); );
if (subspaceModel.tags?.length) { if (subspaceModel.tags?.length) {
const modifyTagDtos = subspaceModel.tags.map((tag) => ({ const modifyTagDtos: CreateTagModelDto[] = subspaceModel.tags.map(
uuid: tag.uuid, (tag) => ({
action: ModifyAction.DELETE, uuid: tag.uuid,
})); action: ModifyAction.ADD,
await this.tagModelService.modifyTags( tag: tag.tag,
productUuid: tag.product.uuid,
}),
);
await this.tagModelService.moveTags(
modifyTagDtos, modifyTagDtos,
queryRunner, queryRunner,
subspaceModel.spaceModel,
null, null,
subspaceModel,
); );
} }
} }
@ -259,7 +263,7 @@ export class SubSpaceModelService {
private async findOne(subspaceUuid: string): Promise<SubspaceModelEntity> { private async findOne(subspaceUuid: string): Promise<SubspaceModelEntity> {
const subspace = await this.subspaceModelRepository.findOne({ const subspace = await this.subspaceModelRepository.findOne({
where: { uuid: subspaceUuid, disabled: false }, where: { uuid: subspaceUuid, disabled: false },
relations: ['tags', 'spaceModel'], relations: ['tags', 'spaceModel', 'tags.product'],
}); });
if (!subspace) { if (!subspace) {
throw new HttpException( throw new HttpException(