import { Body, Controller, Delete, Get, Param, Post, Put, Req, UseGuards, } from '@nestjs/common'; import { KeyService } from './key.service'; import { AuthenticatedRequest } from 'src/model/interface/authenticated-request.interface'; import { AuthGuard } from 'src/core/guards/auth.guard'; import { Key } from 'src/model/entitites'; import { CreateKeySystemDto } from 'src/model/dto/create-key-system.dto'; @UseGuards(AuthGuard) @Controller('key') export class KeyController { constructor(private service: KeyService) {} @Get() getKeys(@Req() req: AuthenticatedRequest) { return this.service.getUsersKeys(req.user); } @Post() postKey(@Req() req: AuthenticatedRequest, @Body() key: Key) { return this.service.createKey(req.user, key); } @Put() updateKey(@Req() req: AuthenticatedRequest, @Body() key: Key) { return this.service.updateKey(req.user, key); } @Put(':id/restore') restoreKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) { return this.service.restoreKey(req.user, id); } @Delete(':id') deleteKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) { return this.service.deleteKey(req.user, id); } @Get('cylinder') getCylinders(@Req() req: AuthenticatedRequest) { return this.service.getUsersCylinders(req.user); } @Post('system') createKeySystem( @Req() req: AuthenticatedRequest, @Body() body: CreateKeySystemDto, ) { return this.service.createKeySystem(req.user, body); } @Post(':id/handover') handoutKey( @Req() req: AuthenticatedRequest, @Body() body: any, @Param('id') id: string, ) { return this.service.handoverKey(req.user, body, id); } @Get(':id/handover') getKeyHandouts(@Req() req: AuthenticatedRequest, @Param('id') id: string) { return this.service.getKeyHandovers(req.user, id); } @Get('Archive') getArchive(@Req() req: AuthenticatedRequest) { return this.service.getDeletedKeys(req.user); } }