using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GB5Shared.ListQuery; using PIEDAL.DTO.Profile; using static GB5Shared.GB5Constant.Constant; namespace PIESL.EndPoints.Profile { public class GetPIEProfileList : BaseEndpoint> { private readonly IListHandler _ListHandler; public GetPIEProfileList(IListHandler listHandler) { _ListHandler = listHandler; } public override void Configure() { Post("/PIE/GetPIEProfileList"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] string? Industry = null, [property: QueryParam] string? Geography = null, [property: QueryParam] short? Status = null, [property: QueryParam] string? SearchText = null, [property: QueryParam] string? SortBy = null, [property: QueryParam] bool SortDesc = false, [property: QueryParam] int PageOffset = 0, [property: QueryParam] int PageSize = 100 ); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(loginDTO.ClientId, EntityConstant.OBJECTPIEPROFILE, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { var criteria = new PIEProfileListCriteria { Industry = req.Industry, Geography = req.Geography, Status = req.Status, SearchText = req.SearchText, SortBy = req.SortBy, SortDesc = req.SortDesc, PageOffset = req.PageOffset, PageSize = req.PageSize }; var result = await _ListHandler.HandleAsync(new PIEProfileListQuery(criteria), loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } } }