Deposit.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Security.Claims;
  2. using System.Text.Json.Serialization;
  3. using Application.Abstractions.Messaging;
  4. using Web.Api.Common;
  5. using Web.Api.Extensions;
  6. namespace Web.Api.Endpoints.Paper;
  7. public sealed class PaperDepositRequest
  8. {
  9. [JsonPropertyName("tokenAmount")]
  10. public decimal TokenAmount { get; set; }
  11. }
  12. /// <summary>모의투자 — 입금 (지갑 토큰 → 계좌).</summary>
  13. internal sealed class Deposit : IEndpoint
  14. {
  15. public void MapEndpoint(IEndpointRouteBuilder app)
  16. {
  17. app.MapPost("api/paper/account/deposit", async (
  18. PaperDepositRequest body,
  19. ClaimsPrincipal user,
  20. ISender sender,
  21. CancellationToken ct
  22. ) => {
  23. var memberID = user.GetRequiredMemberID();
  24. var result = await sender.Send(new Application.Features.Api.Paper.Deposit.Command(memberID, body.TokenAmount), ct);
  25. if (result.IsFailure)
  26. {
  27. return CustomResults.Problem(result);
  28. }
  29. return ApiResponse.Ok(result.Value);
  30. })
  31. .WithTags("Paper")
  32. .RequireAuthorization();
  33. }
  34. }