Search.cs 947 B

1234567891011121314151617181920212223242526272829303132
  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 pageNum = 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, pageNum, perPage
  24. );
  25. return ApiResponse.Ok(await sender.Send(query, ct));
  26. })
  27. .WithTags("Forum")
  28. .AllowAnonymous();
  29. }
  30. }