using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PartnerBLL.PartnerProduct; using static GB5Shared.GB5Constant.Constant; namespace PartnerSL.EndPoints.PartnerProduct { public class GetPartnerProductList : BaseEndpoint> { private readonly IPartnerProductBLL _partnerProductBLL; public GetPartnerProductList(IPartnerProductBLL partnerProductBLL) => _partnerProductBLL = partnerProductBLL; public override void Configure() { Get("/PartnerProduct/GetPartnerProductList"); AllowAnonymous(); } public record GetPartnerProductListParameters( [property: FromHeader] string Login, [property: QueryParam] int PartnerId ); protected override string? GetCacheKey(GetPartnerProductListParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.PartnerId, EntityConstant.OBJECTPARTNERPRODUCT, CacheKeyLevel.OVERALL, loginDTO); protected override async Task> ExecuteAsync( GetPartnerProductListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _partnerProductBLL.GetPartnerProductListByPartner(req.PartnerId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.OVERALL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.OVERALL, loginDTO, ex.Message, 500); } } } }