Search.cs 1.1 KB

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