mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:54:54 +00:00
feat: add DEVICE_SPACE_COMMUNITY route and controller for device retrieval by space or community
This commit is contained in:
52
src/device/controllers/device-space-community.controller.ts
Normal file
52
src/device/controllers/device-space-community.controller.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import { DeviceService } from '../services/device.service';
|
||||
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
ApiQuery,
|
||||
} from '@nestjs/swagger';
|
||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||
import { ControllerRoute } from '@app/common/constants/controller-route';
|
||||
import { PermissionsGuard } from 'src/guards/permissions.guard';
|
||||
import { Permissions } from 'src/decorators/permissions.decorator';
|
||||
import { GetDevicesBySpaceOrCommunityDto } from '../dtos';
|
||||
|
||||
@ApiTags('Device Module')
|
||||
@Controller({
|
||||
version: EnableDisableStatusEnum.ENABLED,
|
||||
path: ControllerRoute.DEVICE_SPACE_COMMUNITY.ROUTE,
|
||||
})
|
||||
export class DeviceSpaceOrCommunityController {
|
||||
constructor(private readonly deviceService: DeviceService) {}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Permissions('DEVICE_VIEW')
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
summary:
|
||||
ControllerRoute.DEVICE_SPACE_COMMUNITY.ACTIONS
|
||||
.GET_ALL_DEVICES_BY_SPACE_OR_COMMUNITY_WITH_RECURSIVE_CHILD_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.DEVICE_SPACE_COMMUNITY.ACTIONS
|
||||
.GET_ALL_DEVICES_BY_SPACE_OR_COMMUNITY_WITH_RECURSIVE_CHILD_DESCRIPTION,
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'spaceUuid',
|
||||
description: 'UUID of the Space',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'communityUuid',
|
||||
description: 'UUID of the Community',
|
||||
required: false,
|
||||
})
|
||||
async getAllDevicesBySpaceOrCommunityWithChild(
|
||||
@Query() query: GetDevicesBySpaceOrCommunityDto,
|
||||
) {
|
||||
return await this.deviceService.getAllDevicesBySpaceOrCommunityWithChild(
|
||||
query,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user