This commit implements a complete rebranding of the project: - Updated all namespaces from `DocumentOperator` to `DocumentService`. - Renamed file paths, embedded resources, and test data references. - Updated configuration keys, logging paths, and Redis instance names. - Revised documentation to reflect the new project name. - Modified project and solution files to align with the new structure. - Updated class names, DTOs, commands, queries, and handlers. - Adjusted middleware, controllers, and API endpoints. - Updated Swagger metadata and API titles to `DocumentService API`. - Refactored test namespaces, resource paths, and embedded resources. - Updated build and deployment configurations for the new name. - Replaced all references to `DocumentOperator` in comments and literals. These changes ensure consistency across the codebase and documentation.
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using AutoMapper;
|
|
using DocumentService.Application.Common.DTOs;
|
|
using DocumentService.Application.Common.Interfaces;
|
|
using MediatR;
|
|
|
|
namespace DocumentService.Application.SwissQrCode.Queries;
|
|
|
|
/// <summary>
|
|
/// Query for extracting Swiss QR Code from PDF (Stream-based)
|
|
/// </summary>
|
|
public record ExtractSwissQrCodeQuery : IRequest<SwissQrCodeExtractionResult>
|
|
{
|
|
/// <summary>
|
|
/// PDF as stream (caller is responsible for disposal)
|
|
/// </summary>
|
|
public required Stream PdfStream { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handler for ExtractSwissQrCodeQuery
|
|
/// Orchestrates Swiss QR Code extraction using ISwissQrCodeProcessor and AutoMapper
|
|
/// </summary>
|
|
public class ExtractSwissQrCodeQueryHandler(ISwissQrCodeProcessor qrCodeProcessor, IMapper mapper)
|
|
: IRequestHandler<ExtractSwissQrCodeQuery, SwissQrCodeExtractionResult>
|
|
{
|
|
/// <summary>
|
|
/// Extracts and parses Swiss QR Code from the PDF (default: scans all pages starting with last)
|
|
/// Returns both parsed Bill DTO and raw QR text lines
|
|
/// </summary>
|
|
public async Task<SwissQrCodeExtractionResult> Handle(ExtractSwissQrCodeQuery request, CancellationToken cancellationToken)
|
|
{
|
|
// Extract: returns (Bill, RawLines) - pass stream directly
|
|
var (bill, rawLines) = await qrCodeProcessor.ExtractSwissQrCodeAsync(request.PdfStream, pageNumbers: null, cancellationToken);
|
|
|
|
// Map Codecrete Bill to DTO using AutoMapper
|
|
var billDto = mapper.Map<SwissQrBillDto>(bill);
|
|
|
|
// Return references (passed through) + Bill DTO + raw lines
|
|
return new SwissQrCodeExtractionResult(
|
|
Bill: billDto,
|
|
RawLines: rawLines
|
|
);
|
|
}
|
|
}
|