mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-12 00:12:16 +00:00
added search for spaces
This commit is contained in:
@ -114,6 +114,7 @@ export class CommunityService {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
onlyWithDevices: false,
|
onlyWithDevices: false,
|
||||||
|
search: pageable.search,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -185,10 +185,10 @@ export class SpaceService {
|
|||||||
|
|
||||||
async getSpacesHierarchyForCommunity(
|
async getSpacesHierarchyForCommunity(
|
||||||
params: CommunitySpaceParam,
|
params: CommunitySpaceParam,
|
||||||
getSpaceDto?: GetSpaceDto,
|
getSpaceDto?: GetSpaceDto & { search?: string },
|
||||||
): Promise<BaseResponseDto> {
|
): Promise<BaseResponseDto> {
|
||||||
const { communityUuid, projectUuid } = params;
|
const { communityUuid, projectUuid } = params;
|
||||||
const { onlyWithDevices } = getSpaceDto;
|
const { onlyWithDevices, search } = getSpaceDto;
|
||||||
await this.validationService.validateCommunityAndProject(
|
await this.validationService.validateCommunityAndProject(
|
||||||
communityUuid,
|
communityUuid,
|
||||||
projectUuid,
|
projectUuid,
|
||||||
@ -231,6 +231,13 @@ export class SpaceService {
|
|||||||
})
|
})
|
||||||
.andWhere('space.disabled = :disabled', { disabled: false });
|
.andWhere('space.disabled = :disabled', { disabled: false });
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryBuilder.andWhere(
|
||||||
|
'(space.spaceName ILIKE :search OR parent.spaceName ILIKE :search)',
|
||||||
|
{ search: `%${search}%` },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (onlyWithDevices) {
|
if (onlyWithDevices) {
|
||||||
queryBuilder.innerJoin('space.devices', 'devices');
|
queryBuilder.innerJoin('space.devices', 'devices');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user