using AccountsBLL.AccountGroup; using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.AccountGroup { public class GetAccountGroupTree : BaseEndpoint> { private readonly IAccountGroupBLL _AccountGroupBLL; public GetAccountGroupTree(IAccountGroupBLL accountGroupBLL) => _AccountGroupBLL = accountGroupBLL; public override void Configure() { Post("/AccountGroup/GetAccountGroupTree"); AllowAnonymous(); } public record GetAccountGroupTreeParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO? CriteriaDTO ); //protected override string? GetCacheKey(GetAccountGroupTreeParameters req, LoginDTO login) // => KeyGenerator.KeyGeneration(0, EntityConstant.OBJECTACCOUNTGROUP, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync( GetAccountGroupTreeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _AccountGroupBLL.GetAccountGroupTree(LoginDTO!, req.CriteriaDTO ?? new CriteriaDTO()); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }