mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 20:04:54 +00:00
Add ApiOperation decorators and update route paths in ScheduleController
This commit is contained in:
@ -11,7 +11,7 @@ import {
|
||||
Delete,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
import {
|
||||
AddScheduleDto,
|
||||
EnableScheduleDto,
|
||||
@ -21,17 +21,24 @@ import {
|
||||
|
||||
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
|
||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||
import { ControllerRoute } from '@app/common/constants/controller-route';
|
||||
|
||||
@ApiTags('Schedule Module')
|
||||
@Controller({
|
||||
version: EnableDisableStatusEnum.ENABLED,
|
||||
path: 'schedule',
|
||||
path: ControllerRoute.SCHEDULE.ROUTE,
|
||||
})
|
||||
export class ScheduleController {
|
||||
constructor(private readonly scheduleService: ScheduleService) {}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post(':deviceUuid')
|
||||
@ApiOperation({
|
||||
summary: ControllerRoute.SCHEDULE.ACTIONS.ADD_DEVICE_SCHEDULE_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.SCHEDULE.ACTIONS.ADD_DEVICE_SCHEDULE_DESCRIPTION,
|
||||
})
|
||||
async addDeviceSchedule(
|
||||
@Param('deviceUuid') deviceUuid: string,
|
||||
@Body() addScheduleDto: AddScheduleDto,
|
||||
@ -44,13 +51,21 @@ export class ScheduleController {
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'schedule added successfully',
|
||||
message: 'Schedule added successfully',
|
||||
data: schedule,
|
||||
};
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get(':deviceUuid')
|
||||
@ApiOperation({
|
||||
summary:
|
||||
ControllerRoute.SCHEDULE.ACTIONS.GET_DEVICE_SCHEDULE_BY_CATEGORY_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.SCHEDULE.ACTIONS
|
||||
.GET_DEVICE_SCHEDULE_BY_CATEGORY_DESCRIPTION,
|
||||
})
|
||||
async getDeviceScheduleByCategory(
|
||||
@Param('deviceUuid') deviceUuid: string,
|
||||
@Query() query: GetScheduleDeviceDto,
|
||||
@ -60,9 +75,15 @@ export class ScheduleController {
|
||||
query.category,
|
||||
);
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete(':deviceUuid/:scheduleId')
|
||||
@ApiOperation({
|
||||
summary: ControllerRoute.SCHEDULE.ACTIONS.DELETE_DEVICE_SCHEDULE_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.SCHEDULE.ACTIONS.DELETE_DEVICE_SCHEDULE_DESCRIPTION,
|
||||
})
|
||||
async deleteDeviceSchedule(
|
||||
@Param('deviceUuid') deviceUuid: string,
|
||||
@Param('scheduleId') scheduleId: string,
|
||||
@ -71,12 +92,18 @@ export class ScheduleController {
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'schedule deleted successfully',
|
||||
message: 'Schedule deleted successfully',
|
||||
};
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put('enable/:deviceUuid')
|
||||
@ApiOperation({
|
||||
summary: ControllerRoute.SCHEDULE.ACTIONS.ENABLE_DEVICE_SCHEDULE_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.SCHEDULE.ACTIONS.ENABLE_DEVICE_SCHEDULE_DESCRIPTION,
|
||||
})
|
||||
async enableDeviceSchedule(
|
||||
@Param('deviceUuid') deviceUuid: string,
|
||||
@Body() enableScheduleDto: EnableScheduleDto,
|
||||
@ -88,12 +115,18 @@ export class ScheduleController {
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'schedule updated successfully',
|
||||
message: 'Schedule updated successfully',
|
||||
};
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put(':deviceUuid')
|
||||
@ApiOperation({
|
||||
summary: ControllerRoute.SCHEDULE.ACTIONS.UPDATE_DEVICE_SCHEDULE_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.SCHEDULE.ACTIONS.UPDATE_DEVICE_SCHEDULE_DESCRIPTION,
|
||||
})
|
||||
async updateDeviceSchedule(
|
||||
@Param('deviceUuid') deviceUuid: string,
|
||||
@Body() updateScheduleDto: UpdateScheduleDto,
|
||||
@ -106,7 +139,7 @@ export class ScheduleController {
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'schedule updated successfully',
|
||||
message: 'Schedule updated successfully',
|
||||
data: schedule,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user