ChannelsSearchForOrder.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Security.Claims;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. using Application.Abstractions.Messaging;
  5. namespace Web.Api.Endpoints.Store;
  6. /// <summary>상점 — 후원 채널 선택 모달용 검색. 활성 채널만. 본인 채널은 결과에서 제외.</summary>
  7. internal sealed class ChannelsSearchForOrder : IEndpoint
  8. {
  9. public void MapEndpoint(IEndpointRouteBuilder app)
  10. {
  11. app.MapGet("api/store/channels/search", async (
  12. string? keyword,
  13. bool? random,
  14. int? page,
  15. ushort? perPage,
  16. ClaimsPrincipal user,
  17. ISender sender,
  18. CancellationToken ct
  19. ) => {
  20. var memberID = user.GetRequiredMemberID();
  21. var data = await sender.Send(new Application.Features.Api.Channel.SearchForOrder.Query(
  22. memberID,
  23. keyword,
  24. random ?? false,
  25. page is > 0 ? page.Value : 1,
  26. perPage is > 0 ? perPage.Value : (ushort)20
  27. ), ct);
  28. return ApiResponse.Ok(data);
  29. })
  30. .WithTags("Store")
  31. .RequireAuthorization();
  32. }
  33. }