From 69db103e0e010a41bf59b3f155626af31df132ac Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Wed, 15 Jul 2026 11:01:33 +0200 Subject: [PATCH] feat(domain): werkbak query + GET /behandel/werkbak (refs #13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Werkbak use-case reads the open Beoordelen tasks (§8.2) and enriches each with its aggregate's bsn + status; exposed as GET /behandel/werkbak for the BFF to proxy. Co-Authored-By: Claude Opus 4.8 (1M context) --- services/domain/Big.Api/Program.cs | 7 +++++ services/domain/Big.Application/Werkbak.cs | 32 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 services/domain/Big.Application/Werkbak.cs diff --git a/services/domain/Big.Api/Program.cs b/services/domain/Big.Api/Program.cs index d24d5c6..176ef91 100644 --- a/services/domain/Big.Api/Program.cs +++ b/services/domain/Big.Api/Program.cs @@ -26,6 +26,7 @@ builder.Services.AddHttpClient(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -73,6 +74,12 @@ app.MapPost("/registrations/{id}/decide", async (string id, DecideRequest body, return Results.NoContent(); }); +// The behandelaar's werkbak (S-12): the registrations awaiting beoordeling, read from the open +// Beoordelen user tasks (§8.2) and enriched with bsn + status. The BFF proxies this behind +// medewerker-realm + behandelaar-role authorization; the domain trusts its callers (§8.3). +app.MapGet("/behandel/werkbak", async (Werkbak werkbak, CancellationToken ct) => + Results.Ok(await werkbak.GetAsync(ct))); + // Read a registration. Its zaak URL appears once the worker has opened the zaak (eventually). app.MapGet("/registrations/{id}", async (string id, IRegistrationStore store, CancellationToken ct) => { diff --git a/services/domain/Big.Application/Werkbak.cs b/services/domain/Big.Application/Werkbak.cs new file mode 100644 index 0000000..4275d50 --- /dev/null +++ b/services/domain/Big.Application/Werkbak.cs @@ -0,0 +1,32 @@ +namespace Big.Application; + +/// One row of the behandelaar's werkbak: a registration awaiting beoordeling, with the +/// public-facing reference (its id) plus the bsn and status a behandelaar needs to triage it. +public sealed record WerkbakItem(string RegistrationId, string Bsn, string Status); + +/// +/// The werkbak query (S-12c): the registrations awaiting a behandelaar's beoordeling. It reads the +/// open Beoordelen tasks from the workflow engine (§8.2, via ) — +/// the authoritative set of work items — and enriches each with its aggregate (bsn + status). A task +/// whose registration the domain doesn't know is skipped rather than invented. +/// +public sealed class Werkbak(IUserTaskClient tasks, IRegistrationStore store) +{ + public async Task> GetAsync(CancellationToken ct = default) + { + var open = await tasks.GetOpenBeoordelingenAsync(ct); + + var items = new List(open.Count); + foreach (var task in open) + { + var registration = await store.GetAsync(task.RegistrationId, ct); + if (registration is null) + continue; + + items.Add(new WerkbakItem( + registration.Id.ToString(), registration.Bsn, registration.Status.ToString())); + } + + return items; + } +}