mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:54:54 +00:00
cleaned space entities
This commit is contained in:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user