From fc4f6defb32ad6f03bd4622e51a5dbabb8c12fc8 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Fri, 28 Nov 2025 01:39:05 +0330 Subject: [PATCH 1/2] Update user order proto and filter model --- .../GetAllUserOrderByFilterQuery.cs | 18 +++++++-------- .../GetAllUserOrderByFilterResponseDto.cs | 22 +++++++++---------- .../GetUserOrder/GetUserOrderResponseDto.cs | 22 +++++++++---------- .../FrontOffice.BFF.Domain.csproj | 2 +- .../Protos/userorder.proto | 10 ++++----- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQuery.cs b/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQuery.cs index e035f1d..215c6a7 100644 --- a/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQuery.cs +++ b/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQuery.cs @@ -10,20 +10,20 @@ public record GetAllUserOrderByFilterQuery : IRequest? FactorDetails { get; set; } } public class GetAllUserOrderByFilterResponseModelFactorDetail diff --git a/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderResponseDto.cs b/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderResponseDto.cs index ee1abc1..ad4c4c0 100644 --- a/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderResponseDto.cs +++ b/src/FrontOffice.BFF.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderResponseDto.cs @@ -3,27 +3,27 @@ using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; namespace FrontOffice.BFF.Application.UserOrderCQ.Queries.GetUserOrder; public class GetUserOrderResponseDto { - //شناسه + //شناسه public long Id { get; set; } - //قیمت + //قیمت public long Amount { get; set; } - //شناسه پکیج + //شناسه پکیج public long PackageId { get; set; } - //شناسه تراکنش + //شناسه تراکنش public long? TransactionId { get; set; } - //وضعیت پرداخت + //وضعیت پرداخت public PaymentStatus PaymentStatus { get; set; } - //تاریخ پرداخت + //تاریخ پرداخت public DateTime? PaymentDate { get; set; } - //شناسه کاربر + //شناسه کاربر public long UserId { get; set; } - //شناسه آدرس کاربر + //شناسه آدرس کاربر public long UserAddressId { get; set; } - // + // public PaymentMethod? PaymentMethod { get; set; } - // + // public string? UserAddressText { get; set; } - // + // public List? FactorDetails { get; set; } }public class GetUserOrderResponseFactorDetail diff --git a/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj b/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj index 83ef7de..9f3f3bc 100644 --- a/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj +++ b/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Protobufs/FrontOffice.BFF.UserOrder.Protobuf/Protos/userorder.proto b/src/Protobufs/FrontOffice.BFF.UserOrder.Protobuf/Protos/userorder.proto index 32d5f91..a80a129 100644 --- a/src/Protobufs/FrontOffice.BFF.UserOrder.Protobuf/Protos/userorder.proto +++ b/src/Protobufs/FrontOffice.BFF.UserOrder.Protobuf/Protos/userorder.proto @@ -81,14 +81,14 @@ message GetUserOrderResponse int64 amount = 2; int64 package_id = 3; google.protobuf.Int64Value transaction_id = 4; - oneof PaymentStatus_item + oneof PaymentStatus_item { PaymentStatus payment_status = 5; } google.protobuf.Timestamp payment_date = 6; int64 user_id = 7; int64 user_address_id = 8; - oneof PaymentMethod_item + oneof PaymentMethod_item { PaymentMethod payment_method = 9; } @@ -124,7 +124,7 @@ message GetAllUserOrderByFilterRequest message GetAllUserOrderByFilterFilter { google.protobuf.Int64Value id = 1; - google.protobuf.Int64Value price = 2; + google.protobuf.Int64Value amount = 2; google.protobuf.Int64Value package_id = 3; google.protobuf.Int64Value transaction_id = 4; google.protobuf.BoolValue payment_status = 5; @@ -143,14 +143,14 @@ message GetAllUserOrderByFilterResponseModel int64 amount = 2; int64 package_id = 3; google.protobuf.Int64Value transaction_id = 4; - oneof PaymentStatus_item + oneof PaymentStatus_item { PaymentStatus payment_status = 5; } google.protobuf.Timestamp payment_date = 6; int64 user_id = 7; int64 user_address_id = 8; - oneof PaymentMethod_item + oneof PaymentMethod_item { PaymentMethod payment_method = 9; } From c4826fe9d710271c9ad1cacf60746cfa428e1022 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Fri, 28 Nov 2025 07:57:19 +0330 Subject: [PATCH 2/2] Add product gallery support to products query --- .../Interfaces/IApplicationContractContext.cs | 4 ++ .../GetProducts/GetProductsQueryHandler.cs | 44 ++++++++++++++++++- .../GetProducts/GetProductsResponseDto.cs | 12 +++++ .../Services/ApplicationContractContext.cs | 4 ++ .../Protos/products.proto | 10 +++++ 5 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs b/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs index aa15953..b9eacbd 100644 --- a/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs +++ b/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs @@ -1,6 +1,8 @@ using CMSMicroservice.Protobuf.Protos.OtpToken; using CMSMicroservice.Protobuf.Protos.Package; using CMSMicroservice.Protobuf.Protos.Products; +using CMSMicroservice.Protobuf.Protos.ProductGallerys; +using CMSMicroservice.Protobuf.Protos.ProductImages; using CMSMicroservice.Protobuf.Protos.User; using CMSMicroservice.Protobuf.Protos.UserAddress; using CMSMicroservice.Protobuf.Protos.UserCarts; @@ -23,6 +25,8 @@ public interface IApplicationContractContext #region CMS PackageContract.PackageContractClient Package { get; } ProductsContract.ProductsContractClient Product { get; } + ProductGallerysContract.ProductGallerysContractClient ProductGallerys { get; } + ProductImagesContract.ProductImagesContractClient ProductImages { get; } UserCartsContract.UserCartsContractClient UserCart { get; } UserContract.UserContractClient User { get; } UserContractContract.UserContractContractClient UserContract { get; } diff --git a/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs b/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs index a2147ae..e176bb5 100644 --- a/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs +++ b/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs @@ -1,4 +1,6 @@ using CMSMicroservice.Protobuf.Protos.Products; +using CMSMicroservice.Protobuf.Protos.ProductGallerys; +using CMSMicroservice.Protobuf.Protos.ProductImages; namespace FrontOffice.BFF.Application.ProductsCQ.Queries.GetProducts; public class GetProductsQueryHandler : IRequestHandler @@ -15,6 +17,46 @@ public class GetProductsQueryHandler : IRequestHandler(), cancellationToken: cancellationToken); - return response ==null? throw new NotFoundException(nameof(ProductsContract.ProductsContractClient), request.Id):response.Adapt(); + if (response == null) + { + throw new NotFoundException(nameof(ProductsContract.ProductsContractClient), request.Id); + } + + var dto = response.Adapt(); + + var galleryResponse = await _context.ProductGallerys.GetAllProductGallerysByFilterAsync( + new GetAllProductGallerysByFilterRequest + { + Filter = new GetAllProductGallerysByFilterFilter() + }, cancellationToken: cancellationToken); + + var relatedItems = galleryResponse?.Models?.Where(x => x.ProductId == request.Id).ToList(); + + if (relatedItems != null && relatedItems.Count > 0) + { + foreach (var item in relatedItems) + { + var image = await _context.ProductImages.GetProductImagesAsync(new GetProductImagesRequest + { + Id = item.ProductImageId + }, cancellationToken: cancellationToken); + + if (image == null) + { + continue; + } + + dto.Gallery.Add(new ProductGalleryItemDto + { + ProductGalleryId = item.Id, + ProductImageId = item.ProductImageId, + Title = image.Title ?? string.Empty, + ImagePath = image.ImagePath ?? string.Empty, + ImageThumbnailPath = image.ImageThumbnailPath ?? string.Empty + }); + } + } + + return dto; } } diff --git a/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsResponseDto.cs b/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsResponseDto.cs index bedd234..41bd430 100644 --- a/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsResponseDto.cs +++ b/src/FrontOffice.BFF.Application/ProductsCQ/Queries/GetProducts/GetProductsResponseDto.cs @@ -27,5 +27,17 @@ public class GetProductsResponseDto public int ViewCount { get; set; } // public int RemainingCount { get; set; } + // + public List Gallery { get; set; } = new(); + +} + +public class ProductGalleryItemDto +{ + public long ProductGalleryId { get; set; } + public long ProductImageId { get; set; } + public string Title { get; set; } = string.Empty; + public string ImagePath { get; set; } = string.Empty; + public string ImageThumbnailPath { get; set; } = string.Empty; } \ No newline at end of file diff --git a/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs b/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs index 8cb69f8..c325be8 100644 --- a/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs +++ b/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs @@ -1,6 +1,8 @@ using CMSMicroservice.Protobuf.Protos.OtpToken; using CMSMicroservice.Protobuf.Protos.Package; using CMSMicroservice.Protobuf.Protos.Products; +using CMSMicroservice.Protobuf.Protos.ProductGallerys; +using CMSMicroservice.Protobuf.Protos.ProductImages; using CMSMicroservice.Protobuf.Protos.User; using CMSMicroservice.Protobuf.Protos.UserAddress; using CMSMicroservice.Protobuf.Protos.UserCarts; @@ -47,6 +49,8 @@ public class ApplicationContractContext : IApplicationContractContext #region CMS public PackageContract.PackageContractClient Package => GetService(); public ProductsContract.ProductsContractClient Product => GetService(); + public ProductGallerysContract.ProductGallerysContractClient ProductGallerys => GetService(); + public ProductImagesContract.ProductImagesContractClient ProductImages => GetService(); public UserCartsContract.UserCartsContractClient UserCart => GetService(); public UserContract.UserContractClient User => GetService(); diff --git a/src/Protobufs/FrontOffice.BFF.Products.Protobuf/Protos/products.proto b/src/Protobufs/FrontOffice.BFF.Products.Protobuf/Protos/products.proto index c138535..6863411 100644 --- a/src/Protobufs/FrontOffice.BFF.Products.Protobuf/Protos/products.proto +++ b/src/Protobufs/FrontOffice.BFF.Products.Protobuf/Protos/products.proto @@ -44,6 +44,7 @@ message GetProductsResponse int32 sale_count = 11; int32 view_count = 12; int32 remaining_count = 13; + repeated ProductGalleryItem gallery = 14; } message GetAllProductsByFilterRequest { @@ -84,6 +85,15 @@ message GetAllProductsByFilterResponseModel int32 remaining_count = 13; } +message ProductGalleryItem +{ + int64 product_gallery_id = 1; + int64 product_image_id = 2; + string title = 3; + string image_path = 4; + string image_thumbnail_path = 5; +} + message PaginationState { int32 page_number = 1;