- Treatments book their dose from a medicine lot (delta booking on edit, bulk all-or-nothing, idempotent); Bestandsbuch columns from the lot, FEHLT exactly where treatmentLogGaps reports a gap; Bestandsbuch export needs veterinary-medicines:read. - Label printing: 409 LABEL_PARTICULARS_MISSING on gaps, proof print with watermark, PRINT audit before the PDF, check endpoints; digit rules only from the seeded ComplianceSettings row (fail closed). - Restricted zone (Berlin day): create, update, move, merge and CSV import blocked inside an active restriction; override with reason and compliance:manage, audited, never stored on the colony; split, harvest and dissolve stay free; restriction details only with compliance:read. - Authority notices: settings, herd snapshot, registration/herd change/TSK notices with one open draft per kind under the settings lock. - Label check refinements (geometric reading order, number|unit pairs). - ARCHITECTURE.md §12.6–12.8, Annahmen 71–77; spec §5.6 Berlin day. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
83 lines
2.5 KiB
TypeScript
83 lines
2.5 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
|
import { PermissionResolverService } from '../auth/permissions/permission-resolver.service';
|
|
import { Idempotent } from '../common/idempotency/idempotent.decorator';
|
|
import { ApiaryRestrictionsService } from './apiary-restrictions.service';
|
|
import { CreateApiaryRestrictionDto } from './dto/create-apiary-restriction.dto';
|
|
import { RestrictionListQuery } from './dto/restriction-list-query.dto';
|
|
import { UpdateApiaryRestrictionDto } from './dto/update-apiary-restriction.dto';
|
|
|
|
// Full paths on an empty prefix: the list lives under /apiary-restrictions,
|
|
// the per-apiary read under /apiaries/:id/restrictions.
|
|
@ApiTags('apiary-restrictions')
|
|
@ApiBearerAuth()
|
|
@Controller()
|
|
export class ApiaryRestrictionsController {
|
|
constructor(
|
|
private readonly restrictions: ApiaryRestrictionsService,
|
|
private readonly permissions: PermissionResolverService,
|
|
) {}
|
|
|
|
// Authority, file reference and notes are for compliance:read only.
|
|
private async mayReadDetails(actor: AuthenticatedUser): Promise<boolean> {
|
|
return (await this.permissions.getPermissions(actor.id)).has(
|
|
'compliance:read',
|
|
);
|
|
}
|
|
|
|
@RequirePermission('apiaries:read')
|
|
@Get('apiary-restrictions')
|
|
async findAll(
|
|
@Query() query: RestrictionListQuery,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.restrictions.list(
|
|
query.active,
|
|
await this.mayReadDetails(actor),
|
|
);
|
|
}
|
|
|
|
@RequirePermission('apiaries:read')
|
|
@Get('apiaries/:id/restrictions')
|
|
async findForApiary(
|
|
@Param('id') id: string,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.restrictions.findForApiary(
|
|
id,
|
|
await this.mayReadDetails(actor),
|
|
);
|
|
}
|
|
|
|
@RequirePermission('compliance:manage')
|
|
@Idempotent()
|
|
@Post('apiary-restrictions')
|
|
create(
|
|
@Body() dto: CreateApiaryRestrictionDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.restrictions.create(dto, actor.id);
|
|
}
|
|
|
|
@RequirePermission('compliance:manage')
|
|
@Patch('apiary-restrictions/:id')
|
|
update(
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateApiaryRestrictionDto,
|
|
@CurrentUser() actor: AuthenticatedUser,
|
|
) {
|
|
return this.restrictions.update(id, dto, actor.id);
|
|
}
|
|
}
|