cleaned space entities

This commit is contained in:
hannathkadher
2024-12-24 08:43:25 +04:00
parent 97b53bf417
commit 1e47fffc0a
12 changed files with 106 additions and 20 deletions

View File

@ -9,7 +9,6 @@ import {
AddSpaceDto,
CommunitySpaceParam,
GetSpaceParam,
ProductAssignmentDto,
UpdateSpaceDto,
} from '../dtos';
import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
@ -37,8 +36,7 @@ export class SpaceService {
addSpaceDto: AddSpaceDto,
params: CommunitySpaceParam,
): Promise<BaseResponseDto> {
const { parentUuid, direction, products, spaceModelUuid, subspaces } =
addSpaceDto;
const { parentUuid, direction, spaceModelUuid, subspaces } = addSpaceDto;
const { communityUuid, projectUuid } = params;
if (addSpaceDto.spaceName === ORPHAN_SPACE_NAME) {
@ -58,7 +56,7 @@ export class SpaceService {
projectUuid,
);
this.validateSpaceCreation(spaceModelUuid, products, subspaces);
this.validateSpaceCreation(spaceModelUuid);
const parent = parentUuid
? await this.validationService.validateSpace(parentUuid)
@ -246,7 +244,7 @@ export class SpaceService {
}
// If a parentId is provided, check if the parent exists
const { parentUuid, products } = updateSpaceDto;
const { parentUuid } = updateSpaceDto;
const parent = parentUuid
? await this.validationService.validateSpace(parentUuid)
: null;
@ -257,8 +255,6 @@ export class SpaceService {
// Save the updated space
await queryRunner.manager.save(space);
if (products && products.length > 0) {
}
await queryRunner.commitTransaction();
return new SuccessResponseDto({
@ -370,12 +366,8 @@ export class SpaceService {
return rootSpaces;
}
private validateSpaceCreation(
spaceModelUuid?: string,
products?: ProductAssignmentDto[],
subSpaces?: CreateSubspaceModelDto[],
) {
if (spaceModelUuid && (products?.length || subSpaces?.length)) {
private validateSpaceCreation(spaceModelUuid?: string) {
if (spaceModelUuid) {
throw new HttpException(
'For space creation choose either space model or products and subspace',
HttpStatus.CONFLICT,