|
|
@@ -2,6 +2,7 @@ using System.Security.Claims;
|
|
|
using System.Text.Json.Serialization;
|
|
|
using Application.Abstractions.Messaging;
|
|
|
using Domain.Entities.Paper.ValueObject;
|
|
|
+using SharedKernel.Results;
|
|
|
using Web.Api.Common;
|
|
|
using Web.Api.Extensions;
|
|
|
|
|
|
@@ -12,8 +13,9 @@ public sealed class PlaceOrderRequest
|
|
|
[JsonPropertyName("stockCode")]
|
|
|
public string StockCode { get; set; } = "";
|
|
|
|
|
|
+ /// <summary>주문 방향 — "Buy" | "Sell" (대소문자 무시).</summary>
|
|
|
[JsonPropertyName("side")]
|
|
|
- public PaperOrderSide Side { get; set; }
|
|
|
+ public string Side { get; set; } = "";
|
|
|
|
|
|
[JsonPropertyName("quantity")]
|
|
|
public int Quantity { get; set; }
|
|
|
@@ -30,8 +32,13 @@ internal sealed class PlaceOrder : IEndpoint
|
|
|
ISender sender,
|
|
|
CancellationToken ct
|
|
|
) => {
|
|
|
+ if (!Enum.TryParse<PaperOrderSide>(body.Side, ignoreCase: true, out var side) || !Enum.IsDefined(side))
|
|
|
+ {
|
|
|
+ return CustomResults.Problem(Result.Failure(Error.Problem("Paper.InvalidSide", "주문 방향(side)이 올바르지 않습니다. (Buy | Sell)")));
|
|
|
+ }
|
|
|
+
|
|
|
var memberID = user.GetRequiredMemberID();
|
|
|
- var result = await sender.Send(new Application.Features.Api.Paper.PlaceOrder.Command(memberID, body.StockCode, body.Side, body.Quantity), ct);
|
|
|
+ var result = await sender.Send(new Application.Features.Api.Paper.PlaceOrder.Command(memberID, body.StockCode, side, body.Quantity), ct);
|
|
|
|
|
|
if (result.IsFailure)
|
|
|
{
|