feat(domain): BIG Domain Service skeleton with the Registration aggregate (closes #6) #61

Merged
not merged 16 commits from feat/6-domain-service into main 2026-07-01 08:46:22 +00:00
2 changed files with 23 additions and 6 deletions
Showing only changes of commit 39b2388a9d - Show all commits

View File

@@ -20,8 +20,17 @@ public sealed class OpenZaakWorker(IRegistrationStore store, IAclClient acl)
{
ArgumentNullException.ThrowIfNull(job);
// STUB (red): does not load, call the ACL, or attach.
await Task.CompletedTask;
return new Uri("about:blank");
var registration = await store.GetAsync(job.RegistrationId, ct)
?? throw new InvalidOperationException(
$"No registration {job.RegistrationId} for OpenZaakAanmaken job {job.JobId}.");
// A redelivered job whose zaak was already opened completes without opening a second one.
if (registration.ZaakUrl is not null)
return registration.ZaakUrl;
var zaakUrl = await acl.OpenZaakAsync(registration.Bsn, ct);
registration.AttachZaak(zaakUrl);
await store.SaveAsync(registration, ct);
return zaakUrl;
}
}

View File

@@ -18,8 +18,16 @@ public sealed class SubmitRegistration(IRegistrationStore store, IWorkflowClient
{
ArgumentNullException.ThrowIfNull(command);
// STUB (red): no persistence, no process start.
await Task.CompletedTask;
return RegistrationId.New();
var registration = Registration.Submit(command.Bsn);
// Persist before starting the process so the worker can correlate the OpenZaakAanmaken
// job back to an aggregate that already exists (ADR-0009).
await store.SaveAsync(registration, ct);
var processInstanceId = await workflow.StartRegistrationProcessAsync(registration.Id, ct);
registration.RecordProcessStarted(processInstanceId);
await store.SaveAsync(registration, ct);
return registration.Id;
}
}