Varroa, SwarmControl, Treatments, Feedings (+ jeweilige Colony-Sub-Controller): @Roles(...) durch @RequirePermission(...) ersetzt, ungeschuetzte GET-Routen mit :read-Rechten geschlossen. Verifiziert: tsc, lint, e2e (varroa/swarm-control/treatments/feedings einzeln gruen; volle 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 { CreateVarroaMeasurementDto } from './dto/create-varroa-measurement.dto';
|
|
import { UpdateVarroaMeasurementDto } from './dto/update-varroa-measurement.dto';
|
|
import { VarroaService } from './varroa.service';
|
|
|
|
@ApiTags('varroa-measurements')
|
|
@ApiBearerAuth()
|
|
@Controller('varroa-measurements')
|
|
export class VarroaController {
|
|
constructor(private readonly varroaService: VarroaService) {}
|
|
|
|
@RequirePermission('varroa:read')
|
|
@Get()
|
|
findAll() {
|
|
return this.varroaService.findAll();
|
|
}
|
|
|
|
@RequirePermission('varroa:read')
|
|
@Get(':id')
|
|
findOne(@Param('id') id: string) {
|
|
return this.varroaService.findById(id);
|
|
}
|
|
|
|
@RequirePermission('varroa:create')
|
|
@Post()
|
|
create(
|
|
@Body() dto: CreateVarroaMeasurementDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.varroaService.create(dto, actor.id);
|
|
}
|
|
|
|
@RequirePermission('varroa:update')
|
|
@Patch(':id')
|
|
update(
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateVarroaMeasurementDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.varroaService.update(id, dto, actor.id);
|
|
}
|
|
}
|