mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
get space model by id
This commit is contained in:
@ -292,6 +292,10 @@ export class ControllerRoute {
|
|||||||
public static readonly CREATE_SPACE_MODEL_DESCRIPTION =
|
public static readonly CREATE_SPACE_MODEL_DESCRIPTION =
|
||||||
'This endpoint allows you to create a new space model within a specified project. A space model defines the structure of spaces, including subspaces, products, and product items, and is uniquely identifiable within the project.';
|
'This endpoint allows you to create a new space model within a specified project. A space model defines the structure of spaces, including subspaces, products, and product items, and is uniquely identifiable within the project.';
|
||||||
|
|
||||||
|
public static readonly GET_SPACE_MODEL_SUMMARY = 'Get a New Space Model';
|
||||||
|
public static readonly GET_SPACE_MODEL_DESCRIPTION =
|
||||||
|
'Fetch a space model details';
|
||||||
|
|
||||||
public static readonly LIST_SPACE_MODEL_SUMMARY = 'List Space Models';
|
public static readonly LIST_SPACE_MODEL_SUMMARY = 'List Space Models';
|
||||||
public static readonly LIST_SPACE_MODEL_DESCRIPTION =
|
public static readonly LIST_SPACE_MODEL_DESCRIPTION =
|
||||||
'This endpoint allows you to retrieve a list of space models within a specified project. Each space model includes its structure, associated subspaces, products, and product items.';
|
'This endpoint allows you to retrieve a list of space models within a specified project. Each space model includes its structure, associated subspaces, products, and product items.';
|
||||||
|
@ -66,6 +66,19 @@ export class SpaceModelController {
|
|||||||
return await this.spaceModelService.list(projectParam, query);
|
return await this.spaceModelService.list(projectParam, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(PermissionsGuard)
|
||||||
|
@Permissions('SPACE_MODEL_VIEW')
|
||||||
|
@ApiOperation({
|
||||||
|
summary: ControllerRoute.SPACE_MODEL.ACTIONS.LIST_SPACE_MODEL_SUMMARY,
|
||||||
|
description:
|
||||||
|
ControllerRoute.SPACE_MODEL.ACTIONS.LIST_SPACE_MODEL_DESCRIPTION,
|
||||||
|
})
|
||||||
|
@Get(':spaceModelUuid')
|
||||||
|
async get(@Param() param: SpaceModelParam): Promise<BaseResponseDto> {
|
||||||
|
return await this.spaceModelService.findOne(param);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@UseGuards(PermissionsGuard)
|
@UseGuards(PermissionsGuard)
|
||||||
@Permissions('SPACE_MODEL_UPDATE')
|
@Permissions('SPACE_MODEL_UPDATE')
|
||||||
|
@ -323,6 +323,22 @@ export class SpaceModelService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findOne(params: SpaceModelParam): Promise<BaseResponseDto> {
|
||||||
|
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}`,
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async validateSpaceModel(uuid: string): Promise<SpaceModelEntity> {
|
async validateSpaceModel(uuid: string): Promise<SpaceModelEntity> {
|
||||||
const spaceModel = await this.spaceModelRepository.findOne({
|
const spaceModel = await this.spaceModelRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
Reference in New Issue
Block a user