InventoryList.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Security.Claims;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. using MediatR;
  5. namespace Web.Api.Endpoints.Store;
  6. /// <summary>상점 — 내 보관함 (Digital 상품 쿠폰 코드).</summary>
  7. internal sealed class InventoryList : IEndpoint
  8. {
  9. public void MapEndpoint(IEndpointRouteBuilder app)
  10. {
  11. app.MapGet("api/store/inventory", async (
  12. int? page,
  13. ushort? perPage,
  14. int? productID,
  15. ClaimsPrincipal user,
  16. ISender sender,
  17. CancellationToken ct
  18. ) => {
  19. var memberID = user.GetRequiredMemberID();
  20. var data = await sender.Send(new Application.Features.Api.Store.Inventory.List.Query(
  21. memberID,
  22. page is > 0 ? page.Value : 1,
  23. perPage is > 0 ? perPage.Value : (ushort)20,
  24. productID is > 0 ? productID.Value : null
  25. ), ct);
  26. return ApiResponse.Ok(data);
  27. })
  28. .WithTags("Store")
  29. .RequireAuthorization();
  30. }
  31. }