Files
ApiCore/ApiCore-Backend/src/compliance/authority-notices.controller.ts
T
Nick SzaunigandClaude Opus 5.5 b912d29166
Backend Image / build-and-push (push) Successful in 4m58s
Frontend Image / build-and-push (push) Successful in 7m57s
feat: T6 wave 4 – notice PDFs, compliance notifications, readiness core
- Authority notice PDFs: pure model plus renderer, TSK count in A4
  landscape, FEHLT for missing particulars, stored totals with correction
  note; GET /authority-notices/:id/pdf with compliance:read.
- Compliance notifications in category COMPLIANCE: herd change and TSK
  reference day, at most one unread per topic and user (advisory lock);
  daily rule TskReferenceDayReached with Berlin day and catch-up; handlers
  in API and worker.
- Readiness core: live evaluation of seven pure rules, fingerprinted
  acknowledgements that reopen when revoked or stale, subject masking,
  read-only GET paths; READINESS_RULES injectable; kept out of the worker.
- e2e hygiene: no unscoped deletes, seeded settings rows saved/restored.
- ARCHITECTURE.md §12.8–12.10, §10 handler rows, Annahmen 78–85.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-15 14:48:57 +02:00

99 lines
2.9 KiB
TypeScript

import {
Body,
Controller,
Get,
Param,
Patch,
Post,
Query,
Res,
} from '@nestjs/common';
import type { Response } from 'express';
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 { Idempotent } from '../common/idempotency/idempotent.decorator';
import { AuthorityNoticesService } from './authority-notices.service';
import { CreateAuthorityNoticeDto } from './dto/create-authority-notice.dto';
import { MarkSentDto } from './dto/mark-sent.dto';
import { NoticeListQuery } from './dto/notice-list-query.dto';
import { UpdateAuthorityNoticeDto } from './dto/update-authority-notice.dto';
@ApiTags('authority-notices')
@ApiBearerAuth()
@Controller('authority-notices')
export class AuthorityNoticesController {
constructor(private readonly notices: AuthorityNoticesService) {}
@RequirePermission('compliance:read')
@Get()
findAll(@Query() query: NoticeListQuery) {
return this.notices.findAll(query);
}
@RequirePermission('compliance:read')
@Get(':id')
findOne(@Param('id') id: string) {
return this.notices.findOne(id);
}
@RequirePermission('compliance:read')
@Get(':id/pdf')
async pdf(@Param('id') id: string, @Res() res: Response): Promise<void> {
const { buffer, fileName } = await this.notices.pdf(id);
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Cache-Control', 'no-store');
res.setHeader('Content-Disposition', `attachment; filename="${fileName}"`);
res.send(buffer);
}
@RequirePermission('compliance:manage')
@Idempotent()
@Post()
create(
@Body() dto: CreateAuthorityNoticeDto,
@CurrentUser() actor: AuthenticatedUser,
) {
return this.notices.create(dto, actor.id);
}
@RequirePermission('compliance:manage')
@Patch(':id')
update(
@Param('id') id: string,
@Body() dto: UpdateAuthorityNoticeDto,
@CurrentUser() actor: AuthenticatedUser,
) {
return this.notices.update(id, dto, actor.id);
}
@RequirePermission('compliance:manage')
@Post(':id/recount')
recount(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
return this.notices.recount(id, actor.id);
}
@RequirePermission('compliance:manage')
@Post(':id/mark-sent')
markSent(
@Param('id') id: string,
@Body() dto: MarkSentDto,
@CurrentUser() actor: AuthenticatedUser,
) {
return this.notices.markSent(id, dto, actor.id);
}
@RequirePermission('compliance:manage')
@Post(':id/reopen')
reopen(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
return this.notices.reopen(id, actor.id);
}
@RequirePermission('compliance:manage')
@Post(':id/cancel')
cancel(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
return this.notices.cancel(id, actor.id);
}
}