Browse Source

Migrate object mapping from AutoMapper to Mapperly (#299)

* Migrate object mapping from AutoMapper to Mapperly

Migrates the object-to-object mapping of every EShop module, plugin, the
integration package and the sample from AutoMapper to Mapperly, following
the ABP AutoMapper to Mapperly migration guide.

- Replace Volo.Abp.AutoMapper with Volo.Abp.Mapperly (and add a direct
  Riok.Mapperly reference to every project that defines a mapper).
- Swap AbpAutoMapperModule -> AbpMapperlyModule and
  AddAutoMapperObjectMapper -> AddMapperlyObjectMapper; drop the
  AbpAutoMapperOptions configuration and the AutoMapper profile classes.
- Convert entity -> DTO/ETO and DTO <-> view-model Profile mappings into
  Mapperly MapperBase<,> mappers.
- Build/update aggregates with protected setters explicitly (MapToEntityAsync
  overrides, domain Update methods, manual construction in the payment/refund
  synchronizers) instead of relying on reflection-based mapping.
- Set ObjectMapperContext on the application services that relied on the
  global AutoMapper configuration.
- Add application-layer tests covering representative entity -> DTO maps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Fix sample proj's abp version

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
dev
Super 3 weeks ago
committed by GitHub
parent
commit
cf4c3461c4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp.EShop.Application.csproj
  2. 14
      integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationAutoMapperProfile.cs
  3. 10
      integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationModule.cs
  4. 14
      integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebAutoMapperProfile.cs
  5. 10
      integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebModule.cs
  6. 2
      integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EasyAbp.EShop.Web.csproj
  7. 3
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp.EShop.Orders.Application.csproj
  8. 10
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/EShopOrdersApplicationModule.cs
  9. 21
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs
  10. 39
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationMapperlyMappers.cs
  11. 3
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp.EShop.Orders.Domain.csproj
  12. 11
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/EShopOrdersDomainModule.cs
  13. 19
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs
  14. 38
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainMapperlyMappers.cs
  15. 10
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EShopOrdersWebModule.cs
  16. 2
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EasyAbp.EShop.Orders.Web.csproj
  17. 16
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/OrdersWebAutoMapperProfile.cs
  18. 32
      modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderExtraFeeMapperlyTests.cs
  19. 3
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp.EShop.Payments.Application.csproj
  20. 10
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/EShopPaymentsApplicationModule.cs
  21. 23
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationAutoMapperProfile.cs
  22. 49
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationMapperlyMappers.cs
  23. 3
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp.EShop.Payments.Domain.csproj
  24. 11
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/EShopPaymentsDomainModule.cs
  25. 53
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs
  26. 35
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentItem.cs
  27. 60
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentSynchronizer.cs
  28. 39
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainAutoMapperProfile.cs
  29. 55
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainMapperlyMappers.cs
  30. 44
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs
  31. 28
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItem.cs
  32. 2
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs
  33. 2
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderLine.cs
  34. 58
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs
  35. 10
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EShopPaymentsWebModule.cs
  36. 2
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EasyAbp.EShop.Payments.Web.csproj
  37. 15
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/PaymentsWebAutoMapperProfile.cs
  38. 33
      modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/PaymentItemMapperlyTests.cs
  39. 2
      modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp.EShop.Plugins.Application.csproj
  40. 10
      modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/EShopPluginsApplicationModule.cs
  41. 14
      modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/PluginsApplicationAutoMapperProfile.cs
  42. 10
      modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EShopPluginsWebModule.cs
  43. 2
      modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EasyAbp.EShop.Plugins.Web.csproj
  44. 14
      modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/PluginsWebAutoMapperProfile.cs
  45. 3
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp.EShop.Products.Application.csproj
  46. 15
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/EShopProductsApplicationModule.cs
  47. 2
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductCategories/ProductCategoryAppService.cs
  48. 18
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductDetails/ProductDetailAppService.cs
  49. 2
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs
  50. 2
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductViewAppService.cs
  51. 50
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs
  52. 138
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationMapperlyMappers.cs
  53. 3
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp.EShop.Products.Domain.csproj
  54. 11
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/EShopProductsDomainModule.cs
  55. 6
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductDetails/ProductDetail.cs
  56. 19
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainAutoMapperProfile.cs
  57. 38
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainMapperlyMappers.cs
  58. 10
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EShopProductsWebModule.cs
  59. 3
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EasyAbp.EShop.Products.Web.csproj
  60. 82
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebAutoMapperProfile.cs
  61. 186
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebMapperlyMappers.cs
  62. 32
      modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Application.Tests/ProductDetails/ProductDetailMapperlyTests.cs
  63. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp.EShop.Stores.Application.Shared.csproj
  64. 4
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp/EShop/Stores/EShopStoresApplicationSharedModule.cs
  65. 3
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp.EShop.Stores.Application.csproj
  66. 10
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/EShopStoresApplicationModule.cs
  67. 20
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerAppService.cs
  68. 19
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Stores/StoreAppService.cs
  69. 31
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs
  70. 37
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationMapperlyMappers.cs
  71. 22
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Transactions/TransactionAppService.cs
  72. 6
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwner.cs
  73. 5
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/Store.cs
  74. 16
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/Transaction.cs
  75. 10
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EShopStoresWebModule.cs
  76. 3
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj
  77. 33
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs
  78. 65
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebMapperlyMappers.cs
  79. 30
      modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Application.Tests/Stores/StoreMapperlyTests.cs
  80. 3
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp.EShop.Plugins.Baskets.Application.csproj
  81. 17
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationAutoMapperProfile.cs
  82. 15
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationMapperlyMappers.cs
  83. 10
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/EShopPluginsBasketsApplicationModule.cs
  84. 26
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebAutoMapperProfile.cs
  85. 47
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebMapperlyMappers.cs
  86. 10
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EShopPluginsBasketsWebModule.cs
  87. 3
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EasyAbp.EShop.Plugins.Baskets.Web.csproj
  88. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp.EShop.Plugins.Booking.Application.csproj
  89. 33
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationAutoMapperProfile.cs
  90. 64
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationMapperlyMappers.cs
  91. 10
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/EShopPluginsBookingApplicationModule.cs
  92. 14
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStoreAppService.cs
  93. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryAppService.cs
  94. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetAppService.cs
  95. 8
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStore.cs
  96. 6
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs
  97. 6
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs
  98. 39
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebAutoMapperProfile.cs
  99. 125
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebMapperlyMappers.cs
  100. 10
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EShopPluginsBookingWebModule.cs

2
integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp.EShop.Application.csproj

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\..\modules\EasyAbp.EShop.Orders\src\EasyAbp.EShop.Orders.Application\EasyAbp.EShop.Orders.Application.csproj" />
<ProjectReference Include="..\..\..\..\modules\EasyAbp.EShop.Payments\src\EasyAbp.EShop.Payments.Application\EasyAbp.EShop.Payments.Application.csproj" />

14
integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationAutoMapperProfile.cs

@ -1,14 +0,0 @@
using AutoMapper;
namespace EasyAbp.EShop
{
public class EShopApplicationAutoMapperProfile : Profile
{
public EShopApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

10
integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationModule.cs

@ -4,7 +4,7 @@ using EasyAbp.EShop.Payments;
using EasyAbp.EShop.Products;
using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -14,7 +14,7 @@ namespace EasyAbp.EShop
typeof(EShopDomainModule),
typeof(EShopApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(EShopOrdersApplicationModule),
typeof(EShopPaymentsApplicationModule),
typeof(EShopPluginsApplicationModule),
@ -25,11 +25,7 @@ namespace EasyAbp.EShop
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopApplicationModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopApplicationModule>();
}
}
}

14
integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebAutoMapperProfile.cs

@ -1,14 +0,0 @@
using AutoMapper;
namespace EasyAbp.EShop.Web
{
public class EShopWebAutoMapperProfile : Profile
{
public EShopWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

10
integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebModule.cs

@ -9,7 +9,7 @@ using EasyAbp.EShop.Stores.Web;
using EasyAbp.EShop.Web.Menus;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -19,7 +19,7 @@ namespace EasyAbp.EShop.Web
[DependsOn(
typeof(EShopApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(EShopOrdersWebModule),
typeof(EShopPaymentsWebModule),
typeof(EShopPluginsWebModule),
@ -53,11 +53,7 @@ namespace EasyAbp.EShop.Web
options.FileSets.AddEmbedded<EShopWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopWebModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopWebModule>();
Configure<RazorPagesOptions>(options =>
{

2
integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EasyAbp.EShop.Web.csproj

@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\..\modules\EasyAbp.EShop.Orders\src\EasyAbp.EShop.Orders.Web\EasyAbp.EShop.Orders.Web.csproj" />
<ProjectReference Include="..\..\..\..\modules\EasyAbp.EShop.Payments\src\EasyAbp.EShop.Payments.Web\EasyAbp.EShop.Payments.Web.csproj" />

3
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp.EShop.Orders.Application.csproj

@ -8,7 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Products\src\EasyAbp.EShop.Products.Application.Contracts\EasyAbp.EShop.Products.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Stores\src\EasyAbp.EShop.Stores.Application.Shared\EasyAbp.EShop.Stores.Application.Shared.csproj" />

10
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/EShopOrdersApplicationModule.cs

@ -3,7 +3,7 @@ using EasyAbp.EShop.Products;
using EasyAbp.EShop.Stores;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -16,7 +16,7 @@ namespace EasyAbp.EShop.Orders
typeof(EShopStoresDomainSharedModule),
typeof(EShopStoresApplicationSharedModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopOrdersApplicationModule : AbpModule
{
@ -28,11 +28,7 @@ namespace EasyAbp.EShop.Orders
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopOrdersApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopOrdersApplicationModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopOrdersApplicationModule>();
}
}
}

21
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs

@ -1,21 +0,0 @@
using EasyAbp.EShop.Orders.Orders;
using EasyAbp.EShop.Orders.Orders.Dtos;
using AutoMapper;
using Volo.Abp.ObjectExtending;
namespace EasyAbp.EShop.Orders
{
public class OrdersApplicationAutoMapperProfile : Profile
{
public OrdersApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Order, OrderDto>();
CreateMap<OrderLine, OrderLineDto>();
CreateMap<OrderDiscount, OrderDiscountDto>();
CreateMap<OrderExtraFee, OrderExtraFeeDto>();
}
}
}

39
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationMapperlyMappers.cs

@ -0,0 +1,39 @@
using EasyAbp.EShop.Orders.Orders;
using EasyAbp.EShop.Orders.Orders.Dtos;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Orders
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderToOrderDtoMapper : MapperBase<Order, OrderDto>
{
public override partial OrderDto Map(Order source);
public override partial void Map(Order source, OrderDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderLineToOrderLineDtoMapper : MapperBase<OrderLine, OrderLineDto>
{
public override partial OrderLineDto Map(OrderLine source);
public override partial void Map(OrderLine source, OrderLineDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderDiscountToOrderDiscountDtoMapper : MapperBase<OrderDiscount, OrderDiscountDto>
{
public override partial OrderDiscountDto Map(OrderDiscount source);
public override partial void Map(OrderDiscount source, OrderDiscountDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderExtraFeeToOrderExtraFeeDtoMapper : MapperBase<OrderExtraFee, OrderExtraFeeDto>
{
public override partial OrderExtraFeeDto Map(OrderExtraFee source);
public override partial void Map(OrderExtraFee source, OrderExtraFeeDto destination);
}
}

3
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp.EShop.Orders.Domain.csproj

@ -15,7 +15,8 @@
<ItemGroup>
<PackageReference Include="NodaMoney" Version="$(NodaMoneyVersion)" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Payments\src\EasyAbp.EShop.Payments.Domain.Shared\EasyAbp.EShop.Payments.Domain.Shared.csproj" />

11
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/EShopOrdersDomainModule.cs

@ -3,7 +3,7 @@ using EasyAbp.EShop.Payments;
using EasyAbp.EShop.Products;
using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
@ -12,7 +12,7 @@ using Volo.Abp.Modularity;
namespace EasyAbp.EShop.Orders
{
[DependsOn(
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpBackgroundJobsAbstractionsModule),
typeof(EShopPaymentsDomainSharedModule),
typeof(EShopProductsDomainSharedModule),
@ -22,12 +22,7 @@ namespace EasyAbp.EShop.Orders
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopOrdersDomainModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<OrdersDomainAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopOrdersDomainModule>();
Configure<AbpDistributedEntityEventOptions>(options =>
{

19
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs

@ -1,19 +0,0 @@
using EasyAbp.EShop.Orders.Orders;
using AutoMapper;
namespace EasyAbp.EShop.Orders
{
public class OrdersDomainAutoMapperProfile : Profile
{
public OrdersDomainAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Order, OrderEto>();
CreateMap<OrderLine, OrderLineEto>();
CreateMap<OrderDiscount, OrderDiscountEto>();
CreateMap<OrderExtraFee, OrderExtraFeeEto>();
}
}
}

38
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainMapperlyMappers.cs

@ -0,0 +1,38 @@
using EasyAbp.EShop.Orders.Orders;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Orders
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderToOrderEtoMapper : MapperBase<Order, OrderEto>
{
public override partial OrderEto Map(Order source);
public override partial void Map(Order source, OrderEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderLineToOrderLineEtoMapper : MapperBase<OrderLine, OrderLineEto>
{
public override partial OrderLineEto Map(OrderLine source);
public override partial void Map(OrderLine source, OrderLineEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderDiscountToOrderDiscountEtoMapper : MapperBase<OrderDiscount, OrderDiscountEto>
{
public override partial OrderDiscountEto Map(OrderDiscount source);
public override partial void Map(OrderDiscount source, OrderDiscountEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class OrderExtraFeeToOrderExtraFeeEtoMapper : MapperBase<OrderExtraFee, OrderExtraFeeEto>
{
public override partial OrderExtraFeeEto Map(OrderExtraFee source);
public override partial void Map(OrderExtraFee source, OrderExtraFeeEto destination);
}
}

10
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EShopOrdersWebModule.cs

@ -5,7 +5,7 @@ using EasyAbp.EShop.Orders.Web.Menus;
using EasyAbp.EShop.Stores;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -16,7 +16,7 @@ namespace EasyAbp.EShop.Orders.Web
typeof(EShopOrdersApplicationContractsModule),
typeof(EShopStoresWebSharedModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopOrdersWebModule : AbpModule
{
@ -45,11 +45,7 @@ namespace EasyAbp.EShop.Orders.Web
options.FileSets.AddEmbedded<EShopOrdersWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopOrdersWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopOrdersWebModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopOrdersWebModule>();
Configure<RazorPagesOptions>(options =>
{

2
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EasyAbp.EShop.Orders.Web.csproj

@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
</ItemGroup>

16
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/OrdersWebAutoMapperProfile.cs

@ -1,16 +0,0 @@
using EasyAbp.EShop.Orders.Orders.Dtos;
using AutoMapper;
using Volo.Abp.ObjectExtending;
namespace EasyAbp.EShop.Orders.Web
{
public class OrdersWebAutoMapperProfile : Profile
{
public OrdersWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

32
modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderExtraFeeMapperlyTests.cs

@ -0,0 +1,32 @@
using System;
using EasyAbp.EShop.Orders.Orders.Dtos;
using Shouldly;
using Volo.Abp.ObjectMapping;
using Xunit;
namespace EasyAbp.EShop.Orders.Orders
{
public class OrderExtraFeeMapperlyTests : OrdersApplicationTestBase
{
private readonly IObjectMapper<EShopOrdersApplicationModule> _objectMapper;
public OrderExtraFeeMapperlyTests()
{
_objectMapper = GetRequiredService<IObjectMapper<EShopOrdersApplicationModule>>();
}
[Fact]
public void Should_Map_OrderExtraFee_To_OrderExtraFeeDto()
{
var entity = new OrderExtraFee(Guid.NewGuid(), "Shipping", "shipping-key", "Shipping Fee", 12.5m);
var dto = _objectMapper.Map<OrderExtraFee, OrderExtraFeeDto>(entity);
dto.ShouldNotBeNull();
dto.Name.ShouldBe("Shipping");
dto.Key.ShouldBe("shipping-key");
dto.DisplayName.ShouldBe("Shipping Fee");
dto.Fee.ShouldBe(12.5m);
}
}
}

3
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp.EShop.Payments.Application.csproj

@ -8,7 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Orders\src\EasyAbp.EShop.Orders.Application.Contracts\EasyAbp.EShop.Orders.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Stores\src\EasyAbp.EShop.Stores.Application.Shared\EasyAbp.EShop.Stores.Application.Shared.csproj" />

10
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/EShopPaymentsApplicationModule.cs

@ -2,7 +2,7 @@
using EasyAbp.EShop.Stores;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -13,7 +13,7 @@ namespace EasyAbp.EShop.Payments
typeof(EShopPaymentsApplicationContractsModule),
typeof(EShopStoresApplicationSharedModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPaymentsApplicationModule : AbpModule
{
@ -24,11 +24,7 @@ namespace EasyAbp.EShop.Payments
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopPaymentsApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPaymentsApplicationModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPaymentsApplicationModule>();
}
}
}

23
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationAutoMapperProfile.cs

@ -1,23 +0,0 @@
using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.Payments.Dtos;
using EasyAbp.EShop.Payments.Refunds;
using EasyAbp.EShop.Payments.Refunds.Dtos;
using AutoMapper;
namespace EasyAbp.EShop.Payments
{
public class PaymentsApplicationAutoMapperProfile : Profile
{
public PaymentsApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Payment, PaymentDto>();
CreateMap<PaymentItem, PaymentItemDto>();
CreateMap<Refund, RefundDto>();
CreateMap<RefundItem, RefundItemDto>();
CreateMap<RefundItemOrderLine, RefundItemOrderLineDto>();
}
}
}

49
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationMapperlyMappers.cs

@ -0,0 +1,49 @@
using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.Payments.Dtos;
using EasyAbp.EShop.Payments.Refunds;
using EasyAbp.EShop.Payments.Refunds.Dtos;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Payments
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class PaymentToPaymentDtoMapper : MapperBase<Payment, PaymentDto>
{
public override partial PaymentDto Map(Payment source);
public override partial void Map(Payment source, PaymentDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class PaymentItemToPaymentItemDtoMapper : MapperBase<PaymentItem, PaymentItemDto>
{
public override partial PaymentItemDto Map(PaymentItem source);
public override partial void Map(PaymentItem source, PaymentItemDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class RefundToRefundDtoMapper : MapperBase<Refund, RefundDto>
{
public override partial RefundDto Map(Refund source);
public override partial void Map(Refund source, RefundDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class RefundItemToRefundItemDtoMapper : MapperBase<RefundItem, RefundItemDto>
{
public override partial RefundItemDto Map(RefundItem source);
public override partial void Map(RefundItem source, RefundItemDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class RefundItemOrderLineToRefundItemOrderLineDtoMapper : MapperBase<RefundItemOrderLine, RefundItemOrderLineDto>
{
public override partial RefundItemOrderLineDto Map(RefundItemOrderLine source);
public override partial void Map(RefundItemOrderLine source, RefundItemOrderLineDto destination);
}
}

3
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp.EShop.Payments.Domain.csproj

@ -8,7 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Stores\src\EasyAbp.EShop.Stores.Domain.Shared\EasyAbp.EShop.Stores.Domain.Shared.csproj" />
<ProjectReference Include="..\EasyAbp.EShop.Payments.Domain.Shared\EasyAbp.EShop.Payments.Domain.Shared.csproj" />

11
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/EShopPaymentsDomainModule.cs

@ -3,14 +3,14 @@ using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.Refunds;
using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.Modularity;
namespace EasyAbp.EShop.Payments
{
[DependsOn(
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(EShopPaymentsDomainSharedModule),
typeof(EShopStoresDomainSharedModule)
)]
@ -32,12 +32,7 @@ namespace EasyAbp.EShop.Payments
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopPaymentsDomainModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<PaymentsDomainAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPaymentsDomainModule>();
}
}
}

53
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs

@ -50,6 +50,59 @@ namespace EasyAbp.EShop.Payments.Payments
{
}
public Payment(
Guid id,
Guid? tenantId,
Guid userId,
[NotNull] string paymentMethod,
[CanBeNull] string payeeAccount,
[CanBeNull] string externalTradingCode,
[NotNull] string currency,
decimal originalPaymentAmount,
decimal paymentDiscount,
decimal actualPaymentAmount,
decimal refundAmount,
decimal pendingRefundAmount,
DateTime? completionTime,
DateTime? canceledTime,
DateTime creationTime) : base(id)
{
TenantId = tenantId;
UserId = userId;
CreationTime = creationTime;
Update(userId, paymentMethod, payeeAccount, externalTradingCode, currency, originalPaymentAmount,
paymentDiscount, actualPaymentAmount, refundAmount, pendingRefundAmount, completionTime, canceledTime);
}
public void Update(
Guid userId,
[NotNull] string paymentMethod,
[CanBeNull] string payeeAccount,
[CanBeNull] string externalTradingCode,
[NotNull] string currency,
decimal originalPaymentAmount,
decimal paymentDiscount,
decimal actualPaymentAmount,
decimal refundAmount,
decimal pendingRefundAmount,
DateTime? completionTime,
DateTime? canceledTime)
{
UserId = userId;
PaymentMethod = paymentMethod;
PayeeAccount = payeeAccount;
ExternalTradingCode = externalTradingCode;
Currency = currency;
OriginalPaymentAmount = originalPaymentAmount;
PaymentDiscount = paymentDiscount;
ActualPaymentAmount = actualPaymentAmount;
RefundAmount = refundAmount;
PendingRefundAmount = pendingRefundAmount;
CompletionTime = completionTime;
CanceledTime = canceledTime;
}
public void SetPaymentItems(List<PaymentItem> paymentItems)
{
PaymentItems = paymentItems;

35
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentItem.cs

@ -43,5 +43,40 @@ namespace EasyAbp.EShop.Payments.Payments
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
}
public PaymentItem(
Guid id,
[NotNull] string itemType,
string itemKey,
decimal originalPaymentAmount,
decimal paymentDiscount,
decimal actualPaymentAmount,
decimal refundAmount,
decimal pendingRefundAmount) : base(id)
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
Update(itemType, itemKey, originalPaymentAmount, paymentDiscount, actualPaymentAmount, refundAmount,
pendingRefundAmount);
}
public void Update(
[NotNull] string itemType,
string itemKey,
decimal originalPaymentAmount,
decimal paymentDiscount,
decimal actualPaymentAmount,
decimal refundAmount,
decimal pendingRefundAmount)
{
ItemType = itemType;
ItemKey = itemKey;
OriginalPaymentAmount = originalPaymentAmount;
PaymentDiscount = paymentDiscount;
ActualPaymentAmount = actualPaymentAmount;
RefundAmount = refundAmount;
PendingRefundAmount = pendingRefundAmount;
}
}
}

60
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentSynchronizer.cs

@ -54,11 +54,10 @@ namespace EasyAbp.EShop.Payments.Payments
return;
}
payment = _objectMapper.Map<PaymentEto, Payment>(eventData.Entity);
payment = CreatePayment(eventData.Entity);
payment.SetPaymentItems(eventData.Entity.PaymentItems.Select(CreatePaymentItem).ToList());
payment.SetPaymentItems(
_objectMapper.Map<List<PaymentItemEto>, List<PaymentItem>>(eventData.Entity.PaymentItems));
payment.PaymentItems.ForEach(FillPaymentItemStoreId);
await _paymentRepository.InsertAsync(payment, true);
@ -107,7 +106,7 @@ namespace EasyAbp.EShop.Payments.Payments
var publishCanceledEvent = eventData.Entity.CanceledTime.HasValue && !payment.CanceledTime.HasValue;
_objectMapper.Map(eventData.Entity, payment);
UpdatePayment(eventData.Entity, payment);
foreach (var etoItem in eventData.Entity.PaymentItems)
{
@ -115,7 +114,7 @@ namespace EasyAbp.EShop.Payments.Payments
if (item == null)
{
item = _objectMapper.Map<PaymentItemEto, PaymentItem>(etoItem);
item = CreatePaymentItem(etoItem);
FillPaymentItemStoreId(item);
@ -123,7 +122,7 @@ namespace EasyAbp.EShop.Payments.Payments
}
else
{
_objectMapper.Map(etoItem, item);
UpdatePaymentItem(etoItem, item);
}
}
@ -144,6 +143,53 @@ namespace EasyAbp.EShop.Payments.Payments
}
}
protected virtual Payment CreatePayment(PaymentEto eto)
{
var payment = new Payment(eto.Id, eto.TenantId, eto.UserId, eto.PaymentMethod, eto.PayeeAccount,
eto.ExternalTradingCode, eto.Currency, eto.OriginalPaymentAmount, eto.PaymentDiscount,
eto.ActualPaymentAmount, eto.RefundAmount, eto.PendingRefundAmount, eto.CompletionTime,
eto.CanceledTime, eto.CreationTime);
CopyExtraProperties(eto, payment);
return payment;
}
protected virtual void UpdatePayment(PaymentEto eto, Payment payment)
{
payment.Update(eto.UserId, eto.PaymentMethod, eto.PayeeAccount, eto.ExternalTradingCode, eto.Currency,
eto.OriginalPaymentAmount, eto.PaymentDiscount, eto.ActualPaymentAmount, eto.RefundAmount,
eto.PendingRefundAmount, eto.CompletionTime, eto.CanceledTime);
CopyExtraProperties(eto, payment);
}
protected virtual PaymentItem CreatePaymentItem(PaymentItemEto eto)
{
var item = new PaymentItem(eto.Id, eto.ItemType, eto.ItemKey, eto.OriginalPaymentAmount,
eto.PaymentDiscount, eto.ActualPaymentAmount, eto.RefundAmount, eto.PendingRefundAmount);
CopyExtraProperties(eto, item);
return item;
}
protected virtual void UpdatePaymentItem(PaymentItemEto eto, PaymentItem item)
{
item.Update(eto.ItemType, eto.ItemKey, eto.OriginalPaymentAmount, eto.PaymentDiscount,
eto.ActualPaymentAmount, eto.RefundAmount, eto.PendingRefundAmount);
CopyExtraProperties(eto, item);
}
protected virtual void CopyExtraProperties(IHasExtraProperties source, IHasExtraProperties destination)
{
foreach (var property in source.ExtraProperties)
{
destination.SetProperty(property.Key, property.Value);
}
}
protected virtual void FillPaymentItemStoreId(PaymentItem item)
{
var storeId = item.GetProperty<Guid?>(nameof(PaymentItem.StoreId));

39
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainAutoMapperProfile.cs

@ -1,39 +0,0 @@
using AutoMapper;
using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.Refunds;
using EasyAbp.PaymentService.Payments;
using EasyAbp.PaymentService.Refunds;
using Volo.Abp.AutoMapper;
namespace EasyAbp.EShop.Payments
{
public class PaymentsDomainAutoMapperProfile : Profile
{
public PaymentsDomainAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<PaymentEto, Payment>(MemberList.Source)
.ForSourceMember(x => x.PaymentItems, x => x.DoNotValidate())
.Ignore(x => x.PaymentItems);
CreateMap<PaymentItemEto, PaymentItem>(MemberList.Source)
.Ignore(x => x.StoreId);
CreateMap<RefundEto, Refund>(MemberList.Source)
.ForSourceMember(x => x.RefundItems, x => x.DoNotValidate())
.Ignore(x => x.RefundItems);
CreateMap<RefundItemEto, RefundItem>(MemberList.Source)
.Ignore(x => x.StoreId)
.Ignore(x => x.OrderId);
CreateMap<Payment, EShopPaymentEto>();
CreateMap<PaymentItem, EShopPaymentItemEto>();
CreateMap<Refund, EShopRefundEto>();
CreateMap<RefundItem, EShopRefundItemEto>();
CreateMap<RefundItemOrderLine, RefundItemOrderLineEto>();
CreateMap<RefundItemOrderExtraFee, RefundItemOrderExtraFeeEto>();
}
}
}

55
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainMapperlyMappers.cs

@ -0,0 +1,55 @@
using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.Refunds;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Payments
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class PaymentToEShopPaymentEtoMapper : MapperBase<Payment, EShopPaymentEto>
{
public override partial EShopPaymentEto Map(Payment source);
public override partial void Map(Payment source, EShopPaymentEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class PaymentItemToEShopPaymentItemEtoMapper : MapperBase<PaymentItem, EShopPaymentItemEto>
{
public override partial EShopPaymentItemEto Map(PaymentItem source);
public override partial void Map(PaymentItem source, EShopPaymentItemEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class RefundToEShopRefundEtoMapper : MapperBase<Refund, EShopRefundEto>
{
public override partial EShopRefundEto Map(Refund source);
public override partial void Map(Refund source, EShopRefundEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class RefundItemToEShopRefundItemEtoMapper : MapperBase<RefundItem, EShopRefundItemEto>
{
public override partial EShopRefundItemEto Map(RefundItem source);
public override partial void Map(RefundItem source, EShopRefundItemEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class RefundItemOrderLineToRefundItemOrderLineEtoMapper : MapperBase<RefundItemOrderLine, RefundItemOrderLineEto>
{
public override partial RefundItemOrderLineEto Map(RefundItemOrderLine source);
public override partial void Map(RefundItemOrderLine source, RefundItemOrderLineEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class RefundItemOrderExtraFeeToRefundItemOrderExtraFeeEtoMapper : MapperBase<RefundItemOrderExtraFee, RefundItemOrderExtraFeeEto>
{
public override partial RefundItemOrderExtraFeeEto Map(RefundItemOrderExtraFee source);
public override partial void Map(RefundItemOrderExtraFee source, RefundItemOrderExtraFeeEto destination);
}
}

44
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs

@ -47,6 +47,50 @@ namespace EasyAbp.EShop.Payments.Refunds
{
}
public Refund(
Guid id,
Guid? tenantId,
Guid paymentId,
[NotNull] string refundPaymentMethod,
[NotNull] string externalTradingCode,
[NotNull] string currency,
decimal refundAmount,
string displayReason,
[CanBeNull] string customerRemark,
[CanBeNull] string staffRemark,
DateTime? completedTime,
DateTime? canceledTime) : base(id)
{
TenantId = tenantId;
Update(paymentId, refundPaymentMethod, externalTradingCode, currency, refundAmount, displayReason,
customerRemark, staffRemark, completedTime, canceledTime);
}
public void Update(
Guid paymentId,
[NotNull] string refundPaymentMethod,
[NotNull] string externalTradingCode,
[NotNull] string currency,
decimal refundAmount,
string displayReason,
[CanBeNull] string customerRemark,
[CanBeNull] string staffRemark,
DateTime? completedTime,
DateTime? canceledTime)
{
PaymentId = paymentId;
RefundPaymentMethod = refundPaymentMethod;
ExternalTradingCode = externalTradingCode;
Currency = currency;
RefundAmount = refundAmount;
DisplayReason = displayReason;
CustomerRemark = customerRemark;
StaffRemark = staffRemark;
CompletedTime = completedTime;
CanceledTime = canceledTime;
}
public void SetRefundItems(List<RefundItem> refundItems)
{
RefundItems = refundItems;

28
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItem.cs

@ -41,6 +41,34 @@ namespace EasyAbp.EShop.Payments.Refunds
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
}
public RefundItem(
Guid id,
Guid paymentItemId,
decimal refundAmount,
string customerRemark,
string staffRemark) : base(id)
{
OrderLines = new List<RefundItemOrderLine>();
OrderExtraFees = new List<RefundItemOrderExtraFee>();
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
Update(paymentItemId, refundAmount, customerRemark, staffRemark);
}
public void Update(
Guid paymentItemId,
decimal refundAmount,
string customerRemark,
string staffRemark)
{
PaymentItemId = paymentItemId;
RefundAmount = refundAmount;
CustomerRemark = customerRemark;
StaffRemark = staffRemark;
}
public void SetStoreId(Guid storeId)
{
StoreId = storeId;

2
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs

@ -1,11 +1,9 @@
using System;
using AutoMapper;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
namespace EasyAbp.EShop.Payments.Refunds
{
[AutoMap(typeof(RefundItemOrderExtraFeeEto))]
public class RefundItemOrderExtraFee : Entity<Guid>
{
[NotNull]

2
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderLine.cs

@ -1,10 +1,8 @@
using System;
using AutoMapper;
using Volo.Abp.Domain.Entities;
namespace EasyAbp.EShop.Payments.Refunds
{
[AutoMap(typeof(RefundItemOrderLineEto))]
public class RefundItemOrderLine : Entity<Guid>
{
public virtual Guid OrderLineId { get; protected set; }

58
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs

@ -68,10 +68,9 @@ namespace EasyAbp.EShop.Payments.Refunds
return;
}
refund = _objectMapper.Map<RefundEto, Refund>(eventData.Entity);
refund = CreateRefund(eventData.Entity);
refund.SetRefundItems(
_objectMapper.Map<List<RefundItemEto>, List<RefundItem>>(eventData.Entity.RefundItems));
refund.SetRefundItems(eventData.Entity.RefundItems.Select(CreateRefundItem).ToList());
refund.RefundItems.ForEach(item =>
{
@ -107,7 +106,7 @@ namespace EasyAbp.EShop.Payments.Refunds
var publishRefundCompleted = eventData.Entity.CompletedTime.HasValue && !refund.CompletedTime.HasValue;
_objectMapper.Map(eventData.Entity, refund);
UpdateRefund(eventData.Entity, refund);
foreach (var etoItem in eventData.Entity.RefundItems)
{
@ -115,13 +114,13 @@ namespace EasyAbp.EShop.Payments.Refunds
if (item == null)
{
item = _objectMapper.Map<RefundItemEto, RefundItem>(etoItem);
item = CreateRefundItem(etoItem);
refund.RefundItems.Add(item);
}
else
{
_objectMapper.Map(etoItem, item);
UpdateRefundItem(etoItem, item);
}
FillRefundItemStoreId(item);
@ -208,6 +207,51 @@ namespace EasyAbp.EShop.Payments.Refunds
}
}
protected virtual Refund CreateRefund(RefundEto eto)
{
var refund = new Refund(eto.Id, eto.TenantId, eto.PaymentId, eto.RefundPaymentMethod,
eto.ExternalTradingCode, eto.Currency, eto.RefundAmount, eto.DisplayReason, eto.CustomerRemark,
eto.StaffRemark, eto.CompletedTime, eto.CanceledTime);
CopyExtraProperties(eto, refund);
return refund;
}
protected virtual void UpdateRefund(RefundEto eto, Refund refund)
{
refund.Update(eto.PaymentId, eto.RefundPaymentMethod, eto.ExternalTradingCode, eto.Currency,
eto.RefundAmount, eto.DisplayReason, eto.CustomerRemark, eto.StaffRemark, eto.CompletedTime,
eto.CanceledTime);
CopyExtraProperties(eto, refund);
}
protected virtual RefundItem CreateRefundItem(RefundItemEto eto)
{
var item = new RefundItem(eto.Id, eto.PaymentItemId, eto.RefundAmount, eto.CustomerRemark,
eto.StaffRemark);
CopyExtraProperties(eto, item);
return item;
}
protected virtual void UpdateRefundItem(RefundItemEto eto, RefundItem item)
{
item.Update(eto.PaymentItemId, eto.RefundAmount, eto.CustomerRemark, eto.StaffRemark);
CopyExtraProperties(eto, item);
}
protected virtual void CopyExtraProperties(IHasExtraProperties source, IHasExtraProperties destination)
{
foreach (var property in source.ExtraProperties)
{
destination.SetProperty(property.Key, property.Value);
}
}
protected virtual void FillRefundItemStoreId(RefundItem item)
{
var storeId = item.GetProperty<Guid?>(nameof(RefundItem.StoreId));

10
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EShopPaymentsWebModule.cs

@ -5,7 +5,7 @@ using EasyAbp.EShop.Payments.Web.Menus;
using EasyAbp.EShop.Stores;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -16,7 +16,7 @@ namespace EasyAbp.EShop.Payments.Web
typeof(EShopPaymentsApplicationContractsModule),
typeof(EShopStoresWebSharedModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPaymentsWebModule : AbpModule
{
@ -45,11 +45,7 @@ namespace EasyAbp.EShop.Payments.Web
options.FileSets.AddEmbedded<EShopPaymentsWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopPaymentsWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPaymentsWebModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPaymentsWebModule>();
Configure<RazorPagesOptions>(options =>
{

2
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EasyAbp.EShop.Payments.Web.csproj

@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
</ItemGroup>

15
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/PaymentsWebAutoMapperProfile.cs

@ -1,15 +0,0 @@
using EasyAbp.EShop.Payments.Refunds.Dtos;
using AutoMapper;
namespace EasyAbp.EShop.Payments.Web
{
public class PaymentsWebAutoMapperProfile : Profile
{
public PaymentsWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

33
modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/PaymentItemMapperlyTests.cs

@ -0,0 +1,33 @@
using System;
using EasyAbp.EShop.Payments.Payments.Dtos;
using Shouldly;
using Volo.Abp.ObjectMapping;
using Xunit;
namespace EasyAbp.EShop.Payments.Payments
{
public class PaymentItemMapperlyTests : PaymentsApplicationTestBase
{
private readonly IObjectMapper<EShopPaymentsApplicationModule> _objectMapper;
public PaymentItemMapperlyTests()
{
_objectMapper = GetRequiredService<IObjectMapper<EShopPaymentsApplicationModule>>();
}
[Fact]
public void Should_Map_PaymentItem_To_PaymentItemDto()
{
var entity = new PaymentItem(Guid.NewGuid(), "TestItemType", "item-key", 100m, 10m, 90m, 0m, 0m);
var dto = _objectMapper.Map<PaymentItem, PaymentItemDto>(entity);
dto.ShouldNotBeNull();
dto.Id.ShouldBe(entity.Id);
dto.ItemType.ShouldBe("TestItemType");
dto.ItemKey.ShouldBe("item-key");
dto.OriginalPaymentAmount.ShouldBe(100m);
dto.ActualPaymentAmount.ShouldBe(90m);
}
}
}

2
modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp.EShop.Plugins.Application.csproj

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\EasyAbp.EShop.Plugins.Application.Contracts\EasyAbp.EShop.Plugins.Application.Contracts.csproj" />
<ProjectReference Include="..\EasyAbp.EShop.Plugins.Domain\EasyAbp.EShop.Plugins.Domain.csproj" />

10
modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/EShopPluginsApplicationModule.cs

@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -9,17 +9,13 @@ namespace EasyAbp.EShop.Plugins
typeof(EShopPluginsDomainModule),
typeof(EShopPluginsApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPluginsApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopPluginsApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPluginsApplicationModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPluginsApplicationModule>();
}
}
}

14
modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/PluginsApplicationAutoMapperProfile.cs

@ -1,14 +0,0 @@
using AutoMapper;
namespace EasyAbp.EShop.Plugins
{
public class PluginsApplicationAutoMapperProfile : Profile
{
public PluginsApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

10
modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EShopPluginsWebModule.cs

@ -4,7 +4,7 @@ using EasyAbp.EShop.Plugins.Localization;
using EasyAbp.EShop.Plugins.Web.Menus;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -14,7 +14,7 @@ namespace EasyAbp.EShop.Plugins.Web
[DependsOn(
typeof(EShopPluginsApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPluginsWebModule : AbpModule
{
@ -43,11 +43,7 @@ namespace EasyAbp.EShop.Plugins.Web
options.FileSets.AddEmbedded<EShopPluginsWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopPluginsWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPluginsWebModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPluginsWebModule>();
Configure<RazorPagesOptions>(options =>
{

2
modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EasyAbp.EShop.Plugins.Web.csproj

@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
</ItemGroup>

14
modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/PluginsWebAutoMapperProfile.cs

@ -1,14 +0,0 @@
using AutoMapper;
namespace EasyAbp.EShop.Plugins.Web
{
public class PluginsWebAutoMapperProfile : Profile
{
public PluginsWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

3
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp.EShop.Products.Application.csproj

@ -9,7 +9,8 @@
<ItemGroup>
<PackageReference Include="EasyAbp.Abp.Trees.Application" Version="$(EasyAbpAbpTreesModuleVersion)" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Stores\src\EasyAbp.EShop.Stores.Application.Shared\EasyAbp.EShop.Stores.Application.Shared.csproj" />
<ProjectReference Include="..\EasyAbp.EShop.Products.Application.Contracts\EasyAbp.EShop.Products.Application.Contracts.csproj" />

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

@ -1,7 +1,7 @@
using EasyAbp.Abp.Trees;
using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -13,23 +13,14 @@ namespace EasyAbp.EShop.Products
typeof(EShopStoresDomainSharedModule),
typeof(EShopStoresApplicationSharedModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpTreesApplicationModule)
)]
public class EShopProductsApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options =>
{
options.Configurators.Add(abpAutoMapperConfigurationContext =>
{
var profile = abpAutoMapperConfigurationContext.ServiceProvider
.GetRequiredService<ProductsApplicationAutoMapperProfile>();
abpAutoMapperConfigurationContext.MapperConfiguration.AddProfile(profile);
});
});
context.Services.AddMapperlyObjectMapper<EShopProductsApplicationModule>();
}
}
}

2
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductCategories/ProductCategoryAppService.cs

@ -19,6 +19,8 @@ namespace EasyAbp.EShop.Products.ProductCategories
public ProductCategoryAppService(IProductCategoryRepository repository) : base(repository)
{
_repository = repository;
ObjectMapperContext = typeof(EShopProductsApplicationModule);
}
protected override async Task<IQueryable<ProductCategory>> CreateFilteredQueryAsync(

18
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductDetails/ProductDetailAppService.cs

@ -97,7 +97,7 @@ namespace EasyAbp.EShop.Products.ProductDetails
public override async Task DeleteAsync(Guid id)
{
await CheckDeletePolicyAsync();
var detail = await GetEntityByIdAsync(id);
await AuthorizationService.CheckMultiStorePolicyAsync(detail.StoreId, DeletePolicyName,
@ -105,5 +105,21 @@ namespace EasyAbp.EShop.Products.ProductDetails
await Repository.DeleteAsync(id);
}
protected override Task<ProductDetail> MapToEntityAsync(CreateUpdateProductDetailDto createInput)
{
return Task.FromResult(new ProductDetail(
GuidGenerator.Create(),
CurrentTenant.Id,
createInput.StoreId,
createInput.Description));
}
protected override Task MapToEntityAsync(CreateUpdateProductDetailDto updateInput, ProductDetail entity)
{
entity.Update(updateInput.StoreId, updateInput.Description);
return Task.CompletedTask;
}
}
}

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

@ -49,6 +49,8 @@ namespace EasyAbp.EShop.Products.Products
_productInventoryProviderResolver = productInventoryProviderResolver;
_productViewCacheKeyProvider = productViewCacheKeyProvider;
_repository = repository;
ObjectMapperContext = typeof(EShopProductsApplicationModule);
}
protected override async Task<IQueryable<Product>> CreateFilteredQueryAsync(GetProductListInput input)

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

@ -45,6 +45,8 @@ namespace EasyAbp.EShop.Products.Products
_productManager = productManager;
_productRepository = productRepository;
_repository = repository;
ObjectMapperContext = typeof(EShopProductsApplicationModule);
}
protected override async Task<IQueryable<ProductView>> CreateFilteredQueryAsync(GetProductListInput input)

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

@ -1,50 +0,0 @@
using AutoMapper;
using EasyAbp.EShop.Products.Categories;
using EasyAbp.EShop.Products.Categories.Dtos;
using EasyAbp.EShop.Products.ProductCategories;
using EasyAbp.EShop.Products.ProductCategories.Dtos;
using EasyAbp.EShop.Products.ProductDetailHistories;
using EasyAbp.EShop.Products.ProductDetailHistories.Dtos;
using EasyAbp.EShop.Products.ProductDetails;
using EasyAbp.EShop.Products.ProductDetails.Dtos;
using EasyAbp.EShop.Products.ProductHistories;
using EasyAbp.EShop.Products.ProductHistories.Dtos;
using EasyAbp.EShop.Products.Products;
using EasyAbp.EShop.Products.Products.Dtos;
using Volo.Abp.AutoMapper;
using Volo.Abp.DependencyInjection;
namespace EasyAbp.EShop.Products
{
public class ProductsApplicationAutoMapperProfile : Profile, ISingletonDependency
{
public ProductsApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Product, ProductDto>()
.Ignore(dto => dto.ProductGroupDisplayName)
.Ignore(dto => dto.Sold)
.Ignore(dto => dto.MinimumPrice)
.Ignore(dto => dto.MaximumPrice);
CreateMap<ProductDetail, ProductDetailDto>();
CreateMap<ProductAttribute, ProductAttributeDto>();
CreateMap<ProductAttributeOption, ProductAttributeOptionDto>();
CreateMap<ProductSku, ProductSkuDto>()
.Ignore(dto => dto.Price)
.Ignore(dto => dto.Inventory)
.Ignore(dto => dto.Sold);
CreateMap<CreateUpdateProductDetailDto, ProductDetail>(MemberList.Source)
.ForSourceMember(dto => dto.StoreId, opt => opt.DoNotValidate());
CreateMap<CreateUpdateProductAttributeDto, ProductAttribute>(MemberList.Source);
CreateMap<CreateUpdateProductAttributeOptionDto, ProductAttributeOption>(MemberList.Source);
CreateMap<Category, CategoryDto>();
CreateMap<Category, CategorySummaryDto>();
CreateMap<ProductCategory, ProductCategoryDto>();
CreateMap<ProductHistory, ProductHistoryDto>();
CreateMap<ProductDetailHistory, ProductDetailHistoryDto>();
CreateMap<ProductView, ProductViewDto>();
}
}
}

138
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationMapperlyMappers.cs

@ -0,0 +1,138 @@
using EasyAbp.EShop.Products.Categories;
using EasyAbp.EShop.Products.Categories.Dtos;
using EasyAbp.EShop.Products.ProductCategories;
using EasyAbp.EShop.Products.ProductCategories.Dtos;
using EasyAbp.EShop.Products.ProductDetailHistories;
using EasyAbp.EShop.Products.ProductDetailHistories.Dtos;
using EasyAbp.EShop.Products.ProductDetails;
using EasyAbp.EShop.Products.ProductDetails.Dtos;
using EasyAbp.EShop.Products.ProductHistories;
using EasyAbp.EShop.Products.ProductHistories.Dtos;
using EasyAbp.EShop.Products.Products;
using EasyAbp.EShop.Products.Products.Dtos;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Products
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductToProductDtoMapper : MapperBase<Product, ProductDto>
{
[UseMapper] private readonly ProductSkuToProductSkuDtoMapper _productSkuMapper;
[UseMapper] private readonly ProductAttributeToProductAttributeDtoMapper _productAttributeMapper;
public ProductToProductDtoMapper(
ProductSkuToProductSkuDtoMapper productSkuMapper,
ProductAttributeToProductAttributeDtoMapper productAttributeMapper)
{
_productSkuMapper = productSkuMapper;
_productAttributeMapper = productAttributeMapper;
}
[MapperIgnoreTarget(nameof(ProductDto.ProductGroupDisplayName))]
[MapperIgnoreTarget(nameof(ProductDto.Sold))]
[MapperIgnoreTarget(nameof(ProductDto.MinimumPrice))]
[MapperIgnoreTarget(nameof(ProductDto.MaximumPrice))]
public override partial ProductDto Map(Product source);
[MapperIgnoreTarget(nameof(ProductDto.ProductGroupDisplayName))]
[MapperIgnoreTarget(nameof(ProductDto.Sold))]
[MapperIgnoreTarget(nameof(ProductDto.MinimumPrice))]
[MapperIgnoreTarget(nameof(ProductDto.MaximumPrice))]
public override partial void Map(Product source, ProductDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductDetailToProductDetailDtoMapper : MapperBase<ProductDetail, ProductDetailDto>
{
public override partial ProductDetailDto Map(ProductDetail source);
public override partial void Map(ProductDetail source, ProductDetailDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAttributeToProductAttributeDtoMapper : MapperBase<ProductAttribute, ProductAttributeDto>
{
[UseMapper] private readonly ProductAttributeOptionToProductAttributeOptionDtoMapper _optionMapper;
public ProductAttributeToProductAttributeDtoMapper(
ProductAttributeOptionToProductAttributeOptionDtoMapper optionMapper)
{
_optionMapper = optionMapper;
}
public override partial ProductAttributeDto Map(ProductAttribute source);
public override partial void Map(ProductAttribute source, ProductAttributeDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAttributeOptionToProductAttributeOptionDtoMapper : MapperBase<ProductAttributeOption, ProductAttributeOptionDto>
{
public override partial ProductAttributeOptionDto Map(ProductAttributeOption source);
public override partial void Map(ProductAttributeOption source, ProductAttributeOptionDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductSkuToProductSkuDtoMapper : MapperBase<ProductSku, ProductSkuDto>
{
[MapperIgnoreTarget(nameof(ProductSkuDto.Price))]
[MapperIgnoreTarget(nameof(ProductSkuDto.Inventory))]
[MapperIgnoreTarget(nameof(ProductSkuDto.Sold))]
public override partial ProductSkuDto Map(ProductSku source);
[MapperIgnoreTarget(nameof(ProductSkuDto.Price))]
[MapperIgnoreTarget(nameof(ProductSkuDto.Inventory))]
[MapperIgnoreTarget(nameof(ProductSkuDto.Sold))]
public override partial void Map(ProductSku source, ProductSkuDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CategoryToCategoryDtoMapper : MapperBase<Category, CategoryDto>
{
public override partial CategoryDto Map(Category source);
public override partial void Map(Category source, CategoryDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CategoryToCategorySummaryDtoMapper : MapperBase<Category, CategorySummaryDto>
{
public override partial CategorySummaryDto Map(Category source);
public override partial void Map(Category source, CategorySummaryDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductCategoryToProductCategoryDtoMapper : MapperBase<ProductCategory, ProductCategoryDto>
{
public override partial ProductCategoryDto Map(ProductCategory source);
public override partial void Map(ProductCategory source, ProductCategoryDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductHistoryToProductHistoryDtoMapper : MapperBase<ProductHistory, ProductHistoryDto>
{
public override partial ProductHistoryDto Map(ProductHistory source);
public override partial void Map(ProductHistory source, ProductHistoryDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductDetailHistoryToProductDetailHistoryDtoMapper : MapperBase<ProductDetailHistory, ProductDetailHistoryDto>
{
public override partial ProductDetailHistoryDto Map(ProductDetailHistory source);
public override partial void Map(ProductDetailHistory source, ProductDetailHistoryDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductViewToProductViewDtoMapper : MapperBase<ProductView, ProductViewDto>
{
public override partial ProductViewDto Map(ProductView source);
public override partial void Map(ProductView source, ProductViewDto destination);
}
}

3
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp.EShop.Products.Domain.csproj

@ -11,7 +11,8 @@
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.2" />
<PackageReference Include="NodaMoney" Version="$(NodaMoneyVersion)" />
<PackageReference Include="EasyAbp.Abp.Trees.Domain" Version="$(EasyAbpAbpTreesModuleVersion)" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Orders\src\EasyAbp.EShop.Orders.Domain.Shared\EasyAbp.EShop.Orders.Domain.Shared.csproj" />

11
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/EShopProductsDomainModule.cs

@ -4,7 +4,7 @@ using EasyAbp.EShop.Products.Options.ProductGroups;
using EasyAbp.EShop.Products.Products;
using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.Modularity;
@ -13,7 +13,7 @@ namespace EasyAbp.EShop.Products
{
[DependsOn(
typeof(EShopProductsDomainSharedModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpCachingModule),
typeof(AbpTreesDomainModule)
)]
@ -50,12 +50,7 @@ namespace EasyAbp.EShop.Products
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopProductsDomainModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<ProductsDomainAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopProductsDomainModule>();
}
}
}

6
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductDetails/ProductDetail.cs

@ -31,5 +31,11 @@ namespace EasyAbp.EShop.Products.ProductDetails
{
Description = description;
}
public void Update(Guid? storeId, [CanBeNull] string description)
{
StoreId = storeId;
Description = description;
}
}
}

19
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainAutoMapperProfile.cs

@ -1,19 +0,0 @@
using AutoMapper;
using EasyAbp.EShop.Products.Products;
namespace EasyAbp.EShop.Products
{
public class ProductsDomainAutoMapperProfile : Profile
{
public ProductsDomainAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Product, ProductEto>();
CreateMap<ProductAttribute, ProductAttributeEto>();
CreateMap<ProductAttributeOption, ProductAttributeOptionEto>();
CreateMap<ProductSku, ProductSkuEto>();
}
}
}

38
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainMapperlyMappers.cs

@ -0,0 +1,38 @@
using EasyAbp.EShop.Products.Products;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Products
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductToProductEtoMapper : MapperBase<Product, ProductEto>
{
public override partial ProductEto Map(Product source);
public override partial void Map(Product source, ProductEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAttributeToProductAttributeEtoMapper : MapperBase<ProductAttribute, ProductAttributeEto>
{
public override partial ProductAttributeEto Map(ProductAttribute source);
public override partial void Map(ProductAttribute source, ProductAttributeEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAttributeOptionToProductAttributeOptionEtoMapper : MapperBase<ProductAttributeOption, ProductAttributeOptionEto>
{
public override partial ProductAttributeOptionEto Map(ProductAttributeOption source);
public override partial void Map(ProductAttributeOption source, ProductAttributeOptionEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductSkuToProductSkuEtoMapper : MapperBase<ProductSku, ProductSkuEto>
{
public override partial ProductSkuEto Map(ProductSku source);
public override partial void Map(ProductSku source, ProductSkuEto destination);
}
}

10
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EShopProductsWebModule.cs

@ -5,7 +5,7 @@ using EasyAbp.EShop.Products.Localization;
using EasyAbp.EShop.Products.Web.Menus;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -15,7 +15,7 @@ namespace EasyAbp.EShop.Products.Web
[DependsOn(
typeof(EShopProductsApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpTagHelperPlusModule)
)]
public class EShopProductsWebModule : AbpModule
@ -45,11 +45,7 @@ namespace EasyAbp.EShop.Products.Web
options.FileSets.AddEmbedded<EShopProductsWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopProductsWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopProductsWebModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopProductsWebModule>();
Configure<RazorPagesOptions>(options =>
{

3
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EasyAbp.EShop.Products.Web.csproj

@ -12,7 +12,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
<PackageReference Include="EasyAbp.Abp.TagHelperPlus" Version="$(EasyAbpAbpTagHelperPlusModuleVersion)" />
</ItemGroup>

82
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebAutoMapperProfile.cs

@ -1,82 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EasyAbp.EShop.Products.Products.Dtos;
using EasyAbp.EShop.Products.Categories.Dtos;
using AutoMapper;
using EasyAbp.EShop.Products.ProductDetails.Dtos;
using EasyAbp.EShop.Products.Web.Pages.EShop.Products.Categories.Category.ViewModels;
using EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.Product.ViewModels;
using EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku.ViewModels;
using Volo.Abp.AutoMapper;
namespace EasyAbp.EShop.Products.Web
{
public class ProductsWebAutoMapperProfile : Profile
{
public ProductsWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<ProductDto, CreateEditProductViewModel>()
.Ignore(model => model.CategoryIds)
.Ignore(model => model.ProductDetail)
.ForSourceMember(dto => dto.Sold, opt => opt.DoNotValidate())
.ForSourceMember(dto => dto.ProductDetailId, opt => opt.DoNotValidate())
// .Ignore(x => x.ProductAttributes);
.ForMember(dest => dest.ProductAttributeNames,
opt => opt.MapFrom(source =>
source.ProductAttributes.Select(x => x.DisplayName).JoinAsString(",")))
.ForMember(dest => dest.ProductAttributeOptionNames,
opt => opt.MapFrom(x =>
x.ProductAttributes
.Select(a => a.ProductAttributeOptions.Select(o => o.DisplayName).JoinAsString(","))
.JoinAsString(Environment.NewLine)));
CreateMap<CreateEditProductViewModel, CreateUpdateProductDto>()
.Ignore(dto => dto.ExtraProperties)
.Ignore(dto => dto.ProductDetailId)
.ForSourceMember(model => model.ProductDetail, opt => opt.DoNotValidate())
.ForMember(dest => dest.ProductAttributes,
opt => opt.MapFrom(x =>
x.ProductAttributeNames.Split(",", StringSplitOptions.RemoveEmptyEntries).Select((s, i) =>
new CreateUpdateProductAttributeDto
{
DisplayName = s,
ProductAttributeOptions = new List<CreateUpdateProductAttributeOptionDto>(
x.ProductAttributeOptionNames.SplitToLines(StringSplitOptions.RemoveEmptyEntries)[i]
.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(o =>
new CreateUpdateProductAttributeOptionDto {DisplayName = o.RemovePostFix("\r")}))
})));
CreateMap<ProductDetailDto, CreateEditProductDetailViewModel>();
CreateMap<CreateEditProductDetailViewModel, CreateUpdateProductDetailDto>()
.Ignore(dto => dto.ExtraProperties);
CreateMap<CreateEditSkuProductDetailViewModel, CreateUpdateProductDetailDto>()
.Ignore(dto => dto.ExtraProperties);
CreateMap<ProductAttributeDto, CreateEditProductAttributeViewModel>();
CreateMap<CreateEditProductAttributeViewModel, CreateUpdateProductAttributeDto>()
.Ignore(dto => dto.ExtraProperties);
CreateMap<CreateProductSkuViewModel, CreateProductSkuDto>()
.Ignore(dto => dto.ExtraProperties)
.Ignore(dto => dto.ProductDetailId)
.ForSourceMember(model => model.ProductDetail, opt => opt.DoNotValidate())
.ForSourceMember(model => model.Inventory, opt => opt.DoNotValidate())
.Ignore(dto => dto.AttributeOptionIds);
CreateMap<EditProductSkuViewModel, UpdateProductSkuDto>()
.Ignore(dto => dto.ProductDetailId)
.ForSourceMember(model => model.ProductDetail, opt => opt.DoNotValidate())
.Ignore(dto => dto.ExtraProperties);
CreateMap<ProductSkuDto, EditProductSkuViewModel>()
.Ignore(x => x.ProductDetail)
.ForSourceMember(dto => dto.AttributeOptionIds, opt => opt.DoNotValidate())
.ForSourceMember(dto => dto.Inventory, opt => opt.DoNotValidate())
.ForSourceMember(dto => dto.Sold, opt => opt.DoNotValidate());
CreateMap<ProductAttributeOptionDto, CreateEditProductAttributeOptionViewModel>();
CreateMap<CreateEditProductAttributeOptionViewModel, CreateUpdateProductAttributeOptionDto>()
.Ignore(dto => dto.ExtraProperties);
CreateMap<CategoryDto, CreateEditCategoryViewModel>(MemberList.Destination);
CreateMap<CreateEditCategoryViewModel, CreateUpdateCategoryDto>()
.Ignore(dto => dto.ExtraProperties);
}
}
}

186
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebMapperlyMappers.cs

@ -0,0 +1,186 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EasyAbp.EShop.Products.Categories.Dtos;
using EasyAbp.EShop.Products.ProductDetails.Dtos;
using EasyAbp.EShop.Products.Products.Dtos;
using EasyAbp.EShop.Products.Web.Pages.EShop.Products.Categories.Category.ViewModels;
using EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.Product.ViewModels;
using EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku.ViewModels;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Products.Web
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductDtoToCreateEditProductViewModelMapper : MapperBase<ProductDto, CreateEditProductViewModel>
{
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.CategoryIds))]
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.ProductDetail))]
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.ProductAttributeNames))]
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.ProductAttributeOptionNames))]
public override partial CreateEditProductViewModel Map(ProductDto source);
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.CategoryIds))]
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.ProductDetail))]
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.ProductAttributeNames))]
[MapperIgnoreTarget(nameof(CreateEditProductViewModel.ProductAttributeOptionNames))]
public override partial void Map(ProductDto source, CreateEditProductViewModel destination);
public override void AfterMap(ProductDto source, CreateEditProductViewModel destination)
{
destination.ProductAttributeNames =
source.ProductAttributes.Select(x => x.DisplayName).JoinAsString(",");
destination.ProductAttributeOptionNames = source.ProductAttributes
.Select(a => a.ProductAttributeOptions.Select(o => o.DisplayName).JoinAsString(","))
.JoinAsString(Environment.NewLine);
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditProductViewModelToCreateUpdateProductDtoMapper : MapperBase<CreateEditProductViewModel, CreateUpdateProductDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateProductDto.ExtraProperties))]
[MapperIgnoreTarget(nameof(CreateUpdateProductDto.ProductDetailId))]
[MapperIgnoreTarget(nameof(CreateUpdateProductDto.ProductAttributes))]
public override partial CreateUpdateProductDto Map(CreateEditProductViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateProductDto.ExtraProperties))]
[MapperIgnoreTarget(nameof(CreateUpdateProductDto.ProductDetailId))]
[MapperIgnoreTarget(nameof(CreateUpdateProductDto.ProductAttributes))]
public override partial void Map(CreateEditProductViewModel source, CreateUpdateProductDto destination);
public override void AfterMap(CreateEditProductViewModel source, CreateUpdateProductDto destination)
{
destination.ProductAttributes = source.ProductAttributeNames
.Split(",", StringSplitOptions.RemoveEmptyEntries).Select((s, i) =>
new CreateUpdateProductAttributeDto
{
DisplayName = s,
ProductAttributeOptions = new List<CreateUpdateProductAttributeOptionDto>(
source.ProductAttributeOptionNames.SplitToLines(StringSplitOptions.RemoveEmptyEntries)[i]
.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(o =>
new CreateUpdateProductAttributeOptionDto { DisplayName = o.RemovePostFix("\r") }))
}).ToList();
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductDetailDtoToCreateEditProductDetailViewModelMapper : MapperBase<ProductDetailDto, CreateEditProductDetailViewModel>
{
public override partial CreateEditProductDetailViewModel Map(ProductDetailDto source);
public override partial void Map(ProductDetailDto source, CreateEditProductDetailViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditProductDetailViewModelToCreateUpdateProductDetailDtoMapper : MapperBase<CreateEditProductDetailViewModel, CreateUpdateProductDetailDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateProductDetailDto.ExtraProperties))]
public override partial CreateUpdateProductDetailDto Map(CreateEditProductDetailViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateProductDetailDto.ExtraProperties))]
public override partial void Map(CreateEditProductDetailViewModel source, CreateUpdateProductDetailDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditSkuProductDetailViewModelToCreateUpdateProductDetailDtoMapper : MapperBase<CreateEditSkuProductDetailViewModel, CreateUpdateProductDetailDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateProductDetailDto.ExtraProperties))]
public override partial CreateUpdateProductDetailDto Map(CreateEditSkuProductDetailViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateProductDetailDto.ExtraProperties))]
public override partial void Map(CreateEditSkuProductDetailViewModel source, CreateUpdateProductDetailDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAttributeDtoToCreateEditProductAttributeViewModelMapper : MapperBase<ProductAttributeDto, CreateEditProductAttributeViewModel>
{
public override partial CreateEditProductAttributeViewModel Map(ProductAttributeDto source);
public override partial void Map(ProductAttributeDto source, CreateEditProductAttributeViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditProductAttributeViewModelToCreateUpdateProductAttributeDtoMapper : MapperBase<CreateEditProductAttributeViewModel, CreateUpdateProductAttributeDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateProductAttributeDto.ExtraProperties))]
public override partial CreateUpdateProductAttributeDto Map(CreateEditProductAttributeViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateProductAttributeDto.ExtraProperties))]
public override partial void Map(CreateEditProductAttributeViewModel source, CreateUpdateProductAttributeDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateProductSkuViewModelToCreateProductSkuDtoMapper : MapperBase<CreateProductSkuViewModel, CreateProductSkuDto>
{
[MapperIgnoreTarget(nameof(CreateProductSkuDto.ExtraProperties))]
[MapperIgnoreTarget(nameof(CreateProductSkuDto.ProductDetailId))]
[MapperIgnoreTarget(nameof(CreateProductSkuDto.AttributeOptionIds))]
public override partial CreateProductSkuDto Map(CreateProductSkuViewModel source);
[MapperIgnoreTarget(nameof(CreateProductSkuDto.ExtraProperties))]
[MapperIgnoreTarget(nameof(CreateProductSkuDto.ProductDetailId))]
[MapperIgnoreTarget(nameof(CreateProductSkuDto.AttributeOptionIds))]
public override partial void Map(CreateProductSkuViewModel source, CreateProductSkuDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class EditProductSkuViewModelToUpdateProductSkuDtoMapper : MapperBase<EditProductSkuViewModel, UpdateProductSkuDto>
{
[MapperIgnoreTarget(nameof(UpdateProductSkuDto.ProductDetailId))]
[MapperIgnoreTarget(nameof(UpdateProductSkuDto.ExtraProperties))]
public override partial UpdateProductSkuDto Map(EditProductSkuViewModel source);
[MapperIgnoreTarget(nameof(UpdateProductSkuDto.ProductDetailId))]
[MapperIgnoreTarget(nameof(UpdateProductSkuDto.ExtraProperties))]
public override partial void Map(EditProductSkuViewModel source, UpdateProductSkuDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductSkuDtoToEditProductSkuViewModelMapper : MapperBase<ProductSkuDto, EditProductSkuViewModel>
{
[MapperIgnoreTarget(nameof(EditProductSkuViewModel.ProductDetail))]
public override partial EditProductSkuViewModel Map(ProductSkuDto source);
[MapperIgnoreTarget(nameof(EditProductSkuViewModel.ProductDetail))]
public override partial void Map(ProductSkuDto source, EditProductSkuViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAttributeOptionDtoToCreateEditProductAttributeOptionViewModelMapper : MapperBase<ProductAttributeOptionDto, CreateEditProductAttributeOptionViewModel>
{
public override partial CreateEditProductAttributeOptionViewModel Map(ProductAttributeOptionDto source);
public override partial void Map(ProductAttributeOptionDto source, CreateEditProductAttributeOptionViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditProductAttributeOptionViewModelToCreateUpdateProductAttributeOptionDtoMapper : MapperBase<CreateEditProductAttributeOptionViewModel, CreateUpdateProductAttributeOptionDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateProductAttributeOptionDto.ExtraProperties))]
public override partial CreateUpdateProductAttributeOptionDto Map(CreateEditProductAttributeOptionViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateProductAttributeOptionDto.ExtraProperties))]
public override partial void Map(CreateEditProductAttributeOptionViewModel source, CreateUpdateProductAttributeOptionDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CategoryDtoToCreateEditCategoryViewModelMapper : MapperBase<CategoryDto, CreateEditCategoryViewModel>
{
public override partial CreateEditCategoryViewModel Map(CategoryDto source);
public override partial void Map(CategoryDto source, CreateEditCategoryViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditCategoryViewModelToCreateUpdateCategoryDtoMapper : MapperBase<CreateEditCategoryViewModel, CreateUpdateCategoryDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateCategoryDto.ExtraProperties))]
public override partial CreateUpdateCategoryDto Map(CreateEditCategoryViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateCategoryDto.ExtraProperties))]
public override partial void Map(CreateEditCategoryViewModel source, CreateUpdateCategoryDto destination);
}
}

32
modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Application.Tests/ProductDetails/ProductDetailMapperlyTests.cs

@ -0,0 +1,32 @@
using System;
using EasyAbp.EShop.Products.ProductDetails.Dtos;
using Shouldly;
using Volo.Abp.ObjectMapping;
using Xunit;
namespace EasyAbp.EShop.Products.ProductDetails
{
public class ProductDetailMapperlyTests : ProductsApplicationTestBase
{
private readonly IObjectMapper<EShopProductsApplicationModule> _objectMapper;
public ProductDetailMapperlyTests()
{
_objectMapper = GetRequiredService<IObjectMapper<EShopProductsApplicationModule>>();
}
[Fact]
public void Should_Map_ProductDetail_To_ProductDetailDto()
{
var storeId = Guid.NewGuid();
var entity = new ProductDetail(Guid.NewGuid(), null, storeId, "A description");
var dto = _objectMapper.Map<ProductDetail, ProductDetailDto>(entity);
dto.ShouldNotBeNull();
dto.Id.ShouldBe(entity.Id);
dto.StoreId.ShouldBe(storeId);
dto.Description.ShouldBe("A description");
}
}
}

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp.EShop.Stores.Application.Shared.csproj

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\EasyAbp.EShop.Stores.Domain.Shared\EasyAbp.EShop.Stores.Domain.Shared.csproj" />
</ItemGroup>

4
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp/EShop/Stores/EShopStoresApplicationSharedModule.cs

@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Application;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
namespace EasyAbp.EShop.Stores
@ -10,7 +10,7 @@ namespace EasyAbp.EShop.Stores
[DependsOn(
typeof(EShopStoresDomainSharedModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopStoresApplicationSharedModule : AbpModule
{

3
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp.EShop.Stores.Application.csproj

@ -8,7 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Users.Abstractions" Version="$(AbpVersion)" />
<ProjectReference Include="..\EasyAbp.EShop.Stores.Application.Contracts\EasyAbp.EShop.Stores.Application.Contracts.csproj" />

10
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/EShopStoresApplicationModule.cs

@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
using Volo.Abp.Users;
@ -12,17 +12,13 @@ namespace EasyAbp.EShop.Stores
typeof(EShopStoresApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpUsersAbstractionModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopStoresApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopStoresApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopStoresApplicationModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopStoresApplicationModule>();
}
}
}

20
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerAppService.cs

@ -6,6 +6,7 @@ using EasyAbp.EShop.Stores.Permissions;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Stores;
using Volo.Abp.Application.Dtos;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Users;
namespace EasyAbp.EShop.Stores.StoreOwners
@ -92,5 +93,24 @@ namespace EasyAbp.EShop.Stores.StoreOwners
return queryable;
}
protected override Task<StoreOwner> MapToEntityAsync(CreateUpdateStoreOwnerDto createInput)
{
var entity = new StoreOwner(GuidGenerator.Create(), createInput.StoreId, createInput.OwnerUserId,
CurrentTenant.Id);
createInput.MapExtraPropertiesTo(entity);
return Task.FromResult(entity);
}
protected override Task MapToEntityAsync(CreateUpdateStoreOwnerDto updateInput, StoreOwner entity)
{
entity.Update(updateInput.StoreId, updateInput.OwnerUserId);
updateInput.MapExtraPropertiesTo(entity);
return Task.CompletedTask;
}
}
}

19
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Stores/StoreAppService.cs

@ -7,6 +7,7 @@ using EasyAbp.EShop.Stores.Stores.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Users;
namespace EasyAbp.EShop.Stores.Stores
@ -68,5 +69,23 @@ namespace EasyAbp.EShop.Stores.Stores
// Todo: need to be improved
return ObjectMapper.Map<Store, StoreDto>(await _repository.FindDefaultStoreAsync());
}
protected override Task<Store> MapToEntityAsync(CreateUpdateStoreDto createInput)
{
var entity = new Store(GuidGenerator.Create(), CurrentTenant.Id, createInput.Name);
createInput.MapExtraPropertiesTo(entity);
return Task.FromResult(entity);
}
protected override Task MapToEntityAsync(CreateUpdateStoreDto updateInput, Store entity)
{
entity.Update(updateInput.Name);
updateInput.MapExtraPropertiesTo(entity);
return Task.CompletedTask;
}
}
}

31
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs

@ -1,31 +0,0 @@
using AutoMapper;
using EasyAbp.EShop.Stores.StoreOwners;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Stores;
using EasyAbp.EShop.Stores.Stores.Dtos;
using EasyAbp.EShop.Stores.Transactions;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using Volo.Abp.AutoMapper;
using Volo.Abp.ObjectExtending;
namespace EasyAbp.EShop.Stores
{
public class StoresApplicationAutoMapperProfile : Profile
{
public StoresApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Store, StoreDto>();
CreateMap<CreateUpdateStoreDto, Store>(MemberList.Source);
CreateMap<StoreOwner, StoreOwnerDto>()
.Ignore(dto => dto.OwnerUserName);
CreateMap<CreateUpdateStoreOwnerDto, StoreOwner>(MemberList.Source);
CreateMap<Transaction, TransactionDto>();
CreateMap<CreateUpdateTransactionDto, Transaction>(MemberList.Source);
}
}
}

37
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationMapperlyMappers.cs

@ -0,0 +1,37 @@
using EasyAbp.EShop.Stores.StoreOwners;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Stores;
using EasyAbp.EShop.Stores.Stores.Dtos;
using EasyAbp.EShop.Stores.Transactions;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Stores
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class StoreToStoreDtoMapper : MapperBase<Store, StoreDto>
{
public override partial StoreDto Map(Store source);
public override partial void Map(Store source, StoreDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class StoreOwnerToStoreOwnerDtoMapper : MapperBase<StoreOwner, StoreOwnerDto>
{
[MapperIgnoreTarget(nameof(StoreOwnerDto.OwnerUserName))]
public override partial StoreOwnerDto Map(StoreOwner source);
[MapperIgnoreTarget(nameof(StoreOwnerDto.OwnerUserName))]
public override partial void Map(StoreOwner source, StoreOwnerDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class TransactionToTransactionDtoMapper : MapperBase<Transaction, TransactionDto>
{
public override partial TransactionDto Map(Transaction source);
public override partial void Map(Transaction source, TransactionDto destination);
}
}

22
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Transactions/TransactionAppService.cs

@ -6,6 +6,7 @@ using EasyAbp.EShop.Stores.Permissions;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.ObjectExtending;
namespace EasyAbp.EShop.Stores.Transactions
{
@ -32,5 +33,26 @@ namespace EasyAbp.EShop.Stores.Transactions
{
return (await base.CreateFilteredQueryAsync(input)).Where(x => x.StoreId == input.StoreId);
}
protected override Task<Transaction> MapToEntityAsync(CreateUpdateTransactionDto createInput)
{
var entity = new Transaction(GuidGenerator.Create(), CurrentTenant.Id, createInput.StoreId,
createInput.OrderId, createInput.TransactionType, createInput.ActionName, createInput.Currency,
createInput.Amount);
createInput.MapExtraPropertiesTo(entity);
return Task.FromResult(entity);
}
protected override Task MapToEntityAsync(CreateUpdateTransactionDto updateInput, Transaction entity)
{
entity.Update(updateInput.StoreId, updateInput.OrderId, updateInput.TransactionType,
updateInput.ActionName, updateInput.Currency, updateInput.Amount);
updateInput.MapExtraPropertiesTo(entity);
return Task.CompletedTask;
}
}
}

6
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwner.cs

@ -23,5 +23,11 @@ namespace EasyAbp.EShop.Stores.StoreOwners
OwnerUserId = ownerUserId;
TenantId = tenantId;
}
public void Update(Guid storeId, Guid ownerUserId)
{
StoreId = storeId;
OwnerUserId = ownerUserId;
}
}
}

5
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/Store.cs

@ -24,5 +24,10 @@ namespace EasyAbp.EShop.Stores.Stores
TenantId = tenantId;
Name = name;
}
public void Update([NotNull] string name)
{
Name = name;
}
}
}

16
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/Transaction.cs

@ -44,5 +44,21 @@ namespace EasyAbp.EShop.Stores.Transactions
Currency = currency;
Amount = amount;
}
public void Update(
Guid storeId,
Guid? orderId,
TransactionType transactionType,
[NotNull] string actionName,
[NotNull] string currency,
decimal amount)
{
StoreId = storeId;
OrderId = orderId;
TransactionType = transactionType;
ActionName = actionName;
Currency = currency;
Amount = amount;
}
}
}

10
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EShopStoresWebModule.cs

@ -5,7 +5,7 @@ using EasyAbp.EShop.Stores.Localization;
using EasyAbp.EShop.Stores.Web.Menus;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -15,7 +15,7 @@ namespace EasyAbp.EShop.Stores.Web
[DependsOn(
typeof(EShopStoresWebSharedModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpTagHelperPlusModule)
)]
public class EShopStoresWebModule : AbpModule
@ -45,11 +45,7 @@ namespace EasyAbp.EShop.Stores.Web
options.FileSets.AddEmbedded<EShopStoresWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopStoresWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopStoresWebModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopStoresWebModule>();
Configure<RazorPagesOptions>(options =>
{

3
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj

@ -13,7 +13,8 @@
<ItemGroup>
<PackageReference Include="EasyAbp.Abp.TagHelperPlus" Version="$(EasyAbpAbpTagHelperPlusModuleVersion)" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
</ItemGroup>

33
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs

@ -1,33 +0,0 @@
using EasyAbp.EShop.Stores.Stores.Dtos;
using AutoMapper;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner.ViewModels;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store.ViewModels;
using Volo.Abp.AutoMapper;
using Volo.Abp.ObjectExtending;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.ViewModels;
namespace EasyAbp.EShop.Stores.Web
{
public class StoresWebAutoMapperProfile : Profile
{
public StoresWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<StoreDto, CreateEditStoreViewModel>();
CreateMap<CreateEditStoreViewModel, CreateUpdateStoreDto>()
.Ignore(dto => dto.ExtraProperties);
CreateMap<StoreOwnerDto, CreateEditStoreOwnerViewModel>();
CreateMap<CreateEditStoreOwnerViewModel, CreateUpdateStoreOwnerDto>()
.Ignore(dto => dto.ExtraProperties);
CreateMap<TransactionDto, CreateEditTransactionViewModel>();
CreateMap<CreateEditTransactionViewModel, CreateUpdateTransactionDto>()
.Ignore(dto => dto.ExtraProperties);
}
}
}

65
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebMapperlyMappers.cs

@ -0,0 +1,65 @@
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Stores.Dtos;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner.ViewModels;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store.ViewModels;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.ViewModels;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Stores.Web
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class StoreDtoToCreateEditStoreViewModelMapper : MapperBase<StoreDto, CreateEditStoreViewModel>
{
public override partial CreateEditStoreViewModel Map(StoreDto source);
public override partial void Map(StoreDto source, CreateEditStoreViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditStoreViewModelToCreateUpdateStoreDtoMapper : MapperBase<CreateEditStoreViewModel, CreateUpdateStoreDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateStoreDto.ExtraProperties))]
public override partial CreateUpdateStoreDto Map(CreateEditStoreViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateStoreDto.ExtraProperties))]
public override partial void Map(CreateEditStoreViewModel source, CreateUpdateStoreDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class StoreOwnerDtoToCreateEditStoreOwnerViewModelMapper : MapperBase<StoreOwnerDto, CreateEditStoreOwnerViewModel>
{
public override partial CreateEditStoreOwnerViewModel Map(StoreOwnerDto source);
public override partial void Map(StoreOwnerDto source, CreateEditStoreOwnerViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditStoreOwnerViewModelToCreateUpdateStoreOwnerDtoMapper : MapperBase<CreateEditStoreOwnerViewModel, CreateUpdateStoreOwnerDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateStoreOwnerDto.ExtraProperties))]
public override partial CreateUpdateStoreOwnerDto Map(CreateEditStoreOwnerViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateStoreOwnerDto.ExtraProperties))]
public override partial void Map(CreateEditStoreOwnerViewModel source, CreateUpdateStoreOwnerDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class TransactionDtoToCreateEditTransactionViewModelMapper : MapperBase<TransactionDto, CreateEditTransactionViewModel>
{
public override partial CreateEditTransactionViewModel Map(TransactionDto source);
public override partial void Map(TransactionDto source, CreateEditTransactionViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditTransactionViewModelToCreateUpdateTransactionDtoMapper : MapperBase<CreateEditTransactionViewModel, CreateUpdateTransactionDto>
{
[MapperIgnoreTarget(nameof(CreateUpdateTransactionDto.ExtraProperties))]
public override partial CreateUpdateTransactionDto Map(CreateEditTransactionViewModel source);
[MapperIgnoreTarget(nameof(CreateUpdateTransactionDto.ExtraProperties))]
public override partial void Map(CreateEditTransactionViewModel source, CreateUpdateTransactionDto destination);
}
}

30
modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Application.Tests/Stores/StoreMapperlyTests.cs

@ -0,0 +1,30 @@
using System;
using EasyAbp.EShop.Stores.Stores.Dtos;
using Shouldly;
using Volo.Abp.ObjectMapping;
using Xunit;
namespace EasyAbp.EShop.Stores.Stores
{
public class StoreMapperlyTests : StoresApplicationTestBase
{
private readonly IObjectMapper<EShopStoresApplicationModule> _objectMapper;
public StoreMapperlyTests()
{
_objectMapper = GetRequiredService<IObjectMapper<EShopStoresApplicationModule>>();
}
[Fact]
public void Should_Map_Store_To_StoreDto()
{
var entity = new Store(Guid.NewGuid(), null, "Test Store");
var dto = _objectMapper.Map<Store, StoreDto>(entity);
dto.ShouldNotBeNull();
dto.Id.ShouldBe(entity.Id);
dto.Name.ShouldBe("Test Store");
}
}
}

3
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp.EShop.Plugins.Baskets.Application.csproj

@ -8,7 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\..\modules\EasyAbp.EShop.Products\src\EasyAbp.EShop.Products.Application.Contracts\EasyAbp.EShop.Products.Application.Contracts.csproj" />
<ProjectReference Include="..\EasyAbp.EShop.Plugins.Baskets.Application.Contracts\EasyAbp.EShop.Plugins.Baskets.Application.Contracts.csproj" />

17
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationAutoMapperProfile.cs

@ -1,17 +0,0 @@
using EasyAbp.EShop.Plugins.Baskets.BasketItems;
using EasyAbp.EShop.Plugins.Baskets.BasketItems.Dtos;
using AutoMapper;
namespace EasyAbp.EShop.Plugins.Baskets
{
public class BasketsApplicationAutoMapperProfile : Profile
{
public BasketsApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<BasketItem, BasketItemDto>();
}
}
}

15
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationMapperlyMappers.cs

@ -0,0 +1,15 @@
using EasyAbp.EShop.Plugins.Baskets.BasketItems;
using EasyAbp.EShop.Plugins.Baskets.BasketItems.Dtos;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Plugins.Baskets
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class BasketItemToBasketItemDtoMapper : MapperBase<BasketItem, BasketItemDto>
{
public override partial BasketItemDto Map(BasketItem source);
public override partial void Map(BasketItem source, BasketItemDto destination);
}
}

10
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/EShopPluginsBasketsApplicationModule.cs

@ -1,6 +1,6 @@
using EasyAbp.EShop.Products;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -11,17 +11,13 @@ namespace EasyAbp.EShop.Plugins.Baskets
typeof(EShopPluginsBasketsApplicationContractsModule),
typeof(EShopProductsApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPluginsBasketsApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopPluginsBasketsApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPluginsBasketsApplicationModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPluginsBasketsApplicationModule>();
}
}
}

26
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebAutoMapperProfile.cs

@ -1,26 +0,0 @@
using EasyAbp.EShop.Plugins.Baskets.BasketItems.Dtos;
using AutoMapper;
using EasyAbp.EShop.Plugins.Baskets.BasketItems;
using EasyAbp.EShop.Plugins.Baskets.Web.Pages.EShop.Plugins.Baskets.BasketItems.BasketItem.ViewModels;
using Volo.Abp.AutoMapper;
namespace EasyAbp.EShop.Plugins.Baskets.Web
{
public class BasketsWebAutoMapperProfile : Profile
{
public BasketsWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<ClientSideBasketItemModel, GenerateClientSideDataItemInput>()
.Ignore(dto => dto.ExtraProperties);
CreateMap<BasketItemDto, EditBasketItemViewModel>();
CreateMap<CreateBasketItemViewModel, CreateBasketItemDto>()
.Ignore(dto => dto.UserId)
.Ignore(dto => dto.ExtraProperties);
CreateMap<EditBasketItemViewModel, UpdateBasketItemDto>()
.Ignore(dto => dto.ExtraProperties);
}
}
}

47
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebMapperlyMappers.cs

@ -0,0 +1,47 @@
using EasyAbp.EShop.Plugins.Baskets.BasketItems.Dtos;
using EasyAbp.EShop.Plugins.Baskets.Web.Pages.EShop.Plugins.Baskets.BasketItems.BasketItem.ViewModels;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Plugins.Baskets.Web
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ClientSideBasketItemModelToGenerateClientSideDataItemInputMapper : MapperBase<ClientSideBasketItemModel, GenerateClientSideDataItemInput>
{
[MapperIgnoreTarget(nameof(GenerateClientSideDataItemInput.ExtraProperties))]
public override partial GenerateClientSideDataItemInput Map(ClientSideBasketItemModel source);
[MapperIgnoreTarget(nameof(GenerateClientSideDataItemInput.ExtraProperties))]
public override partial void Map(ClientSideBasketItemModel source, GenerateClientSideDataItemInput destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class BasketItemDtoToEditBasketItemViewModelMapper : MapperBase<BasketItemDto, EditBasketItemViewModel>
{
public override partial EditBasketItemViewModel Map(BasketItemDto source);
public override partial void Map(BasketItemDto source, EditBasketItemViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateBasketItemViewModelToCreateBasketItemDtoMapper : MapperBase<CreateBasketItemViewModel, CreateBasketItemDto>
{
[MapperIgnoreTarget(nameof(CreateBasketItemDto.UserId))]
[MapperIgnoreTarget(nameof(CreateBasketItemDto.ExtraProperties))]
public override partial CreateBasketItemDto Map(CreateBasketItemViewModel source);
[MapperIgnoreTarget(nameof(CreateBasketItemDto.UserId))]
[MapperIgnoreTarget(nameof(CreateBasketItemDto.ExtraProperties))]
public override partial void Map(CreateBasketItemViewModel source, CreateBasketItemDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class EditBasketItemViewModelToUpdateBasketItemDtoMapper : MapperBase<EditBasketItemViewModel, UpdateBasketItemDto>
{
[MapperIgnoreTarget(nameof(UpdateBasketItemDto.ExtraProperties))]
public override partial UpdateBasketItemDto Map(EditBasketItemViewModel source);
[MapperIgnoreTarget(nameof(UpdateBasketItemDto.ExtraProperties))]
public override partial void Map(EditBasketItemViewModel source, UpdateBasketItemDto destination);
}
}

10
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EShopPluginsBasketsWebModule.cs

@ -5,7 +5,7 @@ using EasyAbp.EShop.Plugins.Baskets.Localization;
using EasyAbp.EShop.Plugins.Baskets.Web.Menus;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -16,7 +16,7 @@ namespace EasyAbp.EShop.Plugins.Baskets.Web
typeof(EShopOrdersApplicationContractsModule),
typeof(EShopPluginsBasketsApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPluginsBasketsWebModule : AbpModule
{
@ -45,12 +45,8 @@ namespace EasyAbp.EShop.Plugins.Baskets.Web
options.FileSets.AddEmbedded<EShopPluginsBasketsWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopPluginsBasketsWebModule>();
context.Services.AddMapperlyObjectMapper<EShopPluginsBasketsWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPluginsBasketsWebModule>(validate: true);
});
Configure<RazorPagesOptions>(options =>
{

3
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EasyAbp.EShop.Plugins.Baskets.Web.csproj

@ -12,7 +12,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
</ItemGroup>

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp.EShop.Plugins.Booking.Application.csproj

@ -8,7 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\..\modules\EasyAbp.EShop.Products\src\EasyAbp.EShop.Products.Application.Contracts\EasyAbp.EShop.Products.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\modules\EasyAbp.EShop.Stores\src\EasyAbp.EShop.Stores.Application.Shared\EasyAbp.EShop.Stores.Application.Shared.csproj" />

33
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationAutoMapperProfile.cs

@ -1,33 +0,0 @@
using EasyAbp.EShop.Plugins.Booking.ProductAssets;
using EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos;
using EasyAbp.EShop.Plugins.Booking.GrantedStores;
using EasyAbp.EShop.Plugins.Booking.GrantedStores.Dtos;
using AutoMapper;
namespace EasyAbp.EShop.Plugins.Booking;
public class BookingApplicationAutoMapperProfile : Profile
{
public BookingApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<ProductAsset, ProductAssetDto>();
CreateMap<ProductAssetPeriod, ProductAssetPeriodDto>();
CreateMap<CreateProductAssetPeriodDto, ProductAssetPeriod>(MemberList.Source);
CreateMap<UpdateProductAssetPeriodDto, ProductAssetPeriod>(MemberList.Source);
CreateMap<ProductAssetCategory, ProductAssetCategoryDto>();
CreateMap<ProductAssetCategoryPeriod, ProductAssetCategoryPeriodDto>();
CreateMap<CreateProductAssetCategoryPeriodDto, ProductAssetCategoryPeriod>(MemberList.Source);
CreateMap<UpdateProductAssetCategoryPeriodDto, ProductAssetCategoryPeriod>(MemberList.Source);
CreateMap<GrantedStore, GrantedStoreDto>();
CreateMap<CreateUpdateGrantedStoreDto, GrantedStore>(MemberList.Source);
}
}

64
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationMapperlyMappers.cs

@ -0,0 +1,64 @@
using System.Collections.Generic;
using EasyAbp.EShop.Plugins.Booking.GrantedStores;
using EasyAbp.EShop.Plugins.Booking.GrantedStores.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssets;
using EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Plugins.Booking
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetToProductAssetDtoMapper : MapperBase<ProductAsset, ProductAssetDto>
{
public override partial ProductAssetDto Map(ProductAsset source);
public override partial void Map(ProductAsset source, ProductAssetDto destination);
// Mirror AutoMapper's default of mapping a null source collection to an empty collection.
public override void AfterMap(ProductAsset source, ProductAssetDto destination)
{
destination.Periods ??= new List<ProductAssetPeriodDto>();
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetPeriodToProductAssetPeriodDtoMapper : MapperBase<ProductAssetPeriod, ProductAssetPeriodDto>
{
public override partial ProductAssetPeriodDto Map(ProductAssetPeriod source);
public override partial void Map(ProductAssetPeriod source, ProductAssetPeriodDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetCategoryToProductAssetCategoryDtoMapper : MapperBase<ProductAssetCategory, ProductAssetCategoryDto>
{
public override partial ProductAssetCategoryDto Map(ProductAssetCategory source);
public override partial void Map(ProductAssetCategory source, ProductAssetCategoryDto destination);
// Mirror AutoMapper's default of mapping a null source collection to an empty collection.
public override void AfterMap(ProductAssetCategory source, ProductAssetCategoryDto destination)
{
destination.Periods ??= new List<ProductAssetCategoryPeriodDto>();
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetCategoryPeriodToProductAssetCategoryPeriodDtoMapper : MapperBase<ProductAssetCategoryPeriod, ProductAssetCategoryPeriodDto>
{
public override partial ProductAssetCategoryPeriodDto Map(ProductAssetCategoryPeriod source);
public override partial void Map(ProductAssetCategoryPeriod source, ProductAssetCategoryPeriodDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class GrantedStoreToGrantedStoreDtoMapper : MapperBase<GrantedStore, GrantedStoreDto>
{
public override partial GrantedStoreDto Map(GrantedStore source);
public override partial void Map(GrantedStore source, GrantedStoreDto destination);
}
}

10
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/EShopPluginsBookingApplicationModule.cs

@ -2,7 +2,7 @@
using EasyAbp.EShop.Products;
using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -15,16 +15,12 @@ namespace EasyAbp.EShop.Plugins.Booking;
typeof(EShopPluginsBookingApplicationContractsModule),
typeof(BookingServiceApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPluginsBookingApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopPluginsBookingApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPluginsBookingApplicationModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPluginsBookingApplicationModule>();
}
}

14
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStoreAppService.cs

@ -36,5 +36,19 @@ namespace EasyAbp.EShop.Plugins.Booking.GrantedStores
.WhereIf(input.AssetCategoryId.HasValue, x => x.AssetCategoryId == input.AssetCategoryId)
.WhereIf(input.AllowAll.HasValue, x => x.AllowAll == input.AllowAll);
}
protected override Task<GrantedStore> MapToEntityAsync(CreateUpdateGrantedStoreDto createInput)
{
return Task.FromResult(new GrantedStore(GuidGenerator.Create(), CurrentTenant.Id, createInput.StoreId,
createInput.AssetId, createInput.AssetCategoryId, createInput.AllowAll));
}
protected override Task MapToEntityAsync(CreateUpdateGrantedStoreDto updateInput, GrantedStore entity)
{
entity.Update(updateInput.StoreId, updateInput.AssetId, updateInput.AssetCategoryId,
updateInput.AllowAll);
return Task.CompletedTask;
}
}
}

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryAppService.cs

@ -140,7 +140,7 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories
await CheckMultiStorePolicyAsync(productAssetCategory.StoreId, UpdatePolicyName);
productAssetCategory.AddPeriod(
ObjectMapper.Map<CreateProductAssetCategoryPeriodDto, ProductAssetCategoryPeriod>(input));
new ProductAssetCategoryPeriod(GuidGenerator.Create(), input.PeriodId, input.Currency, input.Price));
await _repository.UpdateAsync(productAssetCategory, true);
@ -156,7 +156,7 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories
var productAssetCategoryPeriod = productAssetCategory.GetPeriod(periodId);
ObjectMapper.Map(input, productAssetCategoryPeriod);
productAssetCategoryPeriod.Update(input.Currency, input.Price);
await _repository.UpdateAsync(productAssetCategory, true);

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetAppService.cs

@ -138,7 +138,7 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets
await CheckMultiStorePolicyAsync(productAsset.StoreId, UpdatePolicyName);
productAsset.AddPeriod(
ObjectMapper.Map<CreateProductAssetPeriodDto, ProductAssetPeriod>(input));
new ProductAssetPeriod(GuidGenerator.Create(), input.PeriodId, input.Currency, input.Price));
await _repository.UpdateAsync(productAsset, true);
@ -154,7 +154,7 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets
var productAssetPeriod = productAsset.GetPeriod(periodId);
ObjectMapper.Map(input, productAssetPeriod);
productAssetPeriod.Update(input.Currency, input.Price);
await _repository.UpdateAsync(productAsset, true);

8
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStore.cs

@ -36,4 +36,12 @@ public class GrantedStore : AuditedAggregateRoot<Guid>, IMultiTenant
AssetCategoryId = assetCategoryId;
AllowAll = allowAll;
}
public void Update(Guid storeId, Guid? assetId, Guid? assetCategoryId, bool allowAll)
{
StoreId = storeId;
AssetId = assetId;
AssetCategoryId = assetCategoryId;
AllowAll = allowAll;
}
}

6
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs

@ -28,4 +28,10 @@ public class ProductAssetCategoryPeriod : Entity<Guid>
Currency = currency;
Price = price;
}
public void Update([NotNull] string currency, decimal price)
{
Currency = currency;
Price = price;
}
}

6
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs

@ -28,4 +28,10 @@ public class ProductAssetPeriod : Entity<Guid>
Currency = currency;
Price = price;
}
public void Update([NotNull] string currency, decimal price)
{
Currency = currency;
Price = price;
}
}

39
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebAutoMapperProfile.cs

@ -1,39 +0,0 @@
using EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAsset.ViewModels;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAssetPeriod.ViewModels;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos;
using AutoMapper;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategory.ViewModels;
using EasyAbp.EShop.Plugins.Booking.GrantedStores.Dtos;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategoryPeriod.ViewModels;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.GrantedStores.GrantedStore.ViewModels;
namespace EasyAbp.EShop.Plugins.Booking.Web;
public class BookingWebAutoMapperProfile : Profile
{
public BookingWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<ProductAssetDto, EditProductAssetViewModel>();
CreateMap<CreateProductAssetViewModel, CreateProductAssetDto>();
CreateMap<EditProductAssetViewModel, UpdateProductAssetDto>();
CreateMap<ProductAssetPeriodDto, EditProductAssetPeriodViewModel>();
CreateMap<CreateProductAssetPeriodViewModel, CreateProductAssetPeriodDto>();
CreateMap<EditProductAssetPeriodViewModel, UpdateProductAssetPeriodDto>();
CreateMap<ProductAssetCategoryDto, EditProductAssetCategoryViewModel>();
CreateMap<CreateProductAssetCategoryViewModel, CreateProductAssetCategoryDto>();
CreateMap<EditProductAssetCategoryViewModel, UpdateProductAssetCategoryDto>();
CreateMap<ProductAssetCategoryPeriodDto, EditProductAssetCategoryPeriodViewModel>();
CreateMap<CreateProductAssetCategoryPeriodViewModel, CreateProductAssetCategoryPeriodDto>();
CreateMap<EditProductAssetCategoryPeriodViewModel, UpdateProductAssetCategoryPeriodDto>();
CreateMap<GrantedStoreDto, CreateEditGrantedStoreViewModel>();
CreateMap<CreateEditGrantedStoreViewModel, CreateUpdateGrantedStoreDto>();
}
}

125
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebMapperlyMappers.cs

@ -0,0 +1,125 @@
using EasyAbp.EShop.Plugins.Booking.GrantedStores.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.GrantedStores.GrantedStore.ViewModels;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategory.ViewModels;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategoryPeriod.ViewModels;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAsset.ViewModels;
using EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAssetPeriod.ViewModels;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace EasyAbp.EShop.Plugins.Booking.Web
{
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetDtoToEditProductAssetViewModelMapper : MapperBase<ProductAssetDto, EditProductAssetViewModel>
{
public override partial EditProductAssetViewModel Map(ProductAssetDto source);
public override partial void Map(ProductAssetDto source, EditProductAssetViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateProductAssetViewModelToCreateProductAssetDtoMapper : MapperBase<CreateProductAssetViewModel, CreateProductAssetDto>
{
public override partial CreateProductAssetDto Map(CreateProductAssetViewModel source);
public override partial void Map(CreateProductAssetViewModel source, CreateProductAssetDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class EditProductAssetViewModelToUpdateProductAssetDtoMapper : MapperBase<EditProductAssetViewModel, UpdateProductAssetDto>
{
public override partial UpdateProductAssetDto Map(EditProductAssetViewModel source);
public override partial void Map(EditProductAssetViewModel source, UpdateProductAssetDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetPeriodDtoToEditProductAssetPeriodViewModelMapper : MapperBase<ProductAssetPeriodDto, EditProductAssetPeriodViewModel>
{
public override partial EditProductAssetPeriodViewModel Map(ProductAssetPeriodDto source);
public override partial void Map(ProductAssetPeriodDto source, EditProductAssetPeriodViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateProductAssetPeriodViewModelToCreateProductAssetPeriodDtoMapper : MapperBase<CreateProductAssetPeriodViewModel, CreateProductAssetPeriodDto>
{
public override partial CreateProductAssetPeriodDto Map(CreateProductAssetPeriodViewModel source);
public override partial void Map(CreateProductAssetPeriodViewModel source, CreateProductAssetPeriodDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class EditProductAssetPeriodViewModelToUpdateProductAssetPeriodDtoMapper : MapperBase<EditProductAssetPeriodViewModel, UpdateProductAssetPeriodDto>
{
public override partial UpdateProductAssetPeriodDto Map(EditProductAssetPeriodViewModel source);
public override partial void Map(EditProductAssetPeriodViewModel source, UpdateProductAssetPeriodDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetCategoryDtoToEditProductAssetCategoryViewModelMapper : MapperBase<ProductAssetCategoryDto, EditProductAssetCategoryViewModel>
{
public override partial EditProductAssetCategoryViewModel Map(ProductAssetCategoryDto source);
public override partial void Map(ProductAssetCategoryDto source, EditProductAssetCategoryViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateProductAssetCategoryViewModelToCreateProductAssetCategoryDtoMapper : MapperBase<CreateProductAssetCategoryViewModel, CreateProductAssetCategoryDto>
{
public override partial CreateProductAssetCategoryDto Map(CreateProductAssetCategoryViewModel source);
public override partial void Map(CreateProductAssetCategoryViewModel source, CreateProductAssetCategoryDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class EditProductAssetCategoryViewModelToUpdateProductAssetCategoryDtoMapper : MapperBase<EditProductAssetCategoryViewModel, UpdateProductAssetCategoryDto>
{
public override partial UpdateProductAssetCategoryDto Map(EditProductAssetCategoryViewModel source);
public override partial void Map(EditProductAssetCategoryViewModel source, UpdateProductAssetCategoryDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ProductAssetCategoryPeriodDtoToEditProductAssetCategoryPeriodViewModelMapper : MapperBase<ProductAssetCategoryPeriodDto, EditProductAssetCategoryPeriodViewModel>
{
public override partial EditProductAssetCategoryPeriodViewModel Map(ProductAssetCategoryPeriodDto source);
public override partial void Map(ProductAssetCategoryPeriodDto source, EditProductAssetCategoryPeriodViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateProductAssetCategoryPeriodViewModelToCreateProductAssetCategoryPeriodDtoMapper : MapperBase<CreateProductAssetCategoryPeriodViewModel, CreateProductAssetCategoryPeriodDto>
{
public override partial CreateProductAssetCategoryPeriodDto Map(CreateProductAssetCategoryPeriodViewModel source);
public override partial void Map(CreateProductAssetCategoryPeriodViewModel source, CreateProductAssetCategoryPeriodDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class EditProductAssetCategoryPeriodViewModelToUpdateProductAssetCategoryPeriodDtoMapper : MapperBase<EditProductAssetCategoryPeriodViewModel, UpdateProductAssetCategoryPeriodDto>
{
public override partial UpdateProductAssetCategoryPeriodDto Map(EditProductAssetCategoryPeriodViewModel source);
public override partial void Map(EditProductAssetCategoryPeriodViewModel source, UpdateProductAssetCategoryPeriodDto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class GrantedStoreDtoToCreateEditGrantedStoreViewModelMapper : MapperBase<GrantedStoreDto, CreateEditGrantedStoreViewModel>
{
public override partial CreateEditGrantedStoreViewModel Map(GrantedStoreDto source);
public override partial void Map(GrantedStoreDto source, CreateEditGrantedStoreViewModel destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class CreateEditGrantedStoreViewModelToCreateUpdateGrantedStoreDtoMapper : MapperBase<CreateEditGrantedStoreViewModel, CreateUpdateGrantedStoreDto>
{
public override partial CreateUpdateGrantedStoreDto Map(CreateEditGrantedStoreViewModel source);
public override partial void Map(CreateEditGrantedStoreViewModel source, CreateUpdateGrantedStoreDto destination);
}
}

10
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EShopPluginsBookingWebModule.cs

@ -8,7 +8,7 @@ using EasyAbp.EShop.Products;
using EasyAbp.EShop.Stores;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -22,7 +22,7 @@ namespace EasyAbp.EShop.Plugins.Booking.Web;
typeof(EShopStoresApplicationContractsModule),
typeof(EShopPluginsBookingApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule)
typeof(AbpMapperlyModule)
)]
public class EShopPluginsBookingWebModule : AbpModule
{
@ -51,11 +51,7 @@ public class EShopPluginsBookingWebModule : AbpModule
options.FileSets.AddEmbedded<EShopPluginsBookingWebModule>();
});
context.Services.AddAutoMapperObjectMapper<EShopPluginsBookingWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopPluginsBookingWebModule>(validate: true);
});
context.Services.AddMapperlyObjectMapper<EShopPluginsBookingWebModule>();
Configure<RazorPagesOptions>(options =>
{

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save