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 { // One page of Account leaves for a single Group — called only when that Group node is // expanded client-side. Mirrors GetSelectListPartyBranch.cs's FirstNumber/MaxResult // QueryParam shape. public class GetAccountTreeLeaves : BaseEndpoint> { private readonly IAccountTreeBLL _AccountTreeBLL; public GetAccountTreeLeaves(IAccountTreeBLL accountTreeBLL) => _AccountTreeBLL = accountTreeBLL; public override void Configure() { Post("/AccountTree/GetAccountTreeLeaves"); AllowAnonymous(); } public record GetAccountTreeLeavesParameters( [property: FromHeader] string Login, [property: QueryParam] int AccountGroupId, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async Task> ExecuteAsync( GetAccountTreeLeavesParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _AccountTreeBLL.GetAccountTreeLeaves( req.AccountGroupId, req.FirstNumber, req.MaxResult, 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); } } } }