Get.cs 861 B

12345678910111213141516171819202122232425262728
  1. using Application.Abstractions.Messaging;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Forum.PostCheer;
  5. // 글의 응원 합계 + 최근 N건 조회 — D3 M4. 익명 허용 (응원 표시는 열람 조건이 아님).
  6. internal sealed class Get : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/posts/{postID}/cheers", async (
  11. int postID,
  12. int? take,
  13. ISender sender,
  14. CancellationToken ct
  15. ) => {
  16. var result = await sender.Send(new Application.Features.Api.Forum.PostCheer.Get.Query(postID, take ?? 20), ct);
  17. return result.Match(
  18. data => ApiResponse.Ok(data),
  19. CustomResults.Problem
  20. );
  21. })
  22. .WithTags("Forum")
  23. .AllowAnonymous();
  24. }
  25. }