feat(backend): Koeniginnenbewertung (Modul 31)
QueenEvaluation-Modell (Volksstaerke, Sanftmut, Wabensitz, Schwarm- trieb, Brutbild, Honigertrag je Skala 1-5) als Sub-Ressource der Queens-API: GET/POST /queens/:id/evaluations. Vorgezogen vor Modul 27 (Statistik), da dessen Koeniginnen-Auswertungen auf diesen Daten aufbauen.
This commit is contained in:
1 parent
0fc13952fb
commit
50268fa591
8 files changed
+245
-1
No files matched your search
@@ -5,6 +5,7 @@ import { Queen, QueenStatus } from '../../generated/prisma';
|
||||
import { CreateQueenDto } from './dto/create-queen.dto';
|
||||
import { UpdateQueenDto } from './dto/update-queen.dto';
|
||||
import { AssignColonyDto } from './dto/assign-colony.dto';
|
||||
import { CreateQueenEvaluationDto } from './dto/create-queen-evaluation.dto';
|
||||
|
||||
export interface QueenFilter {
|
||||
status?: QueenStatus;
|
||||
@@ -126,4 +127,43 @@ export class QueensService {
|
||||
orderBy: { startDate: 'desc' },
|
||||
});
|
||||
}
|
||||
|
||||
async getEvaluations(id: string) {
|
||||
await this.findById(id);
|
||||
return this.prisma.queenEvaluation.findMany({
|
||||
where: { queenId: id },
|
||||
orderBy: { date: 'desc' },
|
||||
});
|
||||
}
|
||||
|
||||
async addEvaluation(
|
||||
id: string,
|
||||
dto: CreateQueenEvaluationDto,
|
||||
actingUserId: string,
|
||||
) {
|
||||
await this.findById(id);
|
||||
const evaluation = await this.prisma.queenEvaluation.create({
|
||||
data: {
|
||||
queenId: id,
|
||||
colonyId: dto.colonyId,
|
||||
date: new Date(dto.date),
|
||||
colonyStrength: dto.colonyStrength,
|
||||
gentleness: dto.gentleness,
|
||||
combBuild: dto.combBuild,
|
||||
swarmingTendency: dto.swarmingTendency,
|
||||
broodPattern: dto.broodPattern,
|
||||
honeyYield: dto.honeyYield,
|
||||
notes: dto.notes,
|
||||
userId: actingUserId,
|
||||
},
|
||||
});
|
||||
await this.auditLog.record({
|
||||
entityType: 'QueenEvaluation',
|
||||
entityId: evaluation.id,
|
||||
action: 'CREATE',
|
||||
userId: actingUserId,
|
||||
afterData: evaluation,
|
||||
});
|
||||
return evaluation;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user