diff --git a/libs/common/src/constants/controller-route.ts b/libs/common/src/constants/controller-route.ts index 14aa4f5..59049b3 100644 --- a/libs/common/src/constants/controller-route.ts +++ b/libs/common/src/constants/controller-route.ts @@ -501,12 +501,15 @@ export class ControllerRoute { }; static PowerClamp = class { public static readonly ROUTE = 'power-clamp'; - static ACTIONS = class { public static readonly GET_ENERGY_SUMMARY = 'Get power clamp historical data'; public static readonly GET_ENERGY_DESCRIPTION = 'This endpoint retrieves the historical data of a power clamp device based on the provided parameters.'; + public static readonly GET_ENERGY_BY_COMMUNITY_OR_SPACE_SUMMARY = + 'Get power clamp historical data by community or space'; + public static readonly GET_ENERGY_BY_COMMUNITY_OR_SPACE_DESCRIPTION = + 'This endpoint retrieves the historical data of power clamp devices based on the provided community or space UUID.'; }; }; diff --git a/src/power-clamp/controllers/power-clamp.controller.ts b/src/power-clamp/controllers/power-clamp.controller.ts index ca7b664..0cbb6fd 100644 --- a/src/power-clamp/controllers/power-clamp.controller.ts +++ b/src/power-clamp/controllers/power-clamp.controller.ts @@ -1,18 +1,24 @@ +import { ControllerRoute } from '@app/common/constants/controller-route'; +import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; +import { BaseResponseDto } from '@app/common/dto/base.response.dto'; +import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common'; import { - ApiTags, ApiBearerAuth, ApiOperation, ApiParam, + ApiQuery, + ApiTags, } from '@nestjs/swagger'; -import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; -import { ControllerRoute } from '@app/common/constants/controller-route'; -import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; +import { + GetPowerClampBySpaceDto, + GetPowerClampDto, +} from '../dto/get-power-clamp.dto'; +import { + PowerClampParamsDto, + ResourceParamsDto, +} from '../dto/power-clamp-params.dto'; import { PowerClampService } from '../services/power-clamp.service'; -import { GetPowerClampDto } from '../dto/get-power-clamp.dto'; -import { BaseResponseDto } from '@app/common/dto/base.response.dto'; -import { PowerClampParamsDto } from '../dto/power-clamp-params.dto'; - @ApiTags('Power Clamp Module') @Controller({ version: EnableDisableStatusEnum.ENABLED, @@ -20,7 +26,6 @@ import { PowerClampParamsDto } from '../dto/power-clamp-params.dto'; }) export class PowerClampController { constructor(private readonly powerClampService: PowerClampService) {} - @ApiBearerAuth() @UseGuards(JwtAuthGuard) @Get(':powerClampUuid/historical') @@ -39,4 +44,34 @@ export class PowerClampController { ): Promise { return await this.powerClampService.getPowerClampData(params, query); } + @ApiBearerAuth() + @UseGuards(JwtAuthGuard) + @Get('historical') + @ApiOperation({ + summary: + ControllerRoute.PowerClamp.ACTIONS + .GET_ENERGY_BY_COMMUNITY_OR_SPACE_SUMMARY, + description: + ControllerRoute.PowerClamp.ACTIONS + .GET_ENERGY_BY_COMMUNITY_OR_SPACE_DESCRIPTION, + }) + @ApiQuery({ + name: 'spaceUuid', + description: 'UUID of the Space', + required: false, + }) + @ApiQuery({ + name: 'communityUuid', + description: 'UUID of the Community', + required: false, + }) + async getPowerClampDataBySpaceOrCommunity( + @Query() params: ResourceParamsDto, + @Query() query: GetPowerClampBySpaceDto, + ): Promise { + return await this.powerClampService.getPowerClampDataBySpaceOrCommunity( + params, + query, + ); + } }