Generator Changes at 11/22/2025 9:58:16 PM +03:30
This commit is contained in:
@@ -8,12 +8,14 @@ public record CreateNewUserOrderCommand : IRequest<CreateNewUserOrderResponseDto
|
|||||||
//شناسه تراکنش
|
//شناسه تراکنش
|
||||||
public long? TransactionId { get; init; }
|
public long? TransactionId { get; init; }
|
||||||
//وضعیت پرداخت
|
//وضعیت پرداخت
|
||||||
public bool PaymentStatus { get; init; }
|
public PaymentStatus PaymentStatus { get; init; }
|
||||||
//تاریخ پرداخت
|
//تاریخ پرداخت
|
||||||
public DateTime? PaymentDate { get; init; }
|
public DateTime? PaymentDate { get; init; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long UserId { get; init; }
|
public long UserId { get; init; }
|
||||||
//شناسه آدرس کاربر
|
//شناسه آدرس کاربر
|
||||||
public long UserAddressId { get; init; }
|
public long UserAddressId { get; init; }
|
||||||
|
//
|
||||||
|
public PaymentMethod? PaymentMethod { get; init; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,14 @@ public class CreateNewUserOrderCommandValidator : AbstractValidator<CreateNewUse
|
|||||||
RuleFor(model => model.PackageId)
|
RuleFor(model => model.PackageId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.PaymentStatus)
|
RuleFor(model => model.PaymentStatus)
|
||||||
|
.IsInEnum()
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserAddressId)
|
RuleFor(model => model.UserAddressId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.PaymentMethod)
|
||||||
|
.IsInEnum();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace CMSMicroservice.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||||
|
public record SubmitShopBuyOrderCommand : IRequest<SubmitShopBuyOrderResponseDto>
|
||||||
|
{
|
||||||
|
//کل مبلغ ورودی
|
||||||
|
public long TotalAmount { get; init; }
|
||||||
|
//شناسه کاربر
|
||||||
|
public long UserId { get; init; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using CMSMicroservice.Domain.Events;
|
||||||
|
namespace CMSMicroservice.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||||
|
public class SubmitShopBuyOrderCommandHandler : IRequestHandler<SubmitShopBuyOrderCommand, SubmitShopBuyOrderResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public SubmitShopBuyOrderCommandHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<SubmitShopBuyOrderResponseDto> Handle(SubmitShopBuyOrderCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
//TODO: Implement your business logic
|
||||||
|
return new SubmitShopBuyOrderResponseDto();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
namespace CMSMicroservice.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||||
|
public class SubmitShopBuyOrderCommandValidator : AbstractValidator<SubmitShopBuyOrderCommand>
|
||||||
|
{
|
||||||
|
public SubmitShopBuyOrderCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(model => model.TotalAmount)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.UserId)
|
||||||
|
.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 CMSMicroservice.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||||
|
public class SubmitShopBuyOrderResponseDto
|
||||||
|
{
|
||||||
|
//شناسه
|
||||||
|
public long Id { get; set; }
|
||||||
|
//
|
||||||
|
public PaymentStatus PaymentStatus { get; set; }
|
||||||
|
//
|
||||||
|
public DateTime? Created { get; set; }
|
||||||
|
//
|
||||||
|
public PaymentMethod? 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; }
|
||||||
|
}
|
||||||
@@ -10,12 +10,14 @@ public record UpdateUserOrderCommand : IRequest<Unit>
|
|||||||
//شناسه تراکنش
|
//شناسه تراکنش
|
||||||
public long? TransactionId { get; init; }
|
public long? TransactionId { get; init; }
|
||||||
//وضعیت پرداخت
|
//وضعیت پرداخت
|
||||||
public bool PaymentStatus { get; init; }
|
public PaymentStatus PaymentStatus { get; init; }
|
||||||
//تاریخ پرداخت
|
//تاریخ پرداخت
|
||||||
public DateTime? PaymentDate { get; init; }
|
public DateTime? PaymentDate { get; init; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long UserId { get; init; }
|
public long UserId { get; init; }
|
||||||
//شناسه آدرس کاربر
|
//شناسه آدرس کاربر
|
||||||
public long UserAddressId { get; init; }
|
public long UserAddressId { get; init; }
|
||||||
|
//
|
||||||
|
public PaymentMethod? PaymentMethod { get; init; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,11 +10,14 @@ public class UpdateUserOrderCommandValidator : AbstractValidator<UpdateUserOrder
|
|||||||
RuleFor(model => model.PackageId)
|
RuleFor(model => model.PackageId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.PaymentStatus)
|
RuleFor(model => model.PaymentStatus)
|
||||||
|
.IsInEnum()
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserAddressId)
|
RuleFor(model => model.UserAddressId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.PaymentMethod)
|
||||||
|
.IsInEnum();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using CMSMicroservice.Domain.Events;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.UserOrderCQ.EventHandlers;
|
||||||
|
|
||||||
|
public class SubmitShopBuyOrderEventHandler : INotificationHandler<SubmitShopBuyOrderEvent>
|
||||||
|
{
|
||||||
|
private readonly ILogger<
|
||||||
|
SubmitShopBuyOrderEventHandler> _logger;
|
||||||
|
|
||||||
|
public SubmitShopBuyOrderEventHandler(ILogger<SubmitShopBuyOrderEventHandler> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(SubmitShopBuyOrderEvent notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,20 +10,22 @@ public record GetAllUserOrderByFilterQuery : IRequest<GetAllUserOrderByFilterRes
|
|||||||
|
|
||||||
}public class GetAllUserOrderByFilterFilter
|
}public class GetAllUserOrderByFilterFilter
|
||||||
{
|
{
|
||||||
//شناسه
|
//شناسه
|
||||||
public long? Id { get; set; }
|
public long? Id { get; set; }
|
||||||
//قیمت
|
//قیمت
|
||||||
public long? Price { get; set; }
|
public long? Price { get; set; }
|
||||||
//شناسه پکیج
|
//شناسه پکیج
|
||||||
public long? PackageId { get; set; }
|
public long? PackageId { get; set; }
|
||||||
//شناسه تراکنش
|
//شناسه تراکنش
|
||||||
public long? TransactionId { get; set; }
|
public long? TransactionId { get; set; }
|
||||||
//وضعیت پرداخت
|
//وضعیت پرداخت
|
||||||
public int? PaymentStatus { get; set; }
|
public PaymentStatus? PaymentStatus { get; set; }
|
||||||
//تاریخ پرداخت
|
//تاریخ پرداخت
|
||||||
public DateTime? PaymentDate { get; set; }
|
public DateTime? PaymentDate { get; set; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long? UserId { get; set; }
|
public long? UserId { get; set; }
|
||||||
//شناسه آدرس کاربر
|
//شناسه آدرس کاربر
|
||||||
public long? UserAddressId { get; set; }
|
public long? UserAddressId { get; set; }
|
||||||
|
//
|
||||||
|
public PaymentMethod? PaymentMethod { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,20 +8,26 @@ public class GetAllUserOrderByFilterResponseDto
|
|||||||
|
|
||||||
}public class GetAllUserOrderByFilterResponseModel
|
}public class GetAllUserOrderByFilterResponseModel
|
||||||
{
|
{
|
||||||
//شناسه
|
//شناسه
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
//قیمت
|
//قیمت
|
||||||
public long Price { get; set; }
|
public long Price { get; set; }
|
||||||
//شناسه پکیج
|
//شناسه پکیج
|
||||||
public long PackageId { get; set; }
|
public long PackageId { get; set; }
|
||||||
//شناسه تراکنش
|
//شناسه تراکنش
|
||||||
public long? TransactionId { get; set; }
|
public long? TransactionId { get; set; }
|
||||||
//وضعیت پرداخت
|
//وضعیت پرداخت
|
||||||
public int PaymentStatus { get; set; }
|
public PaymentStatus PaymentStatus { get; set; }
|
||||||
//تاریخ پرداخت
|
//تاریخ پرداخت
|
||||||
public DateTime? PaymentDate { get; set; }
|
public DateTime? PaymentDate { get; set; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
//شناسه آدرس کاربر
|
//شناسه آدرس کاربر
|
||||||
public long UserAddressId { get; set; }
|
public long UserAddressId { get; set; }
|
||||||
|
//
|
||||||
|
public PaymentMethod? PaymentMethod { get; set; }
|
||||||
|
//
|
||||||
|
public string? UserAddressText { get; set; }
|
||||||
|
//
|
||||||
|
public long? TotalAmount { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,18 @@ public class GetUserOrderResponseDto
|
|||||||
//شناسه تراکنش
|
//شناسه تراکنش
|
||||||
public long? TransactionId { get; set; }
|
public long? TransactionId { get; set; }
|
||||||
//وضعیت پرداخت
|
//وضعیت پرداخت
|
||||||
public bool PaymentStatus { get; set; }
|
public PaymentStatus PaymentStatus { get; set; }
|
||||||
//تاریخ پرداخت
|
//تاریخ پرداخت
|
||||||
public DateTime? PaymentDate { get; set; }
|
public DateTime? PaymentDate { get; set; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
//شناسه آدرس کاربر
|
//شناسه آدرس کاربر
|
||||||
public long UserAddressId { get; set; }
|
public long UserAddressId { get; set; }
|
||||||
|
//
|
||||||
|
public PaymentMethod? PaymentMethod { get; set; }
|
||||||
|
//
|
||||||
|
public long? TotalAmount { get; set; }
|
||||||
|
//
|
||||||
|
public string? UserAddressText { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
using CMSMicroservice.Domain.Enums;
|
|
||||||
|
|
||||||
namespace CMSMicroservice.Domain.Entities;
|
namespace CMSMicroservice.Domain.Entities;
|
||||||
//سفارش کاربر
|
//سفارش کاربر
|
||||||
public class UserOrder : BaseAuditableEntity
|
public class UserOrder : BaseAuditableEntity
|
||||||
@@ -24,6 +22,7 @@ public class UserOrder : BaseAuditableEntity
|
|||||||
public long UserAddressId { get; set; }
|
public long UserAddressId { get; set; }
|
||||||
//UserAddress Navigation Property
|
//UserAddress Navigation Property
|
||||||
public virtual UserAddress UserAddress { get; set; }
|
public virtual UserAddress UserAddress { get; set; }
|
||||||
|
public PaymentMethod? PaymentMethod { get; set; }
|
||||||
//FactorDetails Collection Navigation Reference
|
//FactorDetails Collection Navigation Reference
|
||||||
public virtual ICollection<FactorDetails> FactorDetailss { get; set; }
|
public virtual ICollection<FactorDetails> FactorDetailss { get; set; }
|
||||||
//Transactions Collection Navigation Reference
|
//Transactions Collection Navigation Reference
|
||||||
|
|||||||
7
src/CMSMicroservice.Domain/Enums/PaymentMethod.cs
Normal file
7
src/CMSMicroservice.Domain/Enums/PaymentMethod.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace CMSMicroservice.Domain.Enums;
|
||||||
|
//
|
||||||
|
public enum PaymentMethod
|
||||||
|
{
|
||||||
|
IPG = 0,
|
||||||
|
Wallet = 1,
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace CMSMicroservice.Domain.Events;
|
||||||
|
public class SubmitShopBuyOrderEvent : BaseEvent
|
||||||
|
{
|
||||||
|
public SubmitShopBuyOrderEvent(UserOrder item)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public UserOrder Item { get; }
|
||||||
|
}
|
||||||
@@ -49,3 +49,8 @@ enum ContractType
|
|||||||
Main = 0;
|
Main = 0;
|
||||||
CMS = 1;
|
CMS = 1;
|
||||||
}
|
}
|
||||||
|
enum PaymentMethod
|
||||||
|
{
|
||||||
|
IPG = 0;
|
||||||
|
Wallet = 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,16 +43,29 @@ service UserOrderContract
|
|||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
rpc SubmitShopBuyOrder(SubmitShopBuyOrderRequest) returns (SubmitShopBuyOrderResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/SubmitShopBuyOrder"
|
||||||
|
body: "*"
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
message CreateNewUserOrderRequest
|
message CreateNewUserOrderRequest
|
||||||
{
|
{
|
||||||
int64 price = 1;
|
int64 price = 1;
|
||||||
int64 package_id = 2;
|
int64 package_id = 2;
|
||||||
google.protobuf.Int64Value transaction_id = 3;
|
google.protobuf.Int64Value transaction_id = 3;
|
||||||
bool payment_status = 4;
|
oneof PaymentStatus_item
|
||||||
|
{
|
||||||
|
messages.PaymentStatus payment_status = 4;
|
||||||
|
}
|
||||||
google.protobuf.Timestamp payment_date = 5;
|
google.protobuf.Timestamp payment_date = 5;
|
||||||
int64 user_id = 6;
|
int64 user_id = 6;
|
||||||
int64 user_address_id = 7;
|
int64 user_address_id = 7;
|
||||||
|
oneof PaymentMethod_item
|
||||||
|
{
|
||||||
|
messages.PaymentMethod payment_method = 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
message CreateNewUserOrderResponse
|
message CreateNewUserOrderResponse
|
||||||
{
|
{
|
||||||
@@ -64,10 +77,17 @@ message UpdateUserOrderRequest
|
|||||||
int64 price = 2;
|
int64 price = 2;
|
||||||
int64 package_id = 3;
|
int64 package_id = 3;
|
||||||
google.protobuf.Int64Value transaction_id = 4;
|
google.protobuf.Int64Value transaction_id = 4;
|
||||||
bool payment_status = 5;
|
oneof PaymentStatus_item
|
||||||
|
{
|
||||||
|
messages.PaymentStatus payment_status = 5;
|
||||||
|
}
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
int64 user_id = 7;
|
int64 user_id = 7;
|
||||||
int64 user_address_id = 8;
|
int64 user_address_id = 8;
|
||||||
|
oneof PaymentMethod_item
|
||||||
|
{
|
||||||
|
messages.PaymentMethod payment_method = 9;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
message DeleteUserOrderRequest
|
message DeleteUserOrderRequest
|
||||||
{
|
{
|
||||||
@@ -83,10 +103,19 @@ message GetUserOrderResponse
|
|||||||
int64 price = 2;
|
int64 price = 2;
|
||||||
int64 package_id = 3;
|
int64 package_id = 3;
|
||||||
google.protobuf.Int64Value transaction_id = 4;
|
google.protobuf.Int64Value transaction_id = 4;
|
||||||
bool payment_status = 5;
|
oneof PaymentStatus_item
|
||||||
|
{
|
||||||
|
messages.PaymentStatus payment_status = 5;
|
||||||
|
}
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
int64 user_id = 7;
|
int64 user_id = 7;
|
||||||
int64 user_address_id = 8;
|
int64 user_address_id = 8;
|
||||||
|
oneof PaymentMethod_item
|
||||||
|
{
|
||||||
|
messages.PaymentMethod payment_method = 9;
|
||||||
|
}
|
||||||
|
google.protobuf.Int64Value total_amount = 10;
|
||||||
|
google.protobuf.StringValue user_address_text = 11;
|
||||||
}
|
}
|
||||||
message GetAllUserOrderByFilterRequest
|
message GetAllUserOrderByFilterRequest
|
||||||
{
|
{
|
||||||
@@ -100,10 +129,17 @@ message GetAllUserOrderByFilterFilter
|
|||||||
google.protobuf.Int64Value price = 2;
|
google.protobuf.Int64Value price = 2;
|
||||||
google.protobuf.Int64Value package_id = 3;
|
google.protobuf.Int64Value package_id = 3;
|
||||||
google.protobuf.Int64Value transaction_id = 4;
|
google.protobuf.Int64Value transaction_id = 4;
|
||||||
google.protobuf.Int32Value payment_status = 5;
|
oneof PaymentStatus_item
|
||||||
|
{
|
||||||
|
messages.PaymentStatus payment_status = 5;
|
||||||
|
}
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
google.protobuf.Int64Value user_id = 7;
|
google.protobuf.Int64Value user_id = 7;
|
||||||
google.protobuf.Int64Value user_address_id = 8;
|
google.protobuf.Int64Value user_address_id = 8;
|
||||||
|
oneof PaymentMethod_item
|
||||||
|
{
|
||||||
|
messages.PaymentMethod payment_method = 9;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
message GetAllUserOrderByFilterResponse
|
message GetAllUserOrderByFilterResponse
|
||||||
{
|
{
|
||||||
@@ -116,8 +152,47 @@ message GetAllUserOrderByFilterResponseModel
|
|||||||
int64 price = 2;
|
int64 price = 2;
|
||||||
int64 package_id = 3;
|
int64 package_id = 3;
|
||||||
google.protobuf.Int64Value transaction_id = 4;
|
google.protobuf.Int64Value transaction_id = 4;
|
||||||
int32 payment_status = 5;
|
oneof PaymentStatus_item
|
||||||
|
{
|
||||||
|
messages.PaymentStatus payment_status = 5;
|
||||||
|
}
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
int64 user_id = 7;
|
int64 user_id = 7;
|
||||||
int64 user_address_id = 8;
|
int64 user_address_id = 8;
|
||||||
|
oneof PaymentMethod_item
|
||||||
|
{
|
||||||
|
messages.PaymentMethod payment_method = 9;
|
||||||
|
}
|
||||||
|
google.protobuf.StringValue user_address_text = 10;
|
||||||
|
google.protobuf.Int64Value total_amount = 11;
|
||||||
|
}
|
||||||
|
message SubmitShopBuyOrderRequest
|
||||||
|
{
|
||||||
|
int64 total_amount = 1;
|
||||||
|
int64 user_id = 2;
|
||||||
|
}
|
||||||
|
message SubmitShopBuyOrderResponse
|
||||||
|
{
|
||||||
|
int64 id = 1;
|
||||||
|
oneof PaymentStatus_item
|
||||||
|
{
|
||||||
|
messages.PaymentStatus payment_status = 2;
|
||||||
|
}
|
||||||
|
google.protobuf.Timestamp created = 3;
|
||||||
|
oneof PaymentMethod_item
|
||||||
|
{
|
||||||
|
messages.PaymentMethod 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,14 @@ public class CreateNewUserOrderRequestValidator : AbstractValidator<CreateNewUse
|
|||||||
RuleFor(model => model.PackageId)
|
RuleFor(model => model.PackageId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.PaymentStatus)
|
RuleFor(model => model.PaymentStatus)
|
||||||
|
.IsInEnum()
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserAddressId)
|
RuleFor(model => model.UserAddressId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.PaymentMethod)
|
||||||
|
.IsInEnum();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||||
|
namespace CMSMicroservice.Protobuf.Validator.UserOrder;
|
||||||
|
|
||||||
|
public class SubmitShopBuyOrderRequestValidator : AbstractValidator<SubmitShopBuyOrderRequest>
|
||||||
|
{
|
||||||
|
public SubmitShopBuyOrderRequestValidator()
|
||||||
|
{
|
||||||
|
RuleFor(model => model.TotalAmount)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.UserId)
|
||||||
|
.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);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -13,11 +13,14 @@ public class UpdateUserOrderRequestValidator : AbstractValidator<UpdateUserOrder
|
|||||||
RuleFor(model => model.PackageId)
|
RuleFor(model => model.PackageId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.PaymentStatus)
|
RuleFor(model => model.PaymentStatus)
|
||||||
|
.IsInEnum()
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserAddressId)
|
RuleFor(model => model.UserAddressId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.PaymentMethod)
|
||||||
|
.IsInEnum();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ namespace CMSMicroservice.WebApi.Common.Mappings;
|
|||||||
public class UserOrderProfile : IRegister
|
public class UserOrderProfile : IRegister
|
||||||
{
|
{
|
||||||
void IRegister.Register(TypeAdapterConfig config)
|
void IRegister.Register(TypeAdapterConfig config)
|
||||||
{
|
{
|
||||||
//config.NewConfig<Source,Destination>()
|
config.NewConfig<Protobuf.Protos.UserOrder.GetAllUserOrderByFilterRequest, Application.UserOrderCQ.Queries.GetAllUserOrderByFilter.GetAllUserOrderByFilterQuery>()
|
||||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
.IgnoreIf((src, dest) => !src.Filter.HasPaymentStatus, dest => dest.Filter.PaymentStatus)
|
||||||
|
.IgnoreIf((src, dest) => !src.Filter.HasPaymentMethod, dest => dest.Filter.PaymentMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using CMSMicroservice.Application.UserOrderCQ.Commands.UpdateUserOrder;
|
|||||||
using CMSMicroservice.Application.UserOrderCQ.Commands.DeleteUserOrder;
|
using CMSMicroservice.Application.UserOrderCQ.Commands.DeleteUserOrder;
|
||||||
using CMSMicroservice.Application.UserOrderCQ.Queries.GetUserOrder;
|
using CMSMicroservice.Application.UserOrderCQ.Queries.GetUserOrder;
|
||||||
using CMSMicroservice.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter;
|
using CMSMicroservice.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter;
|
||||||
|
using CMSMicroservice.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
|
||||||
namespace CMSMicroservice.WebApi.Services;
|
namespace CMSMicroservice.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user