HoneyBatchesModule inkl. Honigmessungen und Rückverfolgbarkeits-Endpunkt, der eine Charge über die Schleuderung und Ernte bis zu den Ursprungsvölkern zurückverfolgt.
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { Body, Controller, Get, Param, 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 { CreateHoneyBatchDto } from './dto/create-honey-batch.dto';
|
|
import { CreateHoneyMeasurementDto } from './dto/create-honey-measurement.dto';
|
|
import { HoneyBatchesService } from './honey-batches.service';
|
|
|
|
@ApiTags('honey-batches')
|
|
@ApiBearerAuth()
|
|
@Controller('honey-batches')
|
|
export class HoneyBatchesController {
|
|
constructor(private readonly honeyBatchesService: HoneyBatchesService) {}
|
|
|
|
@Get()
|
|
findAll() {
|
|
return this.honeyBatchesService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
findOne(@Param('id') id: string) {
|
|
return this.honeyBatchesService.findById(id);
|
|
}
|
|
|
|
@Get(':id/traceability')
|
|
traceability(@Param('id') id: string) {
|
|
return this.honeyBatchesService.traceability(id);
|
|
}
|
|
|
|
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
|
@Post()
|
|
create(
|
|
@Body() dto: CreateHoneyBatchDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.honeyBatchesService.create(dto, actor.id);
|
|
}
|
|
|
|
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
|
@Post(':id/measurements')
|
|
addMeasurement(
|
|
@Param('id') id: string,
|
|
@Body() dto: CreateHoneyMeasurementDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.honeyBatchesService.addMeasurement(id, dto, actor.id);
|
|
}
|
|
}
|