mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-08-26 06:59:39 +00:00
finished return the spaces in get community
This commit is contained in:
@ -14,12 +14,14 @@ import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service
|
||||
import { ProjectRepository } from '@app/common/modules/project/repositiories';
|
||||
import { ORPHAN_COMMUNITY_NAME } from '@app/common/constants/orphan-constant';
|
||||
import { Not } from 'typeorm';
|
||||
import { SpaceService } from 'src/space/services';
|
||||
|
||||
@Injectable()
|
||||
export class CommunityService {
|
||||
constructor(
|
||||
private readonly communityRepository: CommunityRepository,
|
||||
private readonly projectRepository: ProjectRepository,
|
||||
private readonly spaceService: SpaceService,
|
||||
private readonly tuyaService: TuyaService,
|
||||
) {}
|
||||
|
||||
@ -98,6 +100,27 @@ export class CommunityService {
|
||||
const { baseResponseDto, paginationResponseDto } =
|
||||
await customModel.findAll(pageable);
|
||||
|
||||
const communitiesWithSpaces = await Promise.all(
|
||||
baseResponseDto.data.map(async (community: CommunityDto) => {
|
||||
const spaces = await this.spaceService.getSpacesHierarchyForCommunity(
|
||||
{
|
||||
communityUuid: community.uuid,
|
||||
projectUuid: param.projectUuid,
|
||||
},
|
||||
{
|
||||
onlyWithDevices: false,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
...community,
|
||||
spaces: spaces.data,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
baseResponseDto.data = communitiesWithSpaces;
|
||||
|
||||
return new PageResponse<CommunityDto>(
|
||||
baseResponseDto,
|
||||
paginationResponseDto,
|
||||
|
Reference in New Issue
Block a user