Merge pull request #319 from SyncrowIOT/SP-1322

added search for spaces
This commit is contained in:
hannathkadher
2025-03-25 21:55:56 +04:00
committed by GitHub
5 changed files with 37 additions and 7 deletions

View File

@ -188,10 +188,10 @@ export class SpaceService {
async getSpacesHierarchyForCommunity(
params: CommunitySpaceParam,
getSpaceDto?: GetSpaceDto,
getSpaceDto?: GetSpaceDto & { search?: string },
): Promise<BaseResponseDto> {
const { communityUuid, projectUuid } = params;
const { onlyWithDevices } = getSpaceDto;
const { onlyWithDevices, search } = getSpaceDto;
await this.validationService.validateCommunityAndProject(
communityUuid,
projectUuid,
@ -234,6 +234,13 @@ export class SpaceService {
})
.andWhere('space.disabled = :disabled', { disabled: false });
if (search) {
queryBuilder.andWhere(
'(space.spaceName ILIKE :search OR parent.spaceName ILIKE :search)',
{ search: `%${search}%` },
);
}
if (onlyWithDevices) {
queryBuilder.innerJoin('space.devices', 'devices');
}