import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'; import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { Role } from '../../generated/prisma'; import { Roles } from '../auth/decorators/roles.decorator'; import { CurrentUser } from '../auth/decorators/current-user.decorator'; import type { AuthenticatedUser } from '../auth/types/authenticated-user'; import { CreateExtractionDto } from './dto/create-extraction.dto'; import { UpdateExtractionDto } from './dto/update-extraction.dto'; import { ExtractionsService } from './extractions.service'; @ApiTags('extractions') @ApiBearerAuth() @Controller('extractions') export class ExtractionsController { constructor(private readonly extractionsService: ExtractionsService) {} @Get() findAll() { return this.extractionsService.findAll(); } @Get(':id') findOne(@Param('id') id: string) { return this.extractionsService.findById(id); } @Roles(Role.ADMIN, Role.BEEKEEPER) @Post() create( @Body() dto: CreateExtractionDto, @CurrentUser() actor: AuthenticatedUser, ) { return this.extractionsService.create(dto, actor.id); } @Roles(Role.ADMIN, Role.BEEKEEPER) @Patch(':id') update( @Param('id') id: string, @Body() dto: UpdateExtractionDto, @CurrentUser() actor: AuthenticatedUser, ) { return this.extractionsService.update(id, dto, actor.id); } }