43 lines
1.8 KiB
C#
43 lines
1.8 KiB
C#
using GerbilManagerWebAPI.Import;
|
|
using Microsoft.AspNetCore.Http.HttpResults;
|
|
|
|
namespace GerbilManagerWebAPI.Endpoints
|
|
{
|
|
/// <summary>
|
|
/// FEAT-8 stage 3 — spreadsheet import loader. Consumes tools/import/output.
|
|
/// POST /import/dry-run -> report what WOULD be created/linked/quarantined (no writes)
|
|
/// POST /import/execute -> load the conflict-free subset (idempotent). GATED: only run
|
|
/// against Julian's DB under god-supervision after he approves the dry-run.
|
|
/// </summary>
|
|
public static class ImportEndpoints
|
|
{
|
|
public static IEndpointRouteBuilder MapImportEndpoints(this IEndpointRouteBuilder app)
|
|
{
|
|
var group = app.MapGroup("/import").WithTags("Import");
|
|
|
|
group.MapPost("/dry-run", async Task<Ok<ImportReport>> (
|
|
ApplicationContext db, IConfiguration config, IWebHostEnvironment env) =>
|
|
{
|
|
var report = await new ImportService(db, config, env).RunAsync(execute: false);
|
|
return TypedResults.Ok(report);
|
|
});
|
|
|
|
group.MapPost("/execute", async Task<Ok<ImportReport>> (
|
|
ApplicationContext db, IConfiguration config, IWebHostEnvironment env) =>
|
|
{
|
|
var report = await new ImportService(db, config, env).RunAsync(execute: true);
|
|
return TypedResults.Ok(report);
|
|
});
|
|
|
|
group.MapPost("/ingest-resolved", async Task<Ok<string>> (
|
|
ApplicationContext db, IConfiguration config, IWebHostEnvironment env) =>
|
|
{
|
|
var result = await new IngestResolvedService(db, config, env).RunAsync();
|
|
return TypedResults.Ok(result);
|
|
});
|
|
|
|
return app;
|
|
}
|
|
}
|
|
}
|