finished devices batch control endpoint

This commit is contained in:
faris Aljohari
2024-09-09 15:32:51 +03:00
parent 336d8baf60
commit 1fc04b5c78
3 changed files with 126 additions and 3 deletions

View File

@ -18,7 +18,10 @@ import {
GetDeviceByRoomUuidDto,
GetDeviceLogsDto,
} from '../dtos/get.device.dto';
import { ControlDeviceDto } from '../dtos/control.device.dto';
import {
ControlDeviceDto,
BatchControlDevicesDto,
} from '../dtos/control.device.dto';
import { CheckRoomGuard } from 'src/guards/room.guard';
import { CheckUserHavePermission } from 'src/guards/user.device.permission.guard';
import { CheckUserHaveControllablePermission } from 'src/guards/user.device.controllable.permission.guard';
@ -255,4 +258,21 @@ export class DeviceController {
);
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Post('control/batch')
async batchControlDevices(
@Body() batchControlDevicesDto: BatchControlDevicesDto,
) {
try {
return await this.deviceService.batchControlDevices(
batchControlDevicesDto,
);
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
}