Merge branch 'newmain'

This commit is contained in:
masoodafar-web
2025-11-21 10:27:20 +03:30
parent a32de7ebc7
commit cd7b9e4ad2
7 changed files with 149 additions and 23 deletions

View File

@@ -0,0 +1,7 @@
namespace FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
public record SubmitShopBuyOrderCommand : IRequest<SubmitShopBuyOrderResponseDto>
{
//کل مبلغ قابل پرداخت
public long TotalAmount { get; init; }
}

View File

@@ -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();
}
}

View File

@@ -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);
};
}

View File

@@ -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; }
}

View File

@@ -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.WebApi.Common.Services;
using FrontOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder; using FrontOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder;
using FrontOffice.BFF.Application.UserOrderCQ.Commands.UpdateUserOrder; using FrontOffice.BFF.Application.UserOrderCQ.Commands.UpdateUserOrder;
using FrontOffice.BFF.Application.UserOrderCQ.Commands.DeleteUserOrder; using FrontOffice.BFF.Application.UserOrderCQ.Commands.DeleteUserOrder;
using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetUserOrder; using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetUserOrder;
using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter; using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter;
using FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
namespace FrontOffice.BFF.WebApi.Services; namespace FrontOffice.BFF.WebApi.Services;
public class UserOrderService : UserOrderContract.UserOrderContractBase public class UserOrderService : UserOrderContract.UserOrderContractBase
{ {
@@ -34,4 +35,8 @@ public class UserOrderService : UserOrderContract.UserOrderContractBase
{ {
return await _dispatchRequestToCQRS.Handle<GetAllUserOrderByFilterRequest, GetAllUserOrderByFilterQuery, GetAllUserOrderByFilterResponse>(request, context); 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);
}
} }

View File

@@ -42,6 +42,12 @@ service UserOrderContract
}; };
}; };
rpc SubmitShopBuyOrder(SubmitShopBuyOrderRequest) returns (SubmitShopBuyOrderResponse){
option (google.api.http) = {
post: "/SubmitShopBuyOrder"
body: "*"
};
};
} }
message CreateNewUserOrderRequest message CreateNewUserOrderRequest
{ {
@@ -113,31 +119,55 @@ message GetAllUserOrderByFilterResponseModel
int64 user_id = 7; int64 user_id = 7;
int64 user_address_id = 8; int64 user_address_id = 8;
} }
message SubmitShopBuyOrderRequest
message PaginationState
{ {
int32 page_number = 1; int64 total_amount = 1;
int32 page_size = 2;
} }
message MetaData message SubmitShopBuyOrderResponse
{ {
int64 current_page = 1; int64 order_id = 1;
string payment_status = 2;
int64 total_page = 2; google.protobuf.Timestamp created = 3;
google.protobuf.StringValue payment_method = 4;
int64 page_size = 3; google.protobuf.StringValue user_address_text = 5;
google.protobuf.Int64Value total_amount = 6;
int64 total_count = 4; repeated SubmitShopBuyOrderFactorDetail factor_details = 7;
bool has_previous = 5;
bool has_next = 6;
} }
message DecimalValue message SubmitShopBuyOrderFactorDetail
{ {
int64 product_id = 1;
int64 units = 1; string product_title = 2;
google.protobuf.StringValue product_thumbnail_path = 3;
sfixed32 nanos = 2; 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
{
int64 current_page = 1;
int64 total_page = 2;
int64 page_size = 3;
int64 total_count = 4;
bool has_previous = 5;
bool has_next = 6;
}
message DecimalValue
{
int64 units = 1;
sfixed32 nanos = 2;
}

View File

@@ -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);
};
}