Search.cs 972 B

1234567891011121314151617181920212223242526272829303132333435
  1. using MediatR;
  2. using Web.Api.Common;
  3. namespace Web.Api.Endpoints.Forum.Comment;
  4. internal sealed class Search : IEndpoint
  5. {
  6. public void MapEndpoint(IEndpointRouteBuilder app)
  7. {
  8. app.MapGet("api/forum/comments", async (
  9. ISender sender,
  10. CancellationToken ct,
  11. int? boardID = null,
  12. int? postID = null,
  13. int? search = null,
  14. string? keyword = null,
  15. string? startAt = null,
  16. string? endAt = null,
  17. bool? isDeleted = null,
  18. int page = 1,
  19. ushort perPage = 20
  20. ) =>
  21. {
  22. var query = new Application.Features.Api.Forum.Comment.Search.Query(
  23. boardID, postID, search, keyword, startAt, endAt, isDeleted, page, perPage
  24. );
  25. return ApiResponse.Ok(
  26. await sender.Send(query, ct)
  27. );
  28. })
  29. .WithTags("Forum")
  30. .AllowAnonymous();
  31. }
  32. }