mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 23:47:56 +00:00
finished update schedule endpoint
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
AddScheduleDto,
|
||||
EnableScheduleDto,
|
||||
GetScheduleDeviceDto,
|
||||
UpdateScheduleDto,
|
||||
} from '../dtos/schedule.dto';
|
||||
|
||||
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
|
||||
@@ -36,7 +37,7 @@ export class ScheduleController {
|
||||
@Body() addScheduleDto: AddScheduleDto,
|
||||
) {
|
||||
try {
|
||||
const device = await this.scheduleService.addDeviceSchedule(
|
||||
const schedule = await this.scheduleService.addDeviceSchedule(
|
||||
deviceUuid,
|
||||
addScheduleDto,
|
||||
);
|
||||
@@ -45,7 +46,7 @@ export class ScheduleController {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'schedule added successfully',
|
||||
data: device,
|
||||
data: schedule,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
@@ -118,4 +119,30 @@ export class ScheduleController {
|
||||
);
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put(':deviceUuid')
|
||||
async updateDeviceSchedule(
|
||||
@Param('deviceUuid') deviceUuid: string,
|
||||
@Body() updateScheduleDto: UpdateScheduleDto,
|
||||
) {
|
||||
try {
|
||||
const schedule = await this.scheduleService.updateDeviceSchedule(
|
||||
deviceUuid,
|
||||
updateScheduleDto,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'schedule updated successfully',
|
||||
data: schedule,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user