using AccountsBLL.AccountTree; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.AccountTree { // Whole-tree read (Type -> Schedule -> Group) for the Account Tree navigator — no filter // criteria needed (unlike GetAccountGroupTree), so this stays a plain GET like // GetAccountGroup.cs rather than the POST+FromBody-CriteriaDTO shape. public class GetAccountTree : BaseEndpoint> { private readonly IAccountTreeBLL _AccountTreeBLL; public GetAccountTree(IAccountTreeBLL accountTreeBLL) => _AccountTreeBLL = accountTreeBLL; public override void Configure() { Get("/AccountTree/GetAccountTree"); AllowAnonymous(); } public record GetAccountTreeParameters( [property: FromHeader] string Login ); protected override async Task> ExecuteAsync( GetAccountTreeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _AccountTreeBLL.GetAccountTree(LoginDTO!, ct); 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); } } } }