filter disable get space models in get query

This commit is contained in:
hannathkadher
2025-01-22 12:03:53 +04:00
parent 414495c7fe
commit 3ee2e66e39

View File

@ -159,8 +159,6 @@ export class SpaceModelService {
queryBuilder,
);
console.log(baseResponseDto);
return new PageResponse<SpaceModelDto>(
baseResponseDto,
paginationResponseDto,
@ -344,35 +342,51 @@ export class SpaceModelService {
try {
await this.validateProject(params.projectUuid);
const spaceModel = await this.validateSpaceModel(params.spaceModelUuid);
return new SuccessResponseDto({
message: 'SpaceModel retrieved successfully',
data: spaceModel,
});
} catch (error) {
throw new HttpException(
`Failed to retrieve space model ${error}`,
`Failed to retrieve space model: ${error.message}`,
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
async validateSpaceModel(uuid: string): Promise<SpaceModelEntity> {
const spaceModel = await this.spaceModelRepository.findOne({
where: {
uuid,
disabled: false,
},
relations: [
const spaceModel = await this.spaceModelRepository
.createQueryBuilder('spaceModel')
.leftJoinAndSelect(
'spaceModel.subspaceModels',
'subspaceModels',
'subspaceModels.disabled = :subspaceDisabled',
{ subspaceDisabled: false },
)
.leftJoinAndSelect(
'spaceModel.tags',
'tags',
'tags.product',
'tags.disabled = :tagsDisabled',
{ tagsDisabled: false },
)
.leftJoinAndSelect('tags.product', 'spaceTagproduct')
.leftJoinAndSelect(
'subspaceModels.tags',
'subspaceModels.tags.product',
],
});
'subspaceModelTags',
'subspaceModelTags.disabled = :subspaceModelTagsDisabled',
{ subspaceModelTagsDisabled: false },
)
.leftJoinAndSelect('subspaceModelTags.product', 'subspaceTagproduct')
.where('spaceModel.disabled = :disabled', { disabled: false })
.where('spaceModel.disabled = :disabled', { disabled: false })
.andWhere('spaceModel.uuid = :uuid', { uuid })
.getOne();
if (!spaceModel) {
throw new HttpException('space model not found', HttpStatus.NOT_FOUND);
}
return spaceModel;
}
}