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 GetPartnerProduct : BaseEndpoint> { private readonly IPartnerProductBLL _partnerProductBLL; public GetPartnerProduct(IPartnerProductBLL partnerProductBLL) => _partnerProductBLL = partnerProductBLL; public override void Configure() { Get("/PartnerProduct/GetPartnerProduct"); AllowAnonymous(); } public record GetPartnerProductParameters( [property: FromHeader] string Login, [property: QueryParam] int PartnerProductId ); protected override string? GetCacheKey(GetPartnerProductParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.PartnerProductId, EntityConstant.OBJECTPARTNERPRODUCT, CacheKeyLevel.OVERALL, loginDTO); protected override async Task> ExecuteAsync( GetPartnerProductParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _partnerProductBLL.GetPartnerProduct(req.PartnerProductId, 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); } } } }