Add Device Logs Retrieval Endpoint and Service

This commit is contained in:
faris Aljohari
2024-08-26 14:41:02 +03:00
parent 176c2af877
commit 807dc84501
4 changed files with 90 additions and 4 deletions
+20 -1
View File
@@ -14,7 +14,10 @@ import {
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { AddDeviceDto, UpdateDeviceInRoomDto } from '../dtos/add.device.dto';
import { GetDeviceByRoomUuidDto } from '../dtos/get.device.dto';
import {
GetDeviceByRoomUuidDto,
GetDeviceLogsDto,
} from '../dtos/get.device.dto';
import { ControlDeviceDto } from '../dtos/control.device.dto';
import { CheckRoomGuard } from 'src/guards/room.guard';
import { CheckUserHavePermission } from 'src/guards/user.device.permission.guard';
@@ -236,4 +239,20 @@ export class DeviceController {
);
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get('report-logs/:deviceUuid')
async getBuildingChildByUuid(
@Param('deviceUuid') deviceUuid: string,
@Query() query: GetDeviceLogsDto,
) {
try {
return await this.deviceService.getDeviceLogs(deviceUuid, query);
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
}