OrdersList.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Security.Claims;
  2. using Domain.Entities.Store.ValueObject;
  3. using Web.Api.Common;
  4. using Web.Api.Extensions;
  5. using Application.Abstractions.Messaging;
  6. namespace Web.Api.Endpoints.Store;
  7. /// <summary>상점 — 내 주문 내역 리스트.</summary>
  8. internal sealed class OrdersList : IEndpoint
  9. {
  10. public void MapEndpoint(IEndpointRouteBuilder app)
  11. {
  12. app.MapGet("api/store/orders", async (
  13. OrderStatus? status,
  14. int? page,
  15. ushort? perPage,
  16. int? year,
  17. string? keyword,
  18. ClaimsPrincipal user,
  19. ISender sender,
  20. CancellationToken ct
  21. ) => {
  22. var memberID = user.GetRequiredMemberID();
  23. var data = await sender.Send(new Application.Features.Api.Store.Orders.List.Query(
  24. memberID,
  25. status,
  26. page is > 0 ? page.Value : 1,
  27. perPage is > 0 ? perPage.Value : (ushort)20,
  28. year,
  29. keyword
  30. ), ct);
  31. return ApiResponse.Ok(data);
  32. })
  33. .WithTags("Store")
  34. .RequireAuthorization();
  35. }
  36. }