import { Body, Controller, Get, Param, Patch, Post, Query, } from '@nestjs/common'; import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { LegacyRole as 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 { CreateBottlingBatchDto } from './dto/create-bottling-batch.dto'; import { UpdateBottlingBatchDto } from './dto/update-bottling-batch.dto'; import { BottlingService } from './bottling.service'; @ApiTags('bottling') @ApiBearerAuth() @Controller('bottling-batches') export class BottlingController { constructor(private readonly bottlingService: BottlingService) {} @Get() findAll(@Query('honeyBatchId') honeyBatchId?: string) { return this.bottlingService.findAll({ honeyBatchId }); } @Get(':id') findOne(@Param('id') id: string) { return this.bottlingService.findById(id); } @Roles(Role.ADMIN, Role.BEEKEEPER) @Post() create( @Body() dto: CreateBottlingBatchDto, @CurrentUser() actor: AuthenticatedUser, ) { return this.bottlingService.create(dto, actor.id); } @Roles(Role.ADMIN, Role.BEEKEEPER) @Patch(':id') update( @Param('id') id: string, @Body() dto: UpdateBottlingBatchDto, @CurrentUser() actor: AuthenticatedUser, ) { return this.bottlingService.update(id, dto, actor.id); } }