using AdminBLL.Subscription; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.Subscription; public class GetSubscriptions : BaseEndpoint> { private readonly ISubscriptionBLL _bll; public GetSubscriptions(ISubscriptionBLL bll) => _bll = bll; public override void Configure() { Get("/Subscription/GetSubscriptions"); AllowAnonymous(); } protected override string? GetCacheKey(Parameters req, LoginDTO login) => $"Subscription:{login.ClientId}:{req.ObjectTypeId}:{req.ObjectId}"; protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { var result = await _bll.GetSubscriptionsAsync(req.ObjectTypeId, req.ObjectId, login, ct) .ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.CLIENT_LEVEL, login); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] int ObjectTypeId, [property: QueryParam] int ObjectId); }