mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 10:44:55 +00:00
fixed delete space
This commit is contained in:
@ -19,7 +19,7 @@ import { SpaceEntity } from '@app/common/modules/space/entities';
|
||||
import { generateRandomString } from '@app/common/helper/randomString';
|
||||
import { SpaceLinkService } from './space-link';
|
||||
import { SubSpaceService } from './subspace';
|
||||
import { DataSource, Not, QueryRunner } from 'typeorm';
|
||||
import { DataSource, QueryRunner } from 'typeorm';
|
||||
import { ValidationService } from './space-validation.service';
|
||||
import {
|
||||
ORPHAN_COMMUNITY_NAME,
|
||||
@ -171,25 +171,28 @@ export class SpaceService {
|
||||
);
|
||||
try {
|
||||
// Get all spaces related to the community, including the parent-child relations
|
||||
const spaces = await this.spaceRepository.find({
|
||||
where: {
|
||||
community: { uuid: communityUuid },
|
||||
spaceName: Not(`${ORPHAN_SPACE_NAME}`),
|
||||
disabled: false,
|
||||
},
|
||||
relations: [
|
||||
'parent',
|
||||
const spaces = await this.spaceRepository
|
||||
.createQueryBuilder('space')
|
||||
.leftJoinAndSelect('space.parent', 'parent')
|
||||
.leftJoinAndSelect(
|
||||
'space.children',
|
||||
'children',
|
||||
'incomingConnections',
|
||||
'tags',
|
||||
'tags.product',
|
||||
'subspaces',
|
||||
'subspaces.tags',
|
||||
'subspaces.tags.product',
|
||||
],
|
||||
});
|
||||
'children.disabled = :disabled',
|
||||
{ disabled: false },
|
||||
)
|
||||
.leftJoinAndSelect('space.incomingConnections', 'incomingConnections')
|
||||
.leftJoinAndSelect('space.tags', 'tags')
|
||||
.leftJoinAndSelect('tags.product', 'tagProduct')
|
||||
.leftJoinAndSelect('space.subspaces', 'subspaces')
|
||||
.leftJoinAndSelect('subspaces.tags', 'subspaceTags')
|
||||
.leftJoinAndSelect('subspaceTags.product', 'subspaceTagProduct')
|
||||
.where('space.community_id = :communityUuid', { communityUuid })
|
||||
.andWhere('space.spaceName != :orphanSpaceName', {
|
||||
orphanSpaceName: ORPHAN_SPACE_NAME,
|
||||
})
|
||||
.andWhere('space.disabled = :disabled', { disabled: false })
|
||||
.getMany();
|
||||
|
||||
// Organize spaces into a hierarchical structure
|
||||
const spaceHierarchy = this.buildSpaceHierarchy(spaces);
|
||||
|
||||
return new SuccessResponseDto({
|
||||
|
||||
Reference in New Issue
Block a user