mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 18:05:48 +00:00
fix: power clamp historical API (#408)
This commit is contained in:
@ -501,12 +501,15 @@ export class ControllerRoute {
|
|||||||
};
|
};
|
||||||
static PowerClamp = class {
|
static PowerClamp = class {
|
||||||
public static readonly ROUTE = 'power-clamp';
|
public static readonly ROUTE = 'power-clamp';
|
||||||
|
|
||||||
static ACTIONS = class {
|
static ACTIONS = class {
|
||||||
public static readonly GET_ENERGY_SUMMARY =
|
public static readonly GET_ENERGY_SUMMARY =
|
||||||
'Get power clamp historical data';
|
'Get power clamp historical data';
|
||||||
public static readonly GET_ENERGY_DESCRIPTION =
|
public static readonly GET_ENERGY_DESCRIPTION =
|
||||||
'This endpoint retrieves the historical data of a power clamp device based on the provided parameters.';
|
'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.';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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 { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ApiTags,
|
|
||||||
ApiBearerAuth,
|
ApiBearerAuth,
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
ApiParam,
|
ApiParam,
|
||||||
|
ApiQuery,
|
||||||
|
ApiTags,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
import {
|
||||||
import { ControllerRoute } from '@app/common/constants/controller-route';
|
GetPowerClampBySpaceDto,
|
||||||
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
|
GetPowerClampDto,
|
||||||
|
} from '../dto/get-power-clamp.dto';
|
||||||
|
import {
|
||||||
|
PowerClampParamsDto,
|
||||||
|
ResourceParamsDto,
|
||||||
|
} from '../dto/power-clamp-params.dto';
|
||||||
import { PowerClampService } from '../services/power-clamp.service';
|
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')
|
@ApiTags('Power Clamp Module')
|
||||||
@Controller({
|
@Controller({
|
||||||
version: EnableDisableStatusEnum.ENABLED,
|
version: EnableDisableStatusEnum.ENABLED,
|
||||||
@ -20,7 +26,6 @@ import { PowerClampParamsDto } from '../dto/power-clamp-params.dto';
|
|||||||
})
|
})
|
||||||
export class PowerClampController {
|
export class PowerClampController {
|
||||||
constructor(private readonly powerClampService: PowerClampService) {}
|
constructor(private readonly powerClampService: PowerClampService) {}
|
||||||
|
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Get(':powerClampUuid/historical')
|
@Get(':powerClampUuid/historical')
|
||||||
@ -39,4 +44,34 @@ export class PowerClampController {
|
|||||||
): Promise<BaseResponseDto> {
|
): Promise<BaseResponseDto> {
|
||||||
return await this.powerClampService.getPowerClampData(params, query);
|
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<BaseResponseDto> {
|
||||||
|
return await this.powerClampService.getPowerClampDataBySpaceOrCommunity(
|
||||||
|
params,
|
||||||
|
query,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user