Merge branch 'newmain'
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||
public record SubmitShopBuyOrderCommand : IRequest<SubmitShopBuyOrderResponseDto>
|
||||
{
|
||||
//کل مبلغ قابل پرداخت
|
||||
public long TotalAmount { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||
public class SubmitShopBuyOrderCommandHandler : IRequestHandler<SubmitShopBuyOrderCommand, SubmitShopBuyOrderResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public SubmitShopBuyOrderCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<SubmitShopBuyOrderResponseDto> Handle(SubmitShopBuyOrderCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
//TODO: Implement your business logic
|
||||
return new SubmitShopBuyOrderResponseDto();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||
public class SubmitShopBuyOrderCommandValidator : AbstractValidator<SubmitShopBuyOrderCommand>
|
||||
{
|
||||
public SubmitShopBuyOrderCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.TotalAmount)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<SubmitShopBuyOrderCommand>.CreateWithOptions((SubmitShopBuyOrderCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||
public class SubmitShopBuyOrderResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long OrderId { get; set; }
|
||||
//
|
||||
public string PaymentStatus { get; set; }
|
||||
//
|
||||
public DateTime? Created { get; set; }
|
||||
//
|
||||
public string? PaymentMethod { get; set; }
|
||||
//
|
||||
public string? UserAddressText { get; set; }
|
||||
//
|
||||
public long? TotalAmount { get; set; }
|
||||
//
|
||||
public List<SubmitShopBuyOrderFactorDetail>? FactorDetails { get; set; }
|
||||
|
||||
}public class SubmitShopBuyOrderFactorDetail
|
||||
{
|
||||
//شناسه
|
||||
public long ProductId { get; set; }
|
||||
//
|
||||
public string ProductTitle { get; set; }
|
||||
//
|
||||
public string? ProductThumbnailPath { get; set; }
|
||||
//
|
||||
public long? UnitPrice { get; set; }
|
||||
//
|
||||
public int? Count { get; set; }
|
||||
//
|
||||
public long? UnitDiscountPrice { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.BFF.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.BFF.WebApi.Common.Services;
|
||||
using FrontOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder;
|
||||
using FrontOffice.BFF.Application.UserOrderCQ.Commands.UpdateUserOrder;
|
||||
using FrontOffice.BFF.Application.UserOrderCQ.Commands.DeleteUserOrder;
|
||||
using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetUserOrder;
|
||||
using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter;
|
||||
using FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||
namespace FrontOffice.BFF.WebApi.Services;
|
||||
public class UserOrderService : UserOrderContract.UserOrderContractBase
|
||||
{
|
||||
@@ -34,4 +35,8 @@ public class UserOrderService : UserOrderContract.UserOrderContractBase
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetAllUserOrderByFilterRequest, GetAllUserOrderByFilterQuery, GetAllUserOrderByFilterResponse>(request, context);
|
||||
}
|
||||
public override async Task<SubmitShopBuyOrderResponse> SubmitShopBuyOrder(SubmitShopBuyOrderRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<SubmitShopBuyOrderRequest, SubmitShopBuyOrderCommand, SubmitShopBuyOrderResponse>(request, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,12 @@ service UserOrderContract
|
||||
|
||||
};
|
||||
};
|
||||
rpc SubmitShopBuyOrder(SubmitShopBuyOrderRequest) returns (SubmitShopBuyOrderResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/SubmitShopBuyOrder"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewUserOrderRequest
|
||||
{
|
||||
@@ -113,15 +119,38 @@ message GetAllUserOrderByFilterResponseModel
|
||||
int64 user_id = 7;
|
||||
int64 user_address_id = 8;
|
||||
}
|
||||
|
||||
message PaginationState
|
||||
message SubmitShopBuyOrderRequest
|
||||
{
|
||||
int64 total_amount = 1;
|
||||
}
|
||||
message SubmitShopBuyOrderResponse
|
||||
{
|
||||
int64 order_id = 1;
|
||||
string payment_status = 2;
|
||||
google.protobuf.Timestamp created = 3;
|
||||
google.protobuf.StringValue payment_method = 4;
|
||||
google.protobuf.StringValue user_address_text = 5;
|
||||
google.protobuf.Int64Value total_amount = 6;
|
||||
repeated SubmitShopBuyOrderFactorDetail factor_details = 7;
|
||||
}
|
||||
message SubmitShopBuyOrderFactorDetail
|
||||
{
|
||||
int64 product_id = 1;
|
||||
string product_title = 2;
|
||||
google.protobuf.StringValue product_thumbnail_path = 3;
|
||||
google.protobuf.Int64Value unit_price = 4;
|
||||
google.protobuf.Int32Value count = 5;
|
||||
google.protobuf.Int64Value unit_discount_price = 6;
|
||||
}
|
||||
|
||||
message PaginationState
|
||||
{
|
||||
int32 page_number = 1;
|
||||
|
||||
int32 page_size = 2;
|
||||
}
|
||||
message MetaData
|
||||
{
|
||||
}
|
||||
message MetaData
|
||||
{
|
||||
int64 current_page = 1;
|
||||
|
||||
int64 total_page = 2;
|
||||
@@ -133,11 +162,12 @@ message MetaData
|
||||
bool has_previous = 5;
|
||||
|
||||
bool has_next = 6;
|
||||
}
|
||||
message DecimalValue
|
||||
{
|
||||
}
|
||||
message DecimalValue
|
||||
{
|
||||
|
||||
int64 units = 1;
|
||||
|
||||
sfixed32 nanos = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using FrontOfficeMicroservice.Protobuf.Protos.UserOrder;
|
||||
namespace FrontOfficeMicroservice.Protobuf.Validator.UserOrder;
|
||||
|
||||
public class SubmitShopBuyOrderRequestValidator : AbstractValidator<SubmitShopBuyOrderRequest>
|
||||
{
|
||||
public SubmitShopBuyOrderRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.TotalAmount)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<SubmitShopBuyOrderRequest>.CreateWithOptions((SubmitShopBuyOrderRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user