using FastEndpoints; using FMBLL.Handlers; using FMDAL.DTO.ScanIntake; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FMSL.EndPoints.ScanEvent { // The scan-intake endpoint — Capture step of the RAM design's own pipeline. Resolves the // scanned value's identity, always records a TSCANEVENT row, and (for a resolved entity) // routes through the platform IScanEventDispatcher to whichever module owns that EntityType. public class SubmitScan : BaseEndpoint> { private readonly IScanIntakeBLL _ScanIntakeBLL; public SubmitScan(IScanIntakeBLL scanIntakeBLL) { _ScanIntakeBLL = scanIntakeBLL; } public override void Configure() { Post("/ScanEvent/SubmitScan"); AllowAnonymous(); } public class SubmitScanParameters { [FromHeader] public string Login { get; set; } = string.Empty; [FromBody] public ScanSubmitRequestDTO Request { get; set; } = new(); } protected override string? GetCacheKey(SubmitScanParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SubmitScanParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _ScanIntakeBLL.SubmitScanAsync(req.Request, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }