Merge branch 'main' into stage
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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<GetProductsQuery, GetProductsResponseDto>
|
||||
@@ -15,6 +17,46 @@ public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, GetProd
|
||||
{
|
||||
var response = await _context.Product.GetProductsAsync(request.Adapt<GetProductsRequest>(), cancellationToken: cancellationToken);
|
||||
|
||||
return response ==null? throw new NotFoundException(nameof(ProductsContract.ProductsContractClient), request.Id):response.Adapt<GetProductsResponseDto>();
|
||||
if (response == null)
|
||||
{
|
||||
throw new NotFoundException(nameof(ProductsContract.ProductsContractClient), request.Id);
|
||||
}
|
||||
|
||||
var dto = response.Adapt<GetProductsResponseDto>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,17 @@ public class GetProductsResponseDto
|
||||
public int ViewCount { get; set; }
|
||||
//
|
||||
public int RemainingCount { get; set; }
|
||||
//
|
||||
public List<ProductGalleryItemDto> 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;
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public record GetAllUserOrderByFilterQuery : IRequest<GetAllUserOrderByFilterRes
|
||||
//شناسه
|
||||
public long? Id { get; set; }
|
||||
//قیمت
|
||||
public long? Price { get; set; }
|
||||
public long? Amount { get; set; }
|
||||
//شناسه پکیج
|
||||
public long? PackageId { get; set; }
|
||||
//شناسه تراکنش
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" />
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.128" />
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.134" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
|
||||
@@ -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<PackageContract.PackageContractClient>();
|
||||
public ProductsContract.ProductsContractClient Product => GetService<ProductsContract.ProductsContractClient>();
|
||||
public ProductGallerysContract.ProductGallerysContractClient ProductGallerys => GetService<ProductGallerysContract.ProductGallerysContractClient>();
|
||||
public ProductImagesContract.ProductImagesContractClient ProductImages => GetService<ProductImagesContract.ProductImagesContractClient>();
|
||||
public UserCartsContract.UserCartsContractClient UserCart => GetService<UserCartsContract.UserCartsContractClient>();
|
||||
|
||||
public UserContract.UserContractClient User => GetService<UserContract.UserContractClient>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user