From 3d3dcf17dd51082d6477de3cb77e63c7f34c61c2 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Fri, 14 Mar 2025 11:38:49 +0400 Subject: [PATCH] moved automation by space to different root --- libs/common/src/constants/controller-route.ts | 16 ++++++--- .../automation-space.controller.ts | 33 +++++++++++++++++++ .../controllers/automation.controller.ts | 16 +-------- 3 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 src/automation/controllers/automation-space.controller.ts diff --git a/libs/common/src/constants/controller-route.ts b/libs/common/src/constants/controller-route.ts index 26bc418..4ced1dc 100644 --- a/libs/common/src/constants/controller-route.ts +++ b/libs/common/src/constants/controller-route.ts @@ -631,11 +631,6 @@ export class ControllerRoute { public static readonly ADD_AUTOMATION_DESCRIPTION = 'This endpoint creates a new automation based on the provided details.'; - public static readonly GET_AUTOMATION_BY_SPACE_SUMMARY = - 'Get automation by space'; - public static readonly GET_AUTOMATION_BY_SPACE_DESCRIPTION = - 'This endpoint retrieves the automations associated with a particular space.'; - public static readonly GET_AUTOMATION_DETAILS_SUMMARY = 'Get automation details'; public static readonly GET_AUTOMATION_DETAILS_DESCRIPTION = @@ -656,6 +651,17 @@ export class ControllerRoute { }; }; + static AUTOMATION_SPACE = class { + public static readonly ROUTE = + '/projects/:projectUuid/communities/:communityUuid/spaces/:spaceUuid/automation'; + static ACTIONS = class { + public static readonly GET_AUTOMATION_BY_SPACE_SUMMARY = + 'Get automation by space'; + public static readonly GET_AUTOMATION_BY_SPACE_DESCRIPTION = + 'This endpoint retrieves the automations associated with a particular space.'; + }; + }; + static DOOR_LOCK = class { public static readonly ROUTE = 'door-lock'; diff --git a/src/automation/controllers/automation-space.controller.ts b/src/automation/controllers/automation-space.controller.ts new file mode 100644 index 0000000..ebf7aa2 --- /dev/null +++ b/src/automation/controllers/automation-space.controller.ts @@ -0,0 +1,33 @@ +import { ControllerRoute } from '@app/common/constants/controller-route'; +import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; +import { Controller, Get, Param, UseGuards } from '@nestjs/common'; +import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger'; +import { AutomationService } from '../services'; +import { Permissions } from 'src/decorators/permissions.decorator'; +import { PermissionsGuard } from 'src/guards/permissions.guard'; +import { GetSpaceParam } from '@app/common/dto/get.space.param'; + +@ApiTags('Automation Module') +@Controller({ + version: EnableDisableStatusEnum.ENABLED, + path: ControllerRoute.AUTOMATION_SPACE.ROUTE, +}) +export class AutomationSpaceController { + constructor(private readonly automationService: AutomationService) {} + + @ApiBearerAuth() + @UseGuards(PermissionsGuard) + @Permissions('AUTOMATION_VIEW') + @Get() + @ApiOperation({ + summary: + ControllerRoute.AUTOMATION_SPACE.ACTIONS.GET_AUTOMATION_BY_SPACE_SUMMARY, + description: + ControllerRoute.AUTOMATION_SPACE.ACTIONS + .GET_AUTOMATION_BY_SPACE_DESCRIPTION, + }) + async getAutomationBySpace(@Param() param: GetSpaceParam) { + const automation = await this.automationService.getAutomationBySpace(param); + return automation; + } +} diff --git a/src/automation/controllers/automation.controller.ts b/src/automation/controllers/automation.controller.ts index a0db1ed..ffe6d12 100644 --- a/src/automation/controllers/automation.controller.ts +++ b/src/automation/controllers/automation.controller.ts @@ -17,7 +17,7 @@ import { UpdateAutomationStatusDto, } from '../dtos/automation.dto'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; -import { AutomationParamDto, SpaceParamDto } from '../dtos'; +import { AutomationParamDto } from '../dtos'; import { ControllerRoute } from '@app/common/constants/controller-route'; import { PermissionsGuard } from 'src/guards/permissions.guard'; import { Permissions } from 'src/decorators/permissions.decorator'; @@ -55,20 +55,6 @@ export class AutomationController { }; } - @ApiBearerAuth() - @UseGuards(PermissionsGuard) - @Permissions('AUTOMATION_VIEW') - @Get(':spaceUuid') - @ApiOperation({ - summary: ControllerRoute.AUTOMATION.ACTIONS.GET_AUTOMATION_BY_SPACE_SUMMARY, - description: - ControllerRoute.AUTOMATION.ACTIONS.GET_AUTOMATION_BY_SPACE_DESCRIPTION, - }) - async getAutomationBySpace(@Param() param: SpaceParamDto) { - const automation = await this.automationService.getAutomationBySpace(param); - return automation; - } - @ApiBearerAuth() @UseGuards(PermissionsGuard) @Permissions('AUTOMATION_VIEW')