Harvests, Extractions, HoneyBatches, Storage, Products, Bottling, Equipment: @Roles(...) durch @RequirePermission(...) ersetzt, ungeschuetzte GET-Routen mit :read-Rechten geschlossen. HoneyBatches behaelt die feine Unterscheidung relocate (auch STAFF) vs. create/measurements (nur BEEKEEPER+); Storage bekommt konsequent keine STAFF-Schreibrechte (deckt sich mit dem bisherigen @Roles-Stand). Verifiziert: tsc, lint, volle e2e-Suite 158/159 gruen (1 getrackter Skip). Co-Authored-By: Claude Sonnet 5 <[email protected]>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
import { RequirePermission } from '../auth/decorators/require-permission.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) {}
|
|
|
|
@RequirePermission('extractions:read')
|
|
@Get()
|
|
findAll() {
|
|
return this.extractionsService.findAll();
|
|
}
|
|
|
|
@RequirePermission('extractions:read')
|
|
@Get(':id')
|
|
findOne(@Param('id') id: string) {
|
|
return this.extractionsService.findById(id);
|
|
}
|
|
|
|
@RequirePermission('extractions:create')
|
|
@Post()
|
|
create(
|
|
@Body() dto: CreateExtractionDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.extractionsService.create(dto, actor.id);
|
|
}
|
|
|
|
@RequirePermission('extractions:update')
|
|
@Patch(':id')
|
|
update(
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateExtractionDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.extractionsService.update(id, dto, actor.id);
|
|
}
|
|
}
|