tools/import/extract_docx.py (stdlib-Python, kein pip): Parst 'Wurfchronik der Kleinen Chaoten im Detail.docx' (Word/XML via zipfile). 93 Wuerfe + 227 benannte Tiere aus Tabellen extrahiert. Felder pro Tier: WS-Code, Wurfgeburtsdatum, Name, Farbschlag, Geschlecht (Stern- Suffix), Abnehmer, Abgabedatum, Tod-Datum + Ursache, Partnername + DOB. Sonderwerte (ZT/BLEIBT/FREI/VG:) werden herausgefiltert. Edge-Cases: Doppel-Datum (16./17.03.2021, 31.05/*01.06.2023), WS ohne Zaehler (/5), fehlende Leerzeichen vor WS:, mehrere Abnehmer (1.) ... 2.) ...). Output: output/docx_litters.json + output/docx_animals.json. tools/import/test_extract_docx.py: Unit-Tests fuer Regex-Logik + Live-Tests gegen die echte docx (skip wenn fehlt). 28/28 Tests gruen. GerbilManagerWebAPI/Import/ImportDocxService.cs: Idempotenter NACHZUG-Loader (fill-NULL-only, nie ueberschreiben): - WS-Code + Wurfgeburtsdatum -> PairingCode -> Gerbil.LitterId - Abnehmer -> Contact lookup-or-create -> Gerbil.ReceiverContactId - Abgabedatum -> Gerbil.GoHomeDate - Tod-Datum + Ursache -> Gerbil.DateOfDeath + CauseOfDeath Dry-Run zaehlt geplante Aenderungen, Execute schreibt. GerbilManagerWebAPI/Endpoints/ImportDocxEndpoints.cs: POST /import/docx/dry-run + /import/docx/execute (analog ImportEndpoints). GATE: 157/157 C#, 28/28 Python-docx-Tests, ef has-pending=No. NACHZUG: laueft NACH dem finalen WIPE+REIMPORT-3 (kein Impact auf aktuellen Pipeline).
29 lines
1.2 KiB
C#
29 lines
1.2 KiB
C#
using GerbilManagerWebAPI.Import;
|
|
using Microsoft.AspNetCore.Http.HttpResults;
|
|
|
|
namespace GerbilManagerWebAPI.Endpoints
|
|
{
|
|
public static class ImportDocxEndpoints
|
|
{
|
|
public static IEndpointRouteBuilder MapImportDocxEndpoints(this IEndpointRouteBuilder app)
|
|
{
|
|
var group = app.MapGroup("/import/docx").WithTags("Import");
|
|
|
|
// POST /import/docx/dry-run — analyse without writing
|
|
group.MapPost("/dry-run",
|
|
async Task<Ok<ImportDocxReport>> (
|
|
ApplicationContext db, IConfiguration config, IWebHostEnvironment env) =>
|
|
TypedResults.Ok(await new ImportDocxService(db, config, env).RunAsync(execute: false)));
|
|
|
|
// POST /import/docx/execute — GATED: enriches Gerbils with Litter-Link,
|
|
// ReceiverContact, GoHomeDate, DateOfDeath, CauseOfDeath (fill-NULL-only).
|
|
group.MapPost("/execute",
|
|
async Task<Ok<ImportDocxReport>> (
|
|
ApplicationContext db, IConfiguration config, IWebHostEnvironment env) =>
|
|
TypedResults.Ok(await new ImportDocxService(db, config, env).RunAsync(execute: true)));
|
|
|
|
return app;
|
|
}
|
|
}
|
|
}
|