| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System.Security.Claims;
- using System.Text.Json.Serialization;
- using Application.Abstractions.Messaging;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.Paper;
- public sealed class PaperWithdrawRequest
- {
- [JsonPropertyName("tokenAmount")]
- public decimal TokenAmount { get; set; }
- [JsonPropertyName("all")]
- public bool All { get; set; }
- }
- /// <summary>모의투자 — 출금 (계좌 → 지갑 토큰).</summary>
- internal sealed class Withdraw : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapPost("api/paper/account/withdraw", async (
- PaperWithdrawRequest body,
- ClaimsPrincipal user,
- ISender sender,
- CancellationToken ct
- ) => {
- var memberID = user.GetRequiredMemberID();
- var result = await sender.Send(new Application.Features.Api.Paper.Withdraw.Command(memberID, body.TokenAmount, body.All), ct);
- if (result.IsFailure)
- {
- return CustomResults.Problem(result);
- }
- return ApiResponse.Ok(result.Value);
- })
- .WithTags("Paper")
- .RequireAuthorization();
- }
- }
|