Add workflow and document APIs, middleware, and Swagger
Introduced `CloseWorkflowRequest` for closing workflows. Added `DocumentsController` for document downloads and `WorkflowsController` for workflow retrieval and closing. Implemented `ExceptionHandlingMiddleware` for global exception handling with structured API responses. Enhanced Swagger configuration with metadata and production support. Added `Scalar.AspNetCore` for API reference mapping. Updated project dependencies and improved API documentation.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using DigitalData.TaskFlow.Application.Features.Documents.Queries.GetDocument;
|
||||
using DigitalData.TaskFlow.Domain.Common;
|
||||
using DigitalData.TaskFlow.Domain.Documents;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DigitalData.TaskFlow.API.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Provides document binary download endpoints.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/documents")]
|
||||
public sealed class DocumentsController(ISender sender) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns binary document content by document identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">Document identifier.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>Binary stream when available.</returns>
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ApiEnvelope<object>), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(ApiEnvelope<object>), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await sender.Send(new GetDocumentQuery(id), cancellationToken);
|
||||
var data = response.Data;
|
||||
|
||||
if (data is null)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
|
||||
return File(data.Content, data.ContentType, data.FileName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user