added search for spaces

This commit is contained in:
hannathkadher
2025-03-19 10:51:38 +04:00
parent 30badcde67
commit b0a403b0cf
2 changed files with 10 additions and 2 deletions

View File

@ -114,6 +114,7 @@ export class CommunityService {
},
{
onlyWithDevices: false,
search: pageable.search,
},
);

View File

@ -185,10 +185,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,
@ -231,6 +231,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');
}