Dividends.cs 1005 B

1234567891011121314151617181920212223242526272829
  1. using Application.Abstractions.Messaging;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Stocks;
  5. /// <summary>종목 배당 이력 — 단축코드(6자리) 배당 이력. 시가배당율·주당배당금·권리락일 포함 (익명 열람). 종목 상세 배당탭.</summary>
  6. internal sealed class Dividends : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/stocks/{code:regex(^\\d{{6}}$)}/dividends", async (
  11. string code,
  12. ISender sender,
  13. int page = 1,
  14. ushort perPage = 30,
  15. CancellationToken ct = default
  16. ) => {
  17. var result = await sender.Send(new Application.Features.Api.Stocks.GetStockDividends.Query(code, page, perPage), ct);
  18. return result.Match(
  19. () => ApiResponse.Ok(result.Value),
  20. CustomResults.Problem
  21. );
  22. })
  23. .WithTags("Stocks")
  24. .AllowAnonymous();
  25. }
  26. }