DonationRanking.cs 874 B

1234567891011121314151617181920212223242526272829
  1. using Web.Api.Common;
  2. using MediatR;
  3. using Domain.Entities.Donations.ValueObject;
  4. namespace Web.Api.Endpoints.Widget;
  5. /// <summary>후원 순위 (OBS 위젯용, 인증 불필요)</summary>
  6. internal sealed class DonationRanking : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/widget/rank/{channelID}", async (
  11. int channelID,
  12. RankPeriodType? periodType,
  13. int? maxRank,
  14. ISender sender,
  15. CancellationToken ct
  16. ) => {
  17. var data = await sender.Send(new Application.Features.Api.DonationRank.GetRanking.Query(
  18. channelID,
  19. periodType ?? RankPeriodType.Daily,
  20. maxRank ?? 5
  21. ), ct);
  22. return ApiResponse.Ok(data);
  23. })
  24. .WithTags("Widget")
  25. .AllowAnonymous();
  26. }
  27. }