Add endpoints and logic for fetching power clamp data by community or space

- Introduced new API endpoints to retrieve power clamp historical data based on community or space UUID.
- Updated PowerClampController to handle requests with optional parameters for community and space.
- Enhanced PowerClampService to validate input and fetch devices accordingly.
- Created ResourceParamsDto to manage request parameters.
- Updated ControllerRoute with new action summaries and descriptions.
This commit is contained in:
faris Aljohari
2025-05-07 23:09:01 +03:00
parent 5ed59e4fcc
commit 45b8cdcaae
5 changed files with 156 additions and 31 deletions

View File

@ -4,6 +4,7 @@ import {
ApiBearerAuth,
ApiOperation,
ApiParam,
ApiQuery,
} from '@nestjs/swagger';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ -16,7 +17,7 @@ import {
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
import {
PowerClampParamsDto,
SpaceParamsDto,
ResourceParamsDto,
} from '../dto/power-clamp-params.dto';
@ApiTags('Power Clamp Module')
@ -47,20 +48,32 @@ export class PowerClampController {
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get('historical/space/:spaceUuid')
@Get('historical')
@ApiOperation({
summary: ControllerRoute.PowerClamp.ACTIONS.GET_ENERGY_SUMMARY,
description: ControllerRoute.PowerClamp.ACTIONS.GET_ENERGY_DESCRIPTION,
summary:
ControllerRoute.PowerClamp.ACTIONS
.GET_ENERGY_BY_COMMUNITY_OR_SPACE_SUMMARY,
description:
ControllerRoute.PowerClamp.ACTIONS
.GET_ENERGY_BY_COMMUNITY_OR_SPACE_DESCRIPTION,
})
@ApiParam({
@ApiQuery({
name: 'spaceUuid',
description: 'UUID of the Space',
required: true,
required: false,
})
async getPowerClampBySpaceData(
@Param() params: SpaceParamsDto,
@ApiQuery({
name: 'communityUuid',
description: 'UUID of the Community',
required: false,
})
async getPowerClampDataBySpaceOrCommunity(
@Query() params: ResourceParamsDto,
@Query() query: GetPowerClampBySpaceDto,
): Promise<BaseResponseDto> {
return await this.powerClampService.getPowerClampBySpaceData(params, query);
return await this.powerClampService.getPowerClampDataBySpaceOrCommunity(
params,
query,
);
}
}