GetPrediction.cs 836 B

123456789101112131415161718192021222324252627
  1. using Application.Abstractions.Messaging;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Forum.StockBoard;
  5. /// <summary>글의 예측 메타 + 채점 상태 — GET /api/posts/{id}/prediction (익명).</summary>
  6. internal sealed class GetPrediction : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/posts/{id}/prediction", async (
  11. int id,
  12. ISender sender,
  13. CancellationToken ct
  14. ) => {
  15. var result = await sender.Send(new Application.Features.Api.Forum.StockBoard.GetPrediction.Query(id), ct);
  16. return result.Match(
  17. data => ApiResponse.Ok(data),
  18. CustomResults.Problem
  19. );
  20. })
  21. .WithTags("StockBoard")
  22. .AllowAnonymous();
  23. }
  24. }