add where for community name

This commit is contained in:
hannathkadher
2025-03-18 21:20:27 +04:00
parent ec851eda9d
commit 30badcde67
4 changed files with 27 additions and 5 deletions

View File

@ -3,8 +3,8 @@ import { AddCommunityDto, GetCommunityParams, ProjectParam } from '../dtos';
import { UpdateCommunityNameDto } from '../dtos/update.community.dto';
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
import {
ExtendedTypeORMCustomModelFindAllQuery,
TypeORMCustomModel,
TypeORMCustomModelFindAllQuery,
} from '@app/common/models/typeOrmCustom.model';
import { PageResponse } from '@app/common/dto/pagination.response.dto';
import { CommunityRepository } from '@app/common/modules/community/repositories';
@ -13,7 +13,7 @@ import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
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 { ILike, Not } from 'typeorm';
import { SpaceService } from 'src/space/services';
@Injectable()
@ -84,7 +84,7 @@ export class CommunityService {
async getCommunities(
param: ProjectParam,
pageable: Partial<TypeORMCustomModelFindAllQuery>,
pageable: Partial<ExtendedTypeORMCustomModelFindAllQuery>,
): Promise<BaseResponseDto> {
try {
const project = await this.validateProject(param.projectUuid);
@ -95,6 +95,9 @@ export class CommunityService {
name: Not(`${ORPHAN_COMMUNITY_NAME}-${project.name}`),
};
if (pageable.search) {
pageable.where = { name: ILike(`%${pageable.search}%`) };
}
const customModel = TypeORMCustomModel(this.communityRepository);
const { baseResponseDto, paginationResponseDto } =