Browse Source

Use IProductRepository in ProductViewAppService.

pull/119/head 2.2.7
gdlcf88 4 years ago
parent
commit
f3e828e8d3
  1. 2
      common.props
  2. 15
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductViewAppService.cs
  3. 2
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs

2
common.props

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>2.2.6</Version>
<Version>2.2.7</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>

15
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductViewAppService.cs

@ -20,18 +20,18 @@ namespace EasyAbp.EShop.Products.Products
private readonly IProductViewCacheKeyProvider _productViewCacheKeyProvider;
private readonly IDistributedCache<ProductViewCacheItem> _cache;
private readonly IProductAppService _productAppService;
private readonly IProductRepository _productRepository;
private readonly IProductViewRepository _repository;
public ProductViewAppService(
IProductViewCacheKeyProvider productViewCacheKeyProvider,
IDistributedCache<ProductViewCacheItem> cache,
IProductAppService productAppService,
IProductRepository productRepository,
IProductViewRepository repository) : base(repository)
{
_productViewCacheKeyProvider = productViewCacheKeyProvider;
_cache = cache;
_productAppService = productAppService;
_productRepository = productRepository;
_repository = repository;
}
@ -96,18 +96,15 @@ namespace EasyAbp.EShop.Products.Products
protected virtual async Task BuildStoreProductViewsAsync(Guid storeId)
{
var resultDto = await _productAppService.GetListAsync(new GetProductListInput
{
StoreId = storeId
});
var products = await _productRepository.GetListAsync(x => x.StoreId == storeId);
using var uow = UnitOfWorkManager.Begin(true, true);
await _repository.DeleteAsync(x => x.StoreId == storeId, true);
foreach (var product in resultDto.Items)
foreach (var product in products)
{
await _repository.InsertAsync(ObjectMapper.Map<ProductDto, ProductView>(product));
await _repository.InsertAsync(ObjectMapper.Map<Product, ProductView>(product));
}
await uow.CompleteAsync();

2
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs

@ -67,7 +67,7 @@ namespace EasyAbp.EShop.Products
CreateMap<ProductDetailHistory, ProductDetailHistoryDto>();
CreateMap<ProductInventory, ProductInventoryDto>();
CreateMap<ProductView, ProductViewDto>();
CreateMap<ProductDto, ProductView>(MemberList.Destination);
CreateMap<Product, ProductView>(MemberList.Destination);
}
}
}

Loading…
Cancel
Save