feat(backend): Suche und Filter (Modul 14)

SearchModule mit GET /search?q= über Bienenstände, Völker,
Königinnen, Aufgaben und Honigchargen. Kombinierbare Filter
(Status, Standort, Bienenstand) in den bestehenden List-Endpunkten.
This commit is contained in:
Nick Szaunig committed 2026-08-22 05:29:47 +02:00
1 parent 55b9bc2587
commit 146b56d683
15 files changed
+337 -27

No files matched your search

@@ -1,6 +1,6 @@
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { Role } from '../../generated/prisma';
import { HoneyBatchStatus, 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';
@@ -15,8 +15,8 @@ export class HoneyBatchesController {
constructor(private readonly honeyBatchesService: HoneyBatchesService) {}
@Get()
findAll() {
return this.honeyBatchesService.findAll();
findAll(@Query('status') status?: HoneyBatchStatus) {
return this.honeyBatchesService.findAll({ status });
}
@Get(':id')
@@ -1,6 +1,7 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { AuditLogService } from '../audit/audit-log.service';
import { HoneyBatchStatus } from '../../generated/prisma';
import { CreateHoneyBatchDto } from './dto/create-honey-batch.dto';
import { CreateHoneyMeasurementDto } from './dto/create-honey-measurement.dto';
@@ -17,6 +18,10 @@ const honeyBatchInclude = {
},
} as const;
export interface HoneyBatchFilter {
status?: HoneyBatchStatus;
}
@Injectable()
export class HoneyBatchesService {
constructor(
@@ -24,8 +29,9 @@ export class HoneyBatchesService {
private readonly auditLog: AuditLogService,
) {}
async findAll() {
async findAll(filter: HoneyBatchFilter = {}) {
return this.prisma.honeyBatch.findMany({
where: { status: filter.status },
include: honeyBatchInclude,
orderBy: { createdAt: 'desc' },
});