mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
filter disable get space models in get query
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user