using FastEndpoints; using FrameworkBLL.WorkFlow; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.FastEndPoints.Workflow { public class GetWorkflow : BaseEndpoint { private readonly IWorkFlowBLL _WorkFlowBLL; public GetWorkflow(IWorkFlowBLL WorkflowBLL) { _WorkFlowBLL = WorkflowBLL; } public override void Configure() { Get("/Workflow/GetWorkflow"); AllowAnonymous(); } public record GetWorkflowParameters( [property: QueryParam] int WorkflowId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetWorkflowParameters parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration( parameters.WorkflowId!, EntityConstant.OBJECTWORKFLOW, CacheKeyLevel.USER_LEVEL, LoginDTO ); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( GetWorkflowParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _WorkFlowBLL.GetWorkflow(parameters.WorkflowId, loginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.USER_LEVEL, loginDTO ); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500 ); } } } }