| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System.Security.Claims;
- using System.Text.Json.Serialization;
- using Application.Abstractions.Messaging;
- using Domain.Entities.Paper.ValueObject;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.Paper;
- public sealed class PlaceOrderRequest
- {
- [JsonPropertyName("stockCode")]
- public string StockCode { get; set; } = "";
- [JsonPropertyName("side")]
- public PaperOrderSide Side { get; set; }
- [JsonPropertyName("quantity")]
- public int Quantity { get; set; }
- }
- /// <summary>모의투자 — 주문 접수.</summary>
- internal sealed class PlaceOrder : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapPost("api/paper/orders", async (
- PlaceOrderRequest body,
- ClaimsPrincipal user,
- ISender sender,
- CancellationToken ct
- ) => {
- var memberID = user.GetRequiredMemberID();
- var result = await sender.Send(new Application.Features.Api.Paper.PlaceOrder.Command(memberID, body.StockCode, body.Side, body.Quantity), ct);
- if (result.IsFailure)
- {
- return CustomResults.Problem(result);
- }
- return ApiResponse.Ok(result.Value);
- })
- .WithTags("Paper")
- .RequireAuthorization();
- }
- }
|