using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using MMBLL.MMDocument; using MMDAL.DTO.MMHead; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.MMDocument { public class GetMMDocument : BaseEndpoint> { private readonly IMMDocumentBLL _MMDocumentBLL; public GetMMDocument(IMMDocumentBLL mmDocumentBLL) => _MMDocumentBLL = mmDocumentBLL; public override void Configure() { Post("/MMDocument/GetMMDocument"); AllowAnonymous(); } public record Params( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] MMDocumentFilterDTO Filter ); protected override string? GetCacheKey(Params req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _MMDocumentBLL.GetMMDocument(req.Filter, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }