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