using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using PayRollBLL.PayGroup; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.PayGroup { // Full-DTO pay group list (PayGroupDTO, not PayGroupPicklistDTO) — mirrors // AccountsSL.EndPoints.CostCenter.GetCostCenterList's shape: a plain CriteriaDTO-filtered List // call, no FirstNumber/MaxResult paging like GetSelectListPayGroup. // // The [FromBody] property must be literally named/typed ReportCallingDTO, not a custom wrapper — // BaseEndpoint.GetReportCallingDTOFromRequest finds it via reflection on that exact property name // whenever the client sends an "H-ReportFormat"/"ReportFormat" header (which the frontend does // unconditionally for any MenuType=="Reports" menu). ReportCallingDTO.CriteriaDTO already matches // the { "CriteriaDTO": { "SectionCriteriaList": [...] } } body reportviewer.dbservice.ts's existing // generic GB5 branch sends — so this satisfies BaseEndpoint's check with no FE change. public class GetPayGroupList : BaseEndpoint> { private readonly IPayGroupBLL _PayGroupBLL; public GetPayGroupList(IPayGroupBLL payGroupBLL) { _PayGroupBLL = payGroupBLL; } public override void Configure() { Post("/PayGroup/GetPayGroupList"); AllowAnonymous(); } public record GetPayGroupListParameters( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async Task> ExecuteAsync( GetPayGroupListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _PayGroupBLL.GetPayGroupList(req.ReportCallingDTO.CriteriaDTO!, loginDTO!); 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); } } } }