From cf4c3461c4950de42c18a1cd88c4e034eff69a40 Mon Sep 17 00:00:00 2001 From: Super Date: Fri, 24 Jul 2026 20:18:02 +0800 Subject: [PATCH] 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 * Fix sample proj's abp version --------- Co-authored-by: Claude Opus 4.8 --- .../EasyAbp.EShop.Application.csproj | 2 +- .../EShopApplicationAutoMapperProfile.cs | 14 -- .../EasyAbp/EShop/EShopApplicationModule.cs | 10 +- .../EShopWebAutoMapperProfile.cs | 14 -- .../src/EasyAbp.EShop.Web/EShopWebModule.cs | 10 +- .../EasyAbp.EShop.Web.csproj | 2 +- .../EasyAbp.EShop.Orders.Application.csproj | 3 +- .../Orders/EShopOrdersApplicationModule.cs | 10 +- .../OrdersApplicationAutoMapperProfile.cs | 21 -- .../OrdersApplicationMapperlyMappers.cs | 39 ++++ .../EasyAbp.EShop.Orders.Domain.csproj | 3 +- .../EShop/Orders/EShopOrdersDomainModule.cs | 11 +- .../Orders/OrdersDomainAutoMapperProfile.cs | 19 -- .../Orders/OrdersDomainMapperlyMappers.cs | 38 ++++ .../EShopOrdersWebModule.cs | 10 +- .../EasyAbp.EShop.Orders.Web.csproj | 2 +- .../OrdersWebAutoMapperProfile.cs | 16 -- .../Orders/OrderExtraFeeMapperlyTests.cs | 32 +++ .../EasyAbp.EShop.Payments.Application.csproj | 3 +- .../EShopPaymentsApplicationModule.cs | 10 +- .../PaymentsApplicationAutoMapperProfile.cs | 23 --- .../PaymentsApplicationMapperlyMappers.cs | 49 +++++ .../EasyAbp.EShop.Payments.Domain.csproj | 3 +- .../Payments/EShopPaymentsDomainModule.cs | 11 +- .../EShop/Payments/Payments/Payment.cs | 53 +++++ .../EShop/Payments/Payments/PaymentItem.cs | 35 ++++ .../Payments/Payments/PaymentSynchronizer.cs | 60 +++++- .../PaymentsDomainAutoMapperProfile.cs | 39 ---- .../Payments/PaymentsDomainMapperlyMappers.cs | 55 ++++++ .../EasyAbp/EShop/Payments/Refunds/Refund.cs | 44 +++++ .../EShop/Payments/Refunds/RefundItem.cs | 28 +++ .../Refunds/RefundItemOrderExtraFee.cs | 2 - .../Payments/Refunds/RefundItemOrderLine.cs | 2 - .../Payments/Refunds/RefundSynchronizer.cs | 58 +++++- .../EShopPaymentsWebModule.cs | 10 +- .../EasyAbp.EShop.Payments.Web.csproj | 2 +- .../PaymentsWebAutoMapperProfile.cs | 15 -- .../Payments/PaymentItemMapperlyTests.cs | 33 ++++ .../EasyAbp.EShop.Plugins.Application.csproj | 2 +- .../Plugins/EShopPluginsApplicationModule.cs | 10 +- .../PluginsApplicationAutoMapperProfile.cs | 14 -- .../EShopPluginsWebModule.cs | 10 +- .../EasyAbp.EShop.Plugins.Web.csproj | 2 +- .../PluginsWebAutoMapperProfile.cs | 14 -- .../EasyAbp.EShop.Products.Application.csproj | 3 +- .../EShopProductsApplicationModule.cs | 15 +- .../ProductCategoryAppService.cs | 2 + .../ProductDetails/ProductDetailAppService.cs | 18 +- .../Products/Products/ProductAppService.cs | 2 + .../Products/ProductViewAppService.cs | 2 + .../ProductsApplicationAutoMapperProfile.cs | 50 ----- .../ProductsApplicationMapperlyMappers.cs | 138 +++++++++++++ .../EasyAbp.EShop.Products.Domain.csproj | 3 +- .../Products/EShopProductsDomainModule.cs | 11 +- .../Products/ProductDetails/ProductDetail.cs | 6 + .../ProductsDomainAutoMapperProfile.cs | 19 -- .../Products/ProductsDomainMapperlyMappers.cs | 38 ++++ .../EShopProductsWebModule.cs | 10 +- .../EasyAbp.EShop.Products.Web.csproj | 3 +- .../ProductsWebAutoMapperProfile.cs | 82 -------- .../ProductsWebMapperlyMappers.cs | 186 ++++++++++++++++++ .../ProductDetailMapperlyTests.cs | 32 +++ ...Abp.EShop.Stores.Application.Shared.csproj | 2 +- .../EShopStoresApplicationSharedModule.cs | 4 +- .../EasyAbp.EShop.Stores.Application.csproj | 3 +- .../Stores/EShopStoresApplicationModule.cs | 10 +- .../StoreOwners/StoreOwnerAppService.cs | 20 ++ .../EShop/Stores/Stores/StoreAppService.cs | 19 ++ .../StoresApplicationAutoMapperProfile.cs | 31 --- .../StoresApplicationMapperlyMappers.cs | 37 ++++ .../Transactions/TransactionAppService.cs | 22 +++ .../EShop/Stores/StoreOwners/StoreOwner.cs | 6 + .../EasyAbp/EShop/Stores/Stores/Store.cs | 5 + .../EShop/Stores/Transactions/Transaction.cs | 16 ++ .../EShopStoresWebModule.cs | 10 +- .../EasyAbp.EShop.Stores.Web.csproj | 3 +- .../StoresWebAutoMapperProfile.cs | 33 ---- .../StoresWebMapperlyMappers.cs | 65 ++++++ .../Stores/StoreMapperlyTests.cs | 30 +++ ...p.EShop.Plugins.Baskets.Application.csproj | 3 +- .../BasketsApplicationAutoMapperProfile.cs | 17 -- .../BasketsApplicationMapperlyMappers.cs | 15 ++ .../EShopPluginsBasketsApplicationModule.cs | 10 +- .../BasketsWebAutoMapperProfile.cs | 26 --- .../BasketsWebMapperlyMappers.cs | 47 +++++ .../EShopPluginsBasketsWebModule.cs | 10 +- .../EasyAbp.EShop.Plugins.Baskets.Web.csproj | 3 +- ...p.EShop.Plugins.Booking.Application.csproj | 3 +- .../BookingApplicationAutoMapperProfile.cs | 33 ---- .../BookingApplicationMapperlyMappers.cs | 64 ++++++ .../EShopPluginsBookingApplicationModule.cs | 10 +- .../GrantedStores/GrantedStoreAppService.cs | 14 ++ .../ProductAssetCategoryAppService.cs | 4 +- .../ProductAssets/ProductAssetAppService.cs | 4 +- .../Booking/GrantedStores/GrantedStore.cs | 8 + .../ProductAssetCategoryPeriod.cs | 6 + .../ProductAssets/ProductAssetPeriod.cs | 6 + .../BookingWebAutoMapperProfile.cs | 39 ---- .../BookingWebMapperlyMappers.cs | 125 ++++++++++++ .../EShopPluginsBookingWebModule.cs | 10 +- .../EasyAbp.EShop.Plugins.Booking.Web.csproj | 3 +- ...p.EShop.Plugins.Coupons.Application.csproj | 3 +- .../CouponTemplateAppService.cs | 19 ++ .../Coupons/Coupons/CouponAppService.cs | 13 ++ .../CouponsApplicationAutoMapperProfile.cs | 31 --- .../CouponsApplicationMapperlyMappers.cs | 35 ++++ .../EShopPluginsCouponsApplicationModule.cs | 10 +- ...asyAbp.EShop.Plugins.Coupons.Domain.csproj | 3 +- .../Coupons/CouponTemplates/CouponTemplate.cs | 28 +++ .../Coupons/CouponsDomainAutoMapperProfile.cs | 20 -- .../Coupons/CouponsDomainMapperlyMappers.cs | 31 +++ .../EShopPluginsCouponsDomainModule.cs | 10 +- ...Shop.Plugins.Coupons.HttpApi.Client.csproj | 3 +- .../CouponsHttpApiClientAutoMapperProfile.cs | 22 --- .../CouponsHttpApiClientMapperlyMappers.cs | 33 ++++ .../EShopPluginsCouponsHttpApiClientModule.cs | 10 +- .../CouponsWebAutoMapperProfile.cs | 30 --- .../CouponsWebMapperlyMappers.cs | 84 ++++++++ .../EShopPluginsCouponsWebModule.cs | 10 +- .../EasyAbp.EShop.Plugins.Coupons.Web.csproj | 3 +- ...rdersPluginsFlashSalesApplicationModule.cs | 8 +- ...Shop.Plugins.FlashSales.Application.csproj | 3 +- ...EShopPluginsFlashSalesApplicationModule.cs | 10 +- .../FlashSalePlans/FlashSalePlanAppService.cs | 2 + .../FlashSaleResultAppService.cs | 2 + .../FlashSalesApplicationAutoMapperProfile.cs | 41 ---- .../FlashSalesApplicationMapperlyMappers.cs | 56 ++++++ ...Abp.EShop.Plugins.FlashSales.Domain.csproj | 3 +- ...luginsFlashSalesDomainAutoMapperProfile.cs | 16 -- .../EShopPluginsFlashSalesDomainModule.cs | 10 +- .../FlashSalesDomainMapperlyMappers.cs | 15 ++ ...opPluginsFlashSalesWebAutoMapperProfile.cs | 25 --- .../EShopPluginsFlashSalesWebModule.cs | 10 +- ...asyAbp.EShop.Plugins.FlashSales.Web.csproj | 3 +- .../FlashSalesWebMapperlyMappers.cs | 45 +++++ ...Shop.Plugins.Promotions.Application.csproj | 3 +- ...EShopPluginsPromotionsApplicationModule.cs | 10 +- .../PromotionsApplicationAutoMapperProfile.cs | 16 -- .../PromotionsApplicationMapperlyMappers.cs | 15 ++ .../EShopPluginsPromotionsWebModule.cs | 10 +- ...asyAbp.EShop.Plugins.Promotions.Web.csproj | 3 +- .../PromotionsWebAutoMapperProfile.cs | 16 -- .../PromotionsWebMapperlyMappers.cs | 15 ++ ...EShopSampleApplicationAutoMapperProfile.cs | 14 -- .../EShopSampleApplicationModule.cs | 6 +- .../EShopSample.Web/EShopSample.Web.csproj | 2 +- .../EShopSampleWebAutoMapperProfile.cs | 12 -- .../EShopSample.Web/EShopSampleWebModule.cs | 7 +- 148 files changed, 1977 insertions(+), 1038 deletions(-) delete mode 100644 integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationAutoMapperProfile.cs delete mode 100644 integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebAutoMapperProfile.cs delete mode 100644 modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationMapperlyMappers.cs delete mode 100644 modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainMapperlyMappers.cs delete mode 100644 modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/OrdersWebAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderExtraFeeMapperlyTests.cs delete mode 100644 modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationMapperlyMappers.cs delete mode 100644 modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainMapperlyMappers.cs delete mode 100644 modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/PaymentsWebAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/PaymentItemMapperlyTests.cs delete mode 100644 modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/PluginsApplicationAutoMapperProfile.cs delete mode 100644 modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/PluginsWebAutoMapperProfile.cs delete mode 100644 modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationMapperlyMappers.cs delete mode 100644 modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainMapperlyMappers.cs delete mode 100644 modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebMapperlyMappers.cs create mode 100644 modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Application.Tests/ProductDetails/ProductDetailMapperlyTests.cs delete mode 100644 modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationMapperlyMappers.cs delete mode 100644 modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs create mode 100644 modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebMapperlyMappers.cs create mode 100644 modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Application.Tests/Stores/StoreMapperlyTests.cs delete mode 100644 plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationAutoMapperProfile.cs create mode 100644 plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationMapperlyMappers.cs delete mode 100644 plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebAutoMapperProfile.cs create mode 100644 plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebMapperlyMappers.cs delete mode 100644 plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationAutoMapperProfile.cs create mode 100644 plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationMapperlyMappers.cs delete mode 100644 plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebAutoMapperProfile.cs create mode 100644 plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebMapperlyMappers.cs delete mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationAutoMapperProfile.cs create mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationMapperlyMappers.cs delete mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainAutoMapperProfile.cs create mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainMapperlyMappers.cs delete mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientAutoMapperProfile.cs create mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientMapperlyMappers.cs delete mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebAutoMapperProfile.cs create mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebMapperlyMappers.cs delete mode 100644 plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationAutoMapperProfile.cs create mode 100644 plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationMapperlyMappers.cs delete mode 100644 plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainAutoMapperProfile.cs create mode 100644 plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/FlashSalesDomainMapperlyMappers.cs delete mode 100644 plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebAutoMapperProfile.cs create mode 100644 plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/FlashSalesWebMapperlyMappers.cs delete mode 100644 plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationAutoMapperProfile.cs create mode 100644 plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationMapperlyMappers.cs delete mode 100644 plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebAutoMapperProfile.cs create mode 100644 plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebMapperlyMappers.cs delete mode 100644 samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationAutoMapperProfile.cs delete mode 100644 samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebAutoMapperProfile.cs diff --git a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp.EShop.Application.csproj b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp.EShop.Application.csproj index 28da91ce..bd5ea079 100644 --- a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp.EShop.Application.csproj +++ b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp.EShop.Application.csproj @@ -8,7 +8,7 @@ - + diff --git a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationAutoMapperProfile.cs b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationAutoMapperProfile.cs deleted file mode 100644 index b315681f..00000000 --- a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationAutoMapperProfile.cs +++ /dev/null @@ -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. */ - } - } -} \ No newline at end of file diff --git a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationModule.cs b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationModule.cs index 493a6b29..35ea3fa6 100644 --- a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp/EShop/EShopApplicationModule.cs +++ b/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(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebAutoMapperProfile.cs b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebAutoMapperProfile.cs deleted file mode 100644 index 447c409d..00000000 --- a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebAutoMapperProfile.cs +++ /dev/null @@ -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. */ - } - } -} \ No newline at end of file diff --git a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebModule.cs b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebModule.cs index 4514591c..f5575af6 100644 --- a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EShopWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EasyAbp.EShop.Web.csproj b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EasyAbp.EShop.Web.csproj index 23a1a337..576c8293 100644 --- a/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EasyAbp.EShop.Web.csproj +++ b/integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EasyAbp.EShop.Web.csproj @@ -12,7 +12,7 @@ - + diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp.EShop.Orders.Application.csproj b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp.EShop.Orders.Application.csproj index 95cd3aef..fc8d51b0 100644 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp.EShop.Orders.Application.csproj +++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp.EShop.Orders.Application.csproj @@ -8,7 +8,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/EShopOrdersApplicationModule.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/EShopOrdersApplicationModule.cs index 25c8d856..89b9b9a9 100644 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/EShopOrdersApplicationModule.cs +++ b/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(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs deleted file mode 100644 index 3b431128..00000000 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs +++ /dev/null @@ -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(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationMapperlyMappers.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationMapperlyMappers.cs new file mode 100644 index 00000000..72cb6d46 --- /dev/null +++ b/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 + { + 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 + { + 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 + { + 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 + { + public override partial OrderExtraFeeDto Map(OrderExtraFee source); + + public override partial void Map(OrderExtraFee source, OrderExtraFeeDto destination); + } +} diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp.EShop.Orders.Domain.csproj b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp.EShop.Orders.Domain.csproj index 93b70c31..6cad8efd 100644 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp.EShop.Orders.Domain.csproj +++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp.EShop.Orders.Domain.csproj @@ -15,7 +15,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/EShopOrdersDomainModule.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/EShopOrdersDomainModule.cs index da176ca2..403ae064 100644 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/EShopOrdersDomainModule.cs +++ b/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(); - - Configure(options => - { - options.AddProfile(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs deleted file mode 100644 index 4b0cac9c..00000000 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs +++ /dev/null @@ -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(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainMapperlyMappers.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainMapperlyMappers.cs new file mode 100644 index 00000000..3febe6f0 --- /dev/null +++ b/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 + { + 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 + { + 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 + { + 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 + { + public override partial OrderExtraFeeEto Map(OrderExtraFee source); + + public override partial void Map(OrderExtraFee source, OrderExtraFeeEto destination); + } +} diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EShopOrdersWebModule.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EShopOrdersWebModule.cs index 3e6c1b02..e8c1377e 100644 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EShopOrdersWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EasyAbp.EShop.Orders.Web.csproj b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EasyAbp.EShop.Orders.Web.csproj index 5fa22f63..e30988c3 100644 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EasyAbp.EShop.Orders.Web.csproj +++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EasyAbp.EShop.Orders.Web.csproj @@ -12,7 +12,7 @@ - + diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/OrdersWebAutoMapperProfile.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/OrdersWebAutoMapperProfile.cs deleted file mode 100644 index 91d84b9e..00000000 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/OrdersWebAutoMapperProfile.cs +++ /dev/null @@ -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. */ - } - } -} diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderExtraFeeMapperlyTests.cs b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderExtraFeeMapperlyTests.cs new file mode 100644 index 00000000..5fc03761 --- /dev/null +++ b/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 _objectMapper; + + public OrderExtraFeeMapperlyTests() + { + _objectMapper = GetRequiredService>(); + } + + [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(entity); + + dto.ShouldNotBeNull(); + dto.Name.ShouldBe("Shipping"); + dto.Key.ShouldBe("shipping-key"); + dto.DisplayName.ShouldBe("Shipping Fee"); + dto.Fee.ShouldBe(12.5m); + } + } +} diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp.EShop.Payments.Application.csproj b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp.EShop.Payments.Application.csproj index 30d9c933..446ca1f6 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp.EShop.Payments.Application.csproj +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp.EShop.Payments.Application.csproj @@ -8,7 +8,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/EShopPaymentsApplicationModule.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/EShopPaymentsApplicationModule.cs index 9f29dd75..7ca0e050 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/EShopPaymentsApplicationModule.cs +++ b/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(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationAutoMapperProfile.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationAutoMapperProfile.cs deleted file mode 100644 index 7b54f6ca..00000000 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationAutoMapperProfile.cs +++ /dev/null @@ -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(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationMapperlyMappers.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/PaymentsApplicationMapperlyMappers.cs new file mode 100644 index 00000000..99438fb4 --- /dev/null +++ b/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 + { + 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 + { + 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 + { + 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 + { + 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 + { + public override partial RefundItemOrderLineDto Map(RefundItemOrderLine source); + + public override partial void Map(RefundItemOrderLine source, RefundItemOrderLineDto destination); + } +} diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp.EShop.Payments.Domain.csproj b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp.EShop.Payments.Domain.csproj index 251374dc..a8a2c6ff 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp.EShop.Payments.Domain.csproj +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp.EShop.Payments.Domain.csproj @@ -8,7 +8,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/EShopPaymentsDomainModule.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/EShopPaymentsDomainModule.cs index 70a0621b..5b86ee7b 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/EShopPaymentsDomainModule.cs +++ b/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(); - - Configure(options => - { - options.AddProfile(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs index e1c42c61..c4e99b7a 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs +++ b/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 paymentItems) { PaymentItems = paymentItems; diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentItem.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentItem.cs index bdbd08d5..96c6b3e9 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentItem.cs +++ b/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; + } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentSynchronizer.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentSynchronizer.cs index fd5f7ac3..0b2c4c31 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentSynchronizer.cs +++ b/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(eventData.Entity); + payment = CreatePayment(eventData.Entity); + + payment.SetPaymentItems(eventData.Entity.PaymentItems.Select(CreatePaymentItem).ToList()); - payment.SetPaymentItems( - _objectMapper.Map, List>(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(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(nameof(PaymentItem.StoreId)); diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainAutoMapperProfile.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainAutoMapperProfile.cs deleted file mode 100644 index 97b7c78f..00000000 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainAutoMapperProfile.cs +++ /dev/null @@ -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(MemberList.Source) - .ForSourceMember(x => x.PaymentItems, x => x.DoNotValidate()) - .Ignore(x => x.PaymentItems); - CreateMap(MemberList.Source) - .Ignore(x => x.StoreId); - - CreateMap(MemberList.Source) - .ForSourceMember(x => x.RefundItems, x => x.DoNotValidate()) - .Ignore(x => x.RefundItems); - CreateMap(MemberList.Source) - .Ignore(x => x.StoreId) - .Ignore(x => x.OrderId); - - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainMapperlyMappers.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/PaymentsDomainMapperlyMappers.cs new file mode 100644 index 00000000..85487538 --- /dev/null +++ b/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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + public override partial RefundItemOrderExtraFeeEto Map(RefundItemOrderExtraFee source); + + public override partial void Map(RefundItemOrderExtraFee source, RefundItemOrderExtraFeeEto destination); + } +} diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs index 167a49b5..1866a15f 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs +++ b/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 refundItems) { RefundItems = refundItems; diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItem.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItem.cs index bee14c4d..bc39143d 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItem.cs +++ b/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(); + OrderExtraFees = new List(); + + 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; diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs index 8f6d4482..b05580f2 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs +++ b/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 { [NotNull] diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderLine.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderLine.cs index d4ec7cb6..19f761c6 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderLine.cs +++ b/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 { public virtual Guid OrderLineId { get; protected set; } diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs index 4b68da31..36f2d234 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs +++ b/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(eventData.Entity); + refund = CreateRefund(eventData.Entity); - refund.SetRefundItems( - _objectMapper.Map, List>(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(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(nameof(RefundItem.StoreId)); diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EShopPaymentsWebModule.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EShopPaymentsWebModule.cs index 15949109..83854142 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EShopPaymentsWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EasyAbp.EShop.Payments.Web.csproj b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EasyAbp.EShop.Payments.Web.csproj index e0061d26..ea927f96 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EasyAbp.EShop.Payments.Web.csproj +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EasyAbp.EShop.Payments.Web.csproj @@ -12,7 +12,7 @@ - + diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/PaymentsWebAutoMapperProfile.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/PaymentsWebAutoMapperProfile.cs deleted file mode 100644 index 938036d4..00000000 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/PaymentsWebAutoMapperProfile.cs +++ /dev/null @@ -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. */ - } - } -} diff --git a/modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/PaymentItemMapperlyTests.cs b/modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/PaymentItemMapperlyTests.cs new file mode 100644 index 00000000..a2dd23dc --- /dev/null +++ b/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 _objectMapper; + + public PaymentItemMapperlyTests() + { + _objectMapper = GetRequiredService>(); + } + + [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(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); + } + } +} diff --git a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp.EShop.Plugins.Application.csproj b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp.EShop.Plugins.Application.csproj index cbf06476..78061e34 100644 --- a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp.EShop.Plugins.Application.csproj +++ b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp.EShop.Plugins.Application.csproj @@ -8,7 +8,7 @@ - + diff --git a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/EShopPluginsApplicationModule.cs b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/EShopPluginsApplicationModule.cs index b6018530..917b7eb1 100644 --- a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/EShopPluginsApplicationModule.cs +++ b/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(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/PluginsApplicationAutoMapperProfile.cs b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/PluginsApplicationAutoMapperProfile.cs deleted file mode 100644 index f4bb6c1c..00000000 --- a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp/EShop/Plugins/PluginsApplicationAutoMapperProfile.cs +++ /dev/null @@ -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. */ - } - } -} \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EShopPluginsWebModule.cs b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EShopPluginsWebModule.cs index 0ce433c1..7dbfe203 100644 --- a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EShopPluginsWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EasyAbp.EShop.Plugins.Web.csproj b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EasyAbp.EShop.Plugins.Web.csproj index f7a6548f..90890038 100644 --- a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EasyAbp.EShop.Plugins.Web.csproj +++ b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EasyAbp.EShop.Plugins.Web.csproj @@ -12,7 +12,7 @@ - + diff --git a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/PluginsWebAutoMapperProfile.cs b/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/PluginsWebAutoMapperProfile.cs deleted file mode 100644 index ee95af25..00000000 --- a/modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/PluginsWebAutoMapperProfile.cs +++ /dev/null @@ -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. */ - } - } -} \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp.EShop.Products.Application.csproj b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp.EShop.Products.Application.csproj index 5c003d79..1c6cd521 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp.EShop.Products.Application.csproj +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp.EShop.Products.Application.csproj @@ -9,7 +9,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/EShopProductsApplicationModule.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/EShopProductsApplicationModule.cs index c9479ec1..17418682 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/EShopProductsApplicationModule.cs +++ b/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(options => - { - options.Configurators.Add(abpAutoMapperConfigurationContext => - { - var profile = abpAutoMapperConfigurationContext.ServiceProvider - .GetRequiredService(); - - abpAutoMapperConfigurationContext.MapperConfiguration.AddProfile(profile); - }); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductCategories/ProductCategoryAppService.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductCategories/ProductCategoryAppService.cs index 991d7fd3..1765ce91 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductCategories/ProductCategoryAppService.cs +++ b/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> CreateFilteredQueryAsync( diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductDetails/ProductDetailAppService.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductDetails/ProductDetailAppService.cs index c8da8cd8..e05e1bb9 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductDetails/ProductDetailAppService.cs +++ b/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 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; + } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs index 15df94f0..78c4bbe5 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs +++ b/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> CreateFilteredQueryAsync(GetProductListInput input) diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductViewAppService.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductViewAppService.cs index a4ec2dd1..6a74cde4 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductViewAppService.cs +++ b/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> CreateFilteredQueryAsync(GetProductListInput input) diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs deleted file mode 100644 index f7cb401e..00000000 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs +++ /dev/null @@ -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() - .Ignore(dto => dto.ProductGroupDisplayName) - .Ignore(dto => dto.Sold) - .Ignore(dto => dto.MinimumPrice) - .Ignore(dto => dto.MaximumPrice); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap() - .Ignore(dto => dto.Price) - .Ignore(dto => dto.Inventory) - .Ignore(dto => dto.Sold); - CreateMap(MemberList.Source) - .ForSourceMember(dto => dto.StoreId, opt => opt.DoNotValidate()); - CreateMap(MemberList.Source); - CreateMap(MemberList.Source); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationMapperlyMappers.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationMapperlyMappers.cs new file mode 100644 index 00000000..53e57e68 --- /dev/null +++ b/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 + { + [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 + { + 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 + { + [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 + { + 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 + { + [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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + public override partial ProductViewDto Map(ProductView source); + + public override partial void Map(ProductView source, ProductViewDto destination); + } +} diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp.EShop.Products.Domain.csproj b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp.EShop.Products.Domain.csproj index b771d6de..b5f609c2 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp.EShop.Products.Domain.csproj +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp.EShop.Products.Domain.csproj @@ -11,7 +11,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/EShopProductsDomainModule.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/EShopProductsDomainModule.cs index e03e51f8..6f0f0d52 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/EShopProductsDomainModule.cs +++ b/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(); - - Configure(options => - { - options.AddProfile(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductDetails/ProductDetail.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductDetails/ProductDetail.cs index 74276624..2084d22d 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductDetails/ProductDetail.cs +++ b/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; + } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainAutoMapperProfile.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainAutoMapperProfile.cs deleted file mode 100644 index 607492bd..00000000 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainAutoMapperProfile.cs +++ /dev/null @@ -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(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainMapperlyMappers.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/ProductsDomainMapperlyMappers.cs new file mode 100644 index 00000000..d9fd9527 --- /dev/null +++ b/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 + { + 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 + { + 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 + { + 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 + { + public override partial ProductSkuEto Map(ProductSku source); + + public override partial void Map(ProductSku source, ProductSkuEto destination); + } +} diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EShopProductsWebModule.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EShopProductsWebModule.cs index 7be21c7d..53f8b856 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EShopProductsWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EasyAbp.EShop.Products.Web.csproj b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EasyAbp.EShop.Products.Web.csproj index be07ca6c..f62bd62e 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EasyAbp.EShop.Products.Web.csproj +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EasyAbp.EShop.Products.Web.csproj @@ -12,7 +12,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebAutoMapperProfile.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebAutoMapperProfile.cs deleted file mode 100644 index 8d626543..00000000 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebAutoMapperProfile.cs +++ /dev/null @@ -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() - .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() - .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( - x.ProductAttributeOptionNames.SplitToLines(StringSplitOptions.RemoveEmptyEntries)[i] - .Split(",", StringSplitOptions.RemoveEmptyEntries).Select(o => - new CreateUpdateProductAttributeOptionDto {DisplayName = o.RemovePostFix("\r")})) - }))); - CreateMap(); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - CreateMap(); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - CreateMap() - .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() - .Ignore(dto => dto.ProductDetailId) - .ForSourceMember(model => model.ProductDetail, opt => opt.DoNotValidate()) - .Ignore(dto => dto.ExtraProperties); - CreateMap() - .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(); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - CreateMap(MemberList.Destination); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - } - } -} diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebMapperlyMappers.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/ProductsWebMapperlyMappers.cs new file mode 100644 index 00000000..7f24132a --- /dev/null +++ b/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 + { + [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 + { + [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( + 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 + { + 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 + { + [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 + { + [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 + { + 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 + { + [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 + { + [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 + { + [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 + { + [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 + { + 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 + { + [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 + { + 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 + { + [MapperIgnoreTarget(nameof(CreateUpdateCategoryDto.ExtraProperties))] + public override partial CreateUpdateCategoryDto Map(CreateEditCategoryViewModel source); + + [MapperIgnoreTarget(nameof(CreateUpdateCategoryDto.ExtraProperties))] + public override partial void Map(CreateEditCategoryViewModel source, CreateUpdateCategoryDto destination); + } +} diff --git a/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Application.Tests/ProductDetails/ProductDetailMapperlyTests.cs b/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Application.Tests/ProductDetails/ProductDetailMapperlyTests.cs new file mode 100644 index 00000000..d1d1bb47 --- /dev/null +++ b/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 _objectMapper; + + public ProductDetailMapperlyTests() + { + _objectMapper = GetRequiredService>(); + } + + [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(entity); + + dto.ShouldNotBeNull(); + dto.Id.ShouldBe(entity.Id); + dto.StoreId.ShouldBe(storeId); + dto.Description.ShouldBe("A description"); + } + } +} diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp.EShop.Stores.Application.Shared.csproj b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp.EShop.Stores.Application.Shared.csproj index a57d8c49..7e70c828 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp.EShop.Stores.Application.Shared.csproj +++ b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp.EShop.Stores.Application.Shared.csproj @@ -8,7 +8,7 @@ - + diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp/EShop/Stores/EShopStoresApplicationSharedModule.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp/EShop/Stores/EShopStoresApplicationSharedModule.cs index d33ae762..c323a90d 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Shared/EasyAbp/EShop/Stores/EShopStoresApplicationSharedModule.cs +++ b/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 { diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp.EShop.Stores.Application.csproj b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp.EShop.Stores.Application.csproj index acfddfe6..07f602bf 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp.EShop.Stores.Application.csproj +++ b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp.EShop.Stores.Application.csproj @@ -8,7 +8,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/EShopStoresApplicationModule.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/EShopStoresApplicationModule.cs index df4a793c..2ed867ad 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/EShopStoresApplicationModule.cs +++ b/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(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerAppService.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerAppService.cs index c2c21a60..d88fa480 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerAppService.cs +++ b/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 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; + } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Stores/StoreAppService.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Stores/StoreAppService.cs index 468ededf..cdcee6cb 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Stores/StoreAppService.cs +++ b/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(await _repository.FindDefaultStoreAsync()); } + + protected override Task 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; + } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs deleted file mode 100644 index 73ea1e75..00000000 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs +++ /dev/null @@ -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(); - CreateMap(MemberList.Source); - - CreateMap() - .Ignore(dto => dto.OwnerUserName); - CreateMap(MemberList.Source); - - CreateMap(); - CreateMap(MemberList.Source); - } - } -} diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationMapperlyMappers.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationMapperlyMappers.cs new file mode 100644 index 00000000..c968d775 --- /dev/null +++ b/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 + { + 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 + { + [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 + { + public override partial TransactionDto Map(Transaction source); + + public override partial void Map(Transaction source, TransactionDto destination); + } +} diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Transactions/TransactionAppService.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Transactions/TransactionAppService.cs index 9e0b3c37..3defd962 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Transactions/TransactionAppService.cs +++ b/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 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; + } } } diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwner.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwner.cs index e006b68c..1e5fd107 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwner.cs +++ b/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; + } } } diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/Store.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/Store.cs index ce7c9f7b..c445b975 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/Store.cs +++ b/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; + } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/Transaction.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/Transaction.cs index e673b024..13fa47e2 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/Transaction.cs +++ b/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; + } } } diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EShopStoresWebModule.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EShopStoresWebModule.cs index 07e4079b..c4c3f6b7 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EShopStoresWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj index b1e6de31..6a12d1cc 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj +++ b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj @@ -13,7 +13,8 @@ - + + diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs deleted file mode 100644 index 08974e83..00000000 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs +++ /dev/null @@ -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(); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - - CreateMap(); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - - CreateMap(); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - } - } -} diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebMapperlyMappers.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebMapperlyMappers.cs new file mode 100644 index 00000000..f8e7e63a --- /dev/null +++ b/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 + { + 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 + { + [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 + { + 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 + { + [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 + { + 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 + { + [MapperIgnoreTarget(nameof(CreateUpdateTransactionDto.ExtraProperties))] + public override partial CreateUpdateTransactionDto Map(CreateEditTransactionViewModel source); + + [MapperIgnoreTarget(nameof(CreateUpdateTransactionDto.ExtraProperties))] + public override partial void Map(CreateEditTransactionViewModel source, CreateUpdateTransactionDto destination); + } +} diff --git a/modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Application.Tests/Stores/StoreMapperlyTests.cs b/modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Application.Tests/Stores/StoreMapperlyTests.cs new file mode 100644 index 00000000..135d0e76 --- /dev/null +++ b/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 _objectMapper; + + public StoreMapperlyTests() + { + _objectMapper = GetRequiredService>(); + } + + [Fact] + public void Should_Map_Store_To_StoreDto() + { + var entity = new Store(Guid.NewGuid(), null, "Test Store"); + + var dto = _objectMapper.Map(entity); + + dto.ShouldNotBeNull(); + dto.Id.ShouldBe(entity.Id); + dto.Name.ShouldBe("Test Store"); + } + } +} diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp.EShop.Plugins.Baskets.Application.csproj b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp.EShop.Plugins.Baskets.Application.csproj index b4a24a48..c63592b3 100644 --- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp.EShop.Plugins.Baskets.Application.csproj +++ b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp.EShop.Plugins.Baskets.Application.csproj @@ -8,7 +8,8 @@ - + + diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationAutoMapperProfile.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationAutoMapperProfile.cs deleted file mode 100644 index 7db183f1..00000000 --- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationAutoMapperProfile.cs +++ /dev/null @@ -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(); - } - } -} diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationMapperlyMappers.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketsApplicationMapperlyMappers.cs new file mode 100644 index 00000000..140295b7 --- /dev/null +++ b/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 + { + public override partial BasketItemDto Map(BasketItem source); + + public override partial void Map(BasketItem source, BasketItemDto destination); + } +} diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/EShopPluginsBasketsApplicationModule.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/EShopPluginsBasketsApplicationModule.cs index 774cc3ed..3e2bf829 100644 --- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/EShopPluginsBasketsApplicationModule.cs +++ b/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(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebAutoMapperProfile.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebAutoMapperProfile.cs deleted file mode 100644 index d082bfe6..00000000 --- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebAutoMapperProfile.cs +++ /dev/null @@ -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() - .Ignore(dto => dto.ExtraProperties); - CreateMap(); - CreateMap() - .Ignore(dto => dto.UserId) - .Ignore(dto => dto.ExtraProperties); - CreateMap() - .Ignore(dto => dto.ExtraProperties); - } - } -} diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebMapperlyMappers.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/BasketsWebMapperlyMappers.cs new file mode 100644 index 00000000..82e8217f --- /dev/null +++ b/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 + { + [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 + { + 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 + { + [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 + { + [MapperIgnoreTarget(nameof(UpdateBasketItemDto.ExtraProperties))] + public override partial UpdateBasketItemDto Map(EditBasketItemViewModel source); + + [MapperIgnoreTarget(nameof(UpdateBasketItemDto.ExtraProperties))] + public override partial void Map(EditBasketItemViewModel source, UpdateBasketItemDto destination); + } +} diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EShopPluginsBasketsWebModule.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EShopPluginsBasketsWebModule.cs index df6b7ca1..2e5107e0 100644 --- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EShopPluginsBasketsWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); + context.Services.AddMapperlyObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); Configure(options => { diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EasyAbp.EShop.Plugins.Baskets.Web.csproj b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EasyAbp.EShop.Plugins.Baskets.Web.csproj index 63e40732..e8d97c64 100644 --- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EasyAbp.EShop.Plugins.Baskets.Web.csproj +++ b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EasyAbp.EShop.Plugins.Baskets.Web.csproj @@ -12,7 +12,8 @@ - + + diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp.EShop.Plugins.Booking.Application.csproj b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp.EShop.Plugins.Booking.Application.csproj index 4e8d6c43..cdd8a198 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp.EShop.Plugins.Booking.Application.csproj +++ b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp.EShop.Plugins.Booking.Application.csproj @@ -8,7 +8,8 @@ - + + diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationAutoMapperProfile.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationAutoMapperProfile.cs deleted file mode 100644 index bf15e402..00000000 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationAutoMapperProfile.cs +++ /dev/null @@ -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(); - - CreateMap(); - CreateMap(MemberList.Source); - CreateMap(MemberList.Source); - - CreateMap(); - - CreateMap(); - CreateMap(MemberList.Source); - CreateMap(MemberList.Source); - - CreateMap(); - CreateMap(MemberList.Source); - } -} diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationMapperlyMappers.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/BookingApplicationMapperlyMappers.cs new file mode 100644 index 00000000..62111046 --- /dev/null +++ b/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 + { + 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(); + } + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class ProductAssetPeriodToProductAssetPeriodDtoMapper : MapperBase + { + 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 + { + 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(); + } + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class ProductAssetCategoryPeriodToProductAssetCategoryPeriodDtoMapper : MapperBase + { + 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 + { + public override partial GrantedStoreDto Map(GrantedStore source); + + public override partial void Map(GrantedStore source, GrantedStoreDto destination); + } +} diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/EShopPluginsBookingApplicationModule.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/EShopPluginsBookingApplicationModule.cs index b0c882fb..cd038718 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/EShopPluginsBookingApplicationModule.cs +++ b/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(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStoreAppService.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStoreAppService.cs index 84387c23..f10791cf 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStoreAppService.cs +++ b/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 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; + } } } diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryAppService.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryAppService.cs index 8397543e..5f0d1f48 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryAppService.cs +++ b/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(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); diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetAppService.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetAppService.cs index 4e8e945a..dd790cc3 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetAppService.cs +++ b/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(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); diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStore.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStore.cs index 4bd15e4d..ff1fcbbb 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStore.cs +++ b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/GrantedStores/GrantedStore.cs @@ -36,4 +36,12 @@ public class GrantedStore : AuditedAggregateRoot, IMultiTenant AssetCategoryId = assetCategoryId; AllowAll = allowAll; } + + public void Update(Guid storeId, Guid? assetId, Guid? assetCategoryId, bool allowAll) + { + StoreId = storeId; + AssetId = assetId; + AssetCategoryId = assetCategoryId; + AllowAll = allowAll; + } } diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs index 9ca6cb8b..5127030a 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs +++ b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs @@ -28,4 +28,10 @@ public class ProductAssetCategoryPeriod : Entity Currency = currency; Price = price; } + + public void Update([NotNull] string currency, decimal price) + { + Currency = currency; + Price = price; + } } \ No newline at end of file diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs index 03ba7948..9c3a7525 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs +++ b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs @@ -28,4 +28,10 @@ public class ProductAssetPeriod : Entity Currency = currency; Price = price; } + + public void Update([NotNull] string currency, decimal price) + { + Currency = currency; + Price = price; + } } \ No newline at end of file diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebAutoMapperProfile.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebAutoMapperProfile.cs deleted file mode 100644 index c7e7786d..00000000 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebAutoMapperProfile.cs +++ /dev/null @@ -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(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - } -} diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebMapperlyMappers.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/BookingWebMapperlyMappers.cs new file mode 100644 index 00000000..63a5559e --- /dev/null +++ b/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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + 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 + { + public override partial CreateUpdateGrantedStoreDto Map(CreateEditGrantedStoreViewModel source); + + public override partial void Map(CreateEditGrantedStoreViewModel source, CreateUpdateGrantedStoreDto destination); + } +} diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EShopPluginsBookingWebModule.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EShopPluginsBookingWebModule.cs index 405f8371..03636b02 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EShopPluginsBookingWebModule.cs +++ b/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(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EasyAbp.EShop.Plugins.Booking.Web.csproj b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EasyAbp.EShop.Plugins.Booking.Web.csproj index 09f69707..5942cced 100644 --- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EasyAbp.EShop.Plugins.Booking.Web.csproj +++ b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/EasyAbp.EShop.Plugins.Booking.Web.csproj @@ -13,7 +13,8 @@ - + + diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp.EShop.Plugins.Coupons.Application.csproj b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp.EShop.Plugins.Coupons.Application.csproj index 5032f24e..1e5e370e 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp.EShop.Plugins.Coupons.Application.csproj +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp.EShop.Plugins.Coupons.Application.csproj @@ -8,7 +8,8 @@ - + + diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplateAppService.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplateAppService.cs index 6a35df86..0bbc8b6b 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplateAppService.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplateAppService.cs @@ -99,6 +99,25 @@ namespace EasyAbp.EShop.Plugins.Coupons.CouponTemplates await _repository.DeleteAsync(couponTemplate); } + protected override Task MapToEntityAsync(CreateUpdateCouponTemplateDto createInput) + { + return Task.FromResult(new CouponTemplate(GuidGenerator.Create(), null, createInput.StoreId, + createInput.CouponType, createInput.UniqueName, createInput.DisplayName, createInput.Description, + createInput.UsableDuration, createInput.UsableBeginTime, createInput.UsableEndTime, + createInput.ConditionAmount, createInput.DiscountAmount, createInput.Currency, createInput.IsUnscoped, + null)); + } + + protected override Task MapToEntityAsync(CreateUpdateCouponTemplateDto updateInput, CouponTemplate entity) + { + entity.Update(updateInput.StoreId, updateInput.CouponType, updateInput.UniqueName, + updateInput.DisplayName, updateInput.Description, updateInput.UsableDuration, + updateInput.UsableBeginTime, updateInput.UsableEndTime, updateInput.ConditionAmount, + updateInput.DiscountAmount, updateInput.Currency, updateInput.IsUnscoped); + + return Task.CompletedTask; + } + protected virtual bool ExistScope(IEnumerable scopes, ICouponTemplateScope need) { return scopes.Any(x => x.StoreId == need.StoreId && diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/Coupons/CouponAppService.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/Coupons/CouponAppService.cs index 5df8cbc5..ac2afad1 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/Coupons/CouponAppService.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/Coupons/CouponAppService.cs @@ -102,6 +102,19 @@ namespace EasyAbp.EShop.Plugins.Coupons.Coupons return result; } + protected override Task MapToEntityAsync(CreateCouponDto createInput) + { + return Task.FromResult(new Coupon(GuidGenerator.Create(), null, createInput.CouponTemplateId, + createInput.UserId, null, null)); + } + + protected override Task MapToEntityAsync(UpdateCouponDto updateInput, Coupon entity) + { + entity.SetExpirationTime(updateInput.ExpirationTime); + + return Task.CompletedTask; + } + public override async Task CreateAsync(CreateCouponDto input) { await CheckCreatePolicyAsync(); diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationAutoMapperProfile.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationAutoMapperProfile.cs deleted file mode 100644 index 6041d3fb..00000000 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationAutoMapperProfile.cs +++ /dev/null @@ -1,31 +0,0 @@ -using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; -using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; -using EasyAbp.EShop.Plugins.Coupons.Coupons; -using EasyAbp.EShop.Plugins.Coupons.Coupons.Dtos; -using AutoMapper; -using Volo.Abp.AutoMapper; - -namespace EasyAbp.EShop.Plugins.Coupons -{ - public class CouponsApplicationAutoMapperProfile : Profile - { - public CouponsApplicationAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap(); - CreateMap(MemberList.Source) - .ForSourceMember(x => x.Scopes, x => x.DoNotValidate()) - .Ignore(x => x.Scopes); - - CreateMap(); - CreateMap(MemberList.Source); - - CreateMap() - .Ignore(x => x.CouponTemplate); - CreateMap(MemberList.Source); - CreateMap(MemberList.Source); - } - } -} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationMapperlyMappers.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationMapperlyMappers.cs new file mode 100644 index 00000000..f7cdfac0 --- /dev/null +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/CouponsApplicationMapperlyMappers.cs @@ -0,0 +1,35 @@ +using EasyAbp.EShop.Plugins.Coupons.Coupons; +using EasyAbp.EShop.Plugins.Coupons.Coupons.Dtos; +using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; +using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.Coupons +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateToCouponTemplateDtoMapper : MapperBase + { + public override partial CouponTemplateDto Map(CouponTemplate source); + + public override partial void Map(CouponTemplate source, CouponTemplateDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateScopeToCouponTemplateScopeDtoMapper : MapperBase + { + public override partial CouponTemplateScopeDto Map(CouponTemplateScope source); + + public override partial void Map(CouponTemplateScope source, CouponTemplateScopeDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponToCouponDtoMapper : MapperBase + { + [MapperIgnoreTarget(nameof(CouponDto.CouponTemplate))] + public override partial CouponDto Map(Coupon source); + + [MapperIgnoreTarget(nameof(CouponDto.CouponTemplate))] + public override partial void Map(Coupon source, CouponDto destination); + } +} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsApplicationModule.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsApplicationModule.cs index 01874f21..5a18dc75 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsApplicationModule.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Application/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsApplicationModule.cs @@ -1,6 +1,6 @@ using EasyAbp.EShop.Stores; 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.Coupons typeof(EShopPluginsCouponsApplicationContractsModule), typeof(EShopStoresApplicationSharedModule), typeof(AbpDddApplicationModule), - typeof(AbpAutoMapperModule) + typeof(AbpMapperlyModule) )] public class EShopPluginsCouponsApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp.EShop.Plugins.Coupons.Domain.csproj b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp.EShop.Plugins.Coupons.Domain.csproj index 889d4595..e0912ea0 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp.EShop.Plugins.Coupons.Domain.csproj +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp.EShop.Plugins.Coupons.Domain.csproj @@ -8,7 +8,8 @@ - + + diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplate.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplate.cs index f56374ad..abb25de5 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplate.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponTemplates/CouponTemplate.cs @@ -94,6 +94,34 @@ namespace EasyAbp.EShop.Plugins.Coupons.CouponTemplates Scopes = scopes ?? new List(); } + public void Update( + Guid? storeId, + CouponType couponType, + string uniqueName, + string displayName, + string description, + TimeSpan? usableDuration, + DateTime? usableBeginTime, + DateTime? usableEndTime, + decimal conditionAmount, + decimal discountAmount, + [NotNull] string currency, + bool isUnscoped) + { + StoreId = storeId; + CouponType = couponType; + UniqueName = uniqueName; + DisplayName = displayName; + Description = description; + UsableDuration = usableDuration; + UsableBeginTime = usableBeginTime; + UsableEndTime = usableEndTime; + ConditionAmount = conditionAmount; + DiscountAmount = discountAmount; + Currency = currency; + IsUnscoped = isUnscoped; + } + public DateTime? GetCalculatedExpirationTime(IClock clock) { DateTime? expirationTime = null; diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainAutoMapperProfile.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainAutoMapperProfile.cs deleted file mode 100644 index 2653460e..00000000 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainAutoMapperProfile.cs +++ /dev/null @@ -1,20 +0,0 @@ -using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; -using AutoMapper; -using EasyAbp.EShop.Plugins.Coupons.Coupons; - -namespace EasyAbp.EShop.Plugins.Coupons -{ - public class CouponsDomainAutoMapperProfile : Profile - { - public CouponsDomainAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap(MemberList.Destination); - - CreateMap(MemberList.Destination); - CreateMap(MemberList.Destination); - } - } -} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainMapperlyMappers.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainMapperlyMappers.cs new file mode 100644 index 00000000..f35336ae --- /dev/null +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/CouponsDomainMapperlyMappers.cs @@ -0,0 +1,31 @@ +using EasyAbp.EShop.Plugins.Coupons.Coupons; +using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.Coupons +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponToCouponDataMapper : MapperBase + { + public override partial CouponData Map(Coupon source); + + public override partial void Map(Coupon source, CouponData destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateToCouponTemplateDataMapper : MapperBase + { + public override partial CouponTemplateData Map(CouponTemplate source); + + public override partial void Map(CouponTemplate source, CouponTemplateData destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateScopeToCouponTemplateScopeDataMapper : MapperBase + { + public override partial CouponTemplateScopeData Map(CouponTemplateScope source); + + public override partial void Map(CouponTemplateScope source, CouponTemplateScopeData destination); + } +} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsDomainModule.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsDomainModule.cs index d7746f48..600bc4c5 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsDomainModule.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Domain/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsDomainModule.cs @@ -1,13 +1,13 @@ using EasyAbp.EShop.Orders; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.Domain; using Volo.Abp.Modularity; namespace EasyAbp.EShop.Plugins.Coupons { [DependsOn( - typeof(AbpAutoMapperModule), + typeof(AbpMapperlyModule), typeof(AbpDddDomainModule), typeof(EShopPluginsCouponsDomainSharedModule), typeof(EShopOrdersDomainSharedModule) @@ -16,11 +16,7 @@ namespace EasyAbp.EShop.Plugins.Coupons { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } } diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client.csproj b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client.csproj index 3e7558b1..6fef9240 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client.csproj +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client.csproj @@ -9,7 +9,8 @@ - + + diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientAutoMapperProfile.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientAutoMapperProfile.cs deleted file mode 100644 index cd2fcb25..00000000 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientAutoMapperProfile.cs +++ /dev/null @@ -1,22 +0,0 @@ -using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; -using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; -using AutoMapper; -using EasyAbp.EShop.Plugins.Coupons.Coupons; -using EasyAbp.EShop.Plugins.Coupons.Coupons.Dtos; - -namespace EasyAbp.EShop.Plugins.Coupons -{ - public class CouponsHttpApiClientAutoMapperProfile : Profile - { - public CouponsHttpApiClientAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap(MemberList.Destination); - - CreateMap(MemberList.Destination); - CreateMap(MemberList.Destination); - } - } -} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientMapperlyMappers.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientMapperlyMappers.cs new file mode 100644 index 00000000..d1ed67c1 --- /dev/null +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/CouponsHttpApiClientMapperlyMappers.cs @@ -0,0 +1,33 @@ +using EasyAbp.EShop.Plugins.Coupons.Coupons; +using EasyAbp.EShop.Plugins.Coupons.Coupons.Dtos; +using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; +using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.Coupons +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponDtoToCouponDataMapper : MapperBase + { + public override partial CouponData Map(CouponDto source); + + public override partial void Map(CouponDto source, CouponData destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateDtoToCouponTemplateDataMapper : MapperBase + { + public override partial CouponTemplateData Map(CouponTemplateDto source); + + public override partial void Map(CouponTemplateDto source, CouponTemplateData destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateScopeDtoToCouponTemplateScopeDataMapper : MapperBase + { + public override partial CouponTemplateScopeData Map(CouponTemplateScopeDto source); + + public override partial void Map(CouponTemplateScopeDto source, CouponTemplateScopeData destination); + } +} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsHttpApiClientModule.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsHttpApiClientModule.cs index 8e8af899..55af4131 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsHttpApiClientModule.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.HttpApi.Client/EasyAbp/EShop/Plugins/Coupons/EShopPluginsCouponsHttpApiClientModule.cs @@ -1,5 +1,5 @@ using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -9,7 +9,7 @@ namespace EasyAbp.EShop.Plugins.Coupons [DependsOn( typeof(EShopPluginsCouponsApplicationContractsModule), typeof(AbpHttpClientModule), - typeof(AbpAutoMapperModule) + typeof(AbpMapperlyModule) )] public class EShopPluginsCouponsHttpApiClientModule : AbpModule { @@ -17,11 +17,7 @@ namespace EasyAbp.EShop.Plugins.Coupons public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); context.Services.AddHttpClientProxies( typeof(EShopPluginsCouponsApplicationContractsModule).Assembly, diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebAutoMapperProfile.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebAutoMapperProfile.cs deleted file mode 100644 index ef876d53..00000000 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebAutoMapperProfile.cs +++ /dev/null @@ -1,30 +0,0 @@ -using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; -using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplate.ViewModels; -using EasyAbp.EShop.Plugins.Coupons.Coupons.Dtos; -using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.Coupons.Coupon.ViewModels; -using AutoMapper; -using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope.ViewModels; -using Volo.Abp.AutoMapper; - -namespace EasyAbp.EShop.Plugins.Coupons.Web -{ - public class CouponsWebAutoMapperProfile : Profile - { - public CouponsWebAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap(MemberList.Destination); - CreateMap(); - CreateMap(); - CreateMap() - .Ignore(x => x.Scopes); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebMapperlyMappers.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebMapperlyMappers.cs new file mode 100644 index 00000000..7c7ecf66 --- /dev/null +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/CouponsWebMapperlyMappers.cs @@ -0,0 +1,84 @@ +using EasyAbp.EShop.Plugins.Coupons.Coupons.Dtos; +using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; +using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.Coupons.Coupon.ViewModels; +using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplate.ViewModels; +using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope.ViewModels; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.Coupons.Web +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateDtoToCreateUpdateCouponTemplateDtoMapper : MapperBase + { + public override partial CreateUpdateCouponTemplateDto Map(CouponTemplateDto source); + + public override partial void Map(CouponTemplateDto source, CreateUpdateCouponTemplateDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateDtoToCreateEditCouponTemplateViewModelMapper : MapperBase + { + public override partial CreateEditCouponTemplateViewModel Map(CouponTemplateDto source); + + public override partial void Map(CouponTemplateDto source, CreateEditCouponTemplateViewModel destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateScopeDtoToCreateEditCouponTemplateScopeViewModelMapper : MapperBase + { + public override partial CreateEditCouponTemplateScopeViewModel Map(CouponTemplateScopeDto source); + + public override partial void Map(CouponTemplateScopeDto source, CreateEditCouponTemplateScopeViewModel destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CreateEditCouponTemplateViewModelToCreateUpdateCouponTemplateDtoMapper : MapperBase + { + [MapperIgnoreTarget(nameof(CreateUpdateCouponTemplateDto.Scopes))] + public override partial CreateUpdateCouponTemplateDto Map(CreateEditCouponTemplateViewModel source); + + [MapperIgnoreTarget(nameof(CreateUpdateCouponTemplateDto.Scopes))] + public override partial void Map(CreateEditCouponTemplateViewModel source, CreateUpdateCouponTemplateDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CreateEditCouponTemplateScopeViewModelToCreateUpdateCouponTemplateScopeDtoMapper : MapperBase + { + public override partial CreateUpdateCouponTemplateScopeDto Map(CreateEditCouponTemplateScopeViewModel source); + + public override partial void Map(CreateEditCouponTemplateScopeViewModel source, CreateUpdateCouponTemplateScopeDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponTemplateScopeDtoToCreateUpdateCouponTemplateScopeDtoMapper : MapperBase + { + public override partial CreateUpdateCouponTemplateScopeDto Map(CouponTemplateScopeDto source); + + public override partial void Map(CouponTemplateScopeDto source, CreateUpdateCouponTemplateScopeDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CouponDtoToEditCouponViewModelMapper : MapperBase + { + public override partial EditCouponViewModel Map(CouponDto source); + + public override partial void Map(CouponDto source, EditCouponViewModel destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CreateCouponViewModelToCreateCouponDtoMapper : MapperBase + { + public override partial CreateCouponDto Map(CreateCouponViewModel source); + + public override partial void Map(CreateCouponViewModel source, CreateCouponDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class EditCouponViewModelToUpdateCouponDtoMapper : MapperBase + { + public override partial UpdateCouponDto Map(EditCouponViewModel source); + + public override partial void Map(EditCouponViewModel source, UpdateCouponDto destination); + } +} diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EShopPluginsCouponsWebModule.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EShopPluginsCouponsWebModule.cs index 2365392f..ca2396e4 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EShopPluginsCouponsWebModule.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EShopPluginsCouponsWebModule.cs @@ -4,7 +4,7 @@ using EasyAbp.EShop.Plugins.Coupons.Localization; using EasyAbp.EShop.Plugins.Coupons.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.Plugins.Coupons.Web [DependsOn( typeof(EShopPluginsCouponsApplicationContractsModule), typeof(AbpAspNetCoreMvcUiThemeSharedModule), - typeof(AbpAutoMapperModule) + typeof(AbpMapperlyModule) )] public class EShopPluginsCouponsWebModule : AbpModule { @@ -44,11 +44,7 @@ namespace EasyAbp.EShop.Plugins.Coupons.Web options.FileSets.AddEmbedded(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EasyAbp.EShop.Plugins.Coupons.Web.csproj b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EasyAbp.EShop.Plugins.Coupons.Web.csproj index 2ab5021a..dc67e5e2 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EasyAbp.EShop.Plugins.Coupons.Web.csproj +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/EasyAbp.EShop.Plugins.Coupons.Web.csproj @@ -12,7 +12,8 @@ - + + diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Orders.Plugins.FlashSales.Application/EasyAbp/EShop/Orders/Plugins/FlashSales/EShopOrdersPluginsFlashSalesApplicationModule.cs b/plugins/FlashSales/src/EasyAbp.EShop.Orders.Plugins.FlashSales.Application/EasyAbp/EShop/Orders/Plugins/FlashSales/EShopOrdersPluginsFlashSalesApplicationModule.cs index 6086e4d7..2179e9fc 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Orders.Plugins.FlashSales.Application/EasyAbp/EShop/Orders/Plugins/FlashSales/EShopOrdersPluginsFlashSalesApplicationModule.cs +++ b/plugins/FlashSales/src/EasyAbp.EShop.Orders.Plugins.FlashSales.Application/EasyAbp/EShop/Orders/Plugins/FlashSales/EShopOrdersPluginsFlashSalesApplicationModule.cs @@ -1,7 +1,7 @@ using EasyAbp.EShop.Plugins.FlashSales; using EasyAbp.EShop.Products; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.Modularity; namespace EasyAbp.EShop.Orders.Plugins.FlashSales; @@ -15,10 +15,6 @@ public class EShopOrdersPluginsFlashSalesApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp.EShop.Plugins.FlashSales.Application.csproj b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp.EShop.Plugins.FlashSales.Application.csproj index 4786abed..f73bdcb8 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp.EShop.Plugins.FlashSales.Application.csproj +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp.EShop.Plugins.FlashSales.Application.csproj @@ -9,7 +9,8 @@ - + + diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesApplicationModule.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesApplicationModule.cs index 48e94a13..57d1979b 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesApplicationModule.cs +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesApplicationModule.cs @@ -3,7 +3,7 @@ using EasyAbp.EShop.Products.Plugins.FlashSales; using EasyAbp.EShop.Stores; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Application; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.Caching; using Volo.Abp.Modularity; @@ -17,17 +17,13 @@ namespace EasyAbp.EShop.Plugins.FlashSales; typeof(EShopProductsPluginsFlashSalesAbstractionsModule), typeof(EShopProductsPluginsFlashSalesApplicationContractsModule), typeof(AbpDddApplicationModule), - typeof(AbpAutoMapperModule), + typeof(AbpMapperlyModule), typeof(AbpCachingModule) )] public class EShopPluginsFlashSalesApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs index 14896b80..3e88b4d4 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs @@ -94,6 +94,8 @@ public class FlashSalePlanAppService : FlashSaleInventoryManager = flashSaleInventoryManager; FlashSaleCurrentResultCache = flashSaleCurrentResultCache; Options = options.Value; + + ObjectMapperContext = typeof(EShopPluginsFlashSalesApplicationModule); } public override async Task GetAsync(Guid id) diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSaleResults/FlashSaleResultAppService.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSaleResults/FlashSaleResultAppService.cs index 205b8eed..d307f2f2 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSaleResults/FlashSaleResultAppService.cs +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSaleResults/FlashSaleResultAppService.cs @@ -26,6 +26,8 @@ public class FlashSaleResultAppService : IFlashSaleResultRepository flashSaleResultRepository) : base(flashSaleResultRepository) { FlashSaleCurrentResultCache = flashSaleCurrentResultCache; + + ObjectMapperContext = typeof(EShopPluginsFlashSalesApplicationModule); } [Authorize] diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationAutoMapperProfile.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationAutoMapperProfile.cs deleted file mode 100644 index f14f1303..00000000 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationAutoMapperProfile.cs +++ /dev/null @@ -1,41 +0,0 @@ -using AutoMapper; -using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans; -using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans.Dtos; -using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults; -using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults.Dtos; -using EasyAbp.EShop.Products.Products; -using EasyAbp.EShop.Products.Products.Dtos; - -namespace EasyAbp.EShop.Plugins.FlashSales; - -public class FlashSalesApplicationAutoMapperProfile : Profile -{ - public FlashSalesApplicationAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap() - .MapExtraProperties() - .ForSourceMember(x => x.ExtraProperties, - x => x.DoNotValidate()); // todo: https://github.com/abpframework/abp/issues/15404 - CreateMap(MemberList.Source); - CreateMap(MemberList.Source); - CreateMap() - .MapExtraProperties() - .ForSourceMember(x => x.ExtraProperties, - x => x.DoNotValidate()); // todo: https://github.com/abpframework/abp/issues/15404 - CreateMap() - .MapExtraProperties() - .ForSourceMember(x => x.ExtraProperties, - x => x.DoNotValidate()); // todo: https://github.com/abpframework/abp/issues/15404 - CreateMap() - .MapExtraProperties() - .ForSourceMember(x => x.ExtraProperties, - x => x.DoNotValidate()); // todo: https://github.com/abpframework/abp/issues/15404 - CreateMap(MemberList.Source) - .MapExtraProperties() - .ForSourceMember(x => x.ExtraProperties, - x => x.DoNotValidate()); // todo: https://github.com/abpframework/abp/issues/15404 - } -} \ No newline at end of file diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationMapperlyMappers.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationMapperlyMappers.cs new file mode 100644 index 00000000..91dacfb6 --- /dev/null +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalesApplicationMapperlyMappers.cs @@ -0,0 +1,56 @@ +using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans; +using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans.Dtos; +using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults; +using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults.Dtos; +using EasyAbp.EShop.Products.Products; +using EasyAbp.EShop.Products.Products.Dtos; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.FlashSales +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + [MapExtraProperties] + public partial class FlashSalePlanToFlashSalePlanDtoMapper : MapperBase + { + public override partial FlashSalePlanDto Map(FlashSalePlan source); + + public override partial void Map(FlashSalePlan source, FlashSalePlanDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + [MapExtraProperties] + public partial class FlashSalePlanToFlashSalePlanCacheItemMapper : MapperBase + { + public override partial FlashSalePlanCacheItem Map(FlashSalePlan source); + + public override partial void Map(FlashSalePlan source, FlashSalePlanCacheItem destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + [MapExtraProperties] + public partial class FlashSalePlanCacheItemToFlashSalePlanEtoMapper : MapperBase + { + public override partial FlashSalePlanEto Map(FlashSalePlanCacheItem source); + + public override partial void Map(FlashSalePlanCacheItem source, FlashSalePlanEto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + [MapExtraProperties] + public partial class FlashSaleResultToFlashSaleResultDtoMapper : MapperBase + { + public override partial FlashSaleResultDto Map(FlashSaleResult source); + + public override partial void Map(FlashSaleResult source, FlashSaleResultDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + [MapExtraProperties] + public partial class ProductDtoToProductCacheItemMapper : MapperBase + { + public override partial ProductCacheItem Map(ProductDto source); + + public override partial void Map(ProductDto source, ProductCacheItem destination); + } +} diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp.EShop.Plugins.FlashSales.Domain.csproj b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp.EShop.Plugins.FlashSales.Domain.csproj index cb9d1b85..06c547d2 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp.EShop.Plugins.FlashSales.Domain.csproj +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp.EShop.Plugins.FlashSales.Domain.csproj @@ -8,7 +8,8 @@ - + + diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainAutoMapperProfile.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainAutoMapperProfile.cs deleted file mode 100644 index fed8b5cd..00000000 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainAutoMapperProfile.cs +++ /dev/null @@ -1,16 +0,0 @@ -using AutoMapper; -using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans; - -namespace EasyAbp.EShop.Plugins.FlashSales; - -public class EShopPluginsFlashSalesDomainAutoMapperProfile : Profile -{ - public EShopPluginsFlashSalesDomainAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap() - .MapExtraProperties(); - } -} diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainModule.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainModule.cs index f05ee3d6..88be80f7 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainModule.cs +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/EShopPluginsFlashSalesDomainModule.cs @@ -1,6 +1,6 @@ using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.Domain; using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.Modularity; @@ -9,19 +9,15 @@ namespace EasyAbp.EShop.Plugins.FlashSales; [DependsOn( typeof(AbpDddDomainModule), - typeof(AbpAutoMapperModule), + typeof(AbpMapperlyModule), typeof(EShopPluginsFlashSalesDomainSharedModule) )] public class EShopPluginsFlashSalesDomainModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); + context.Services.AddMapperlyObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); Configure(options => { diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/FlashSalesDomainMapperlyMappers.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/FlashSalesDomainMapperlyMappers.cs new file mode 100644 index 00000000..ba8a3e62 --- /dev/null +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Domain/EasyAbp/EShop/Plugins/FlashSales/FlashSalesDomainMapperlyMappers.cs @@ -0,0 +1,15 @@ +using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.FlashSales +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + [MapExtraProperties] + public partial class FlashSalePlanToFlashSalePlanEtoMapper : MapperBase + { + public override partial FlashSalePlanEto Map(FlashSalePlan source); + + public override partial void Map(FlashSalePlan source, FlashSalePlanEto destination); + } +} diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebAutoMapperProfile.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebAutoMapperProfile.cs deleted file mode 100644 index 5a88342e..00000000 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebAutoMapperProfile.cs +++ /dev/null @@ -1,25 +0,0 @@ -using AutoMapper; -using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans.Dtos; -using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults.Dtos; -using EasyAbp.EShop.Plugins.FlashSales.Web.Pages.EShop.Plugins.FlashSales.FlashSalePlans.FlashSalePlan.ViewModels; -using EasyAbp.EShop.Plugins.FlashSales.Web.Pages.EShop.Plugins.FlashSales.FlashSaleResults.FlashSaleResult.ViewModels; - -namespace EasyAbp.EShop.Plugins.FlashSales.Web; - -public class EShopPluginsFlashSalesWebAutoMapperProfile : Profile -{ - public EShopPluginsFlashSalesWebAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap(MemberList.Destination) - .ForMember(dest => dest.ExtraProperties, opt => opt.Ignore()); - CreateMap(MemberList.Destination) - .ForMember(dest => dest.ExtraProperties, opt => opt.Ignore()); - CreateMap(MemberList.Destination) - .ForSourceMember(dest => dest.ExtraProperties, opt => opt.DoNotValidate()); - CreateMap(MemberList.Destination) - .ForSourceMember(dest => dest.ExtraProperties, opt => opt.DoNotValidate()); - } -} diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebModule.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebModule.cs index 443dc336..2b36afde 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebModule.cs +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EShopPluginsFlashSalesWebModule.cs @@ -4,7 +4,7 @@ using EasyAbp.EShop.Plugins.FlashSales.Localization; using EasyAbp.EShop.Plugins.FlashSales.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.Plugins.FlashSales.Web; [DependsOn( typeof(EShopPluginsFlashSalesApplicationContractsModule), typeof(AbpAspNetCoreMvcUiThemeSharedModule), - typeof(AbpAutoMapperModule) + typeof(AbpMapperlyModule) )] public class EShopPluginsFlashSalesWebModule : AbpModule { @@ -44,11 +44,7 @@ public class EShopPluginsFlashSalesWebModule : AbpModule options.FileSets.AddEmbedded(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EasyAbp.EShop.Plugins.FlashSales.Web.csproj b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EasyAbp.EShop.Plugins.FlashSales.Web.csproj index 555b1d7d..7eb0bbbf 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EasyAbp.EShop.Plugins.FlashSales.Web.csproj +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/EasyAbp.EShop.Plugins.FlashSales.Web.csproj @@ -12,7 +12,8 @@ - + + diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/FlashSalesWebMapperlyMappers.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/FlashSalesWebMapperlyMappers.cs new file mode 100644 index 00000000..74406284 --- /dev/null +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Web/FlashSalesWebMapperlyMappers.cs @@ -0,0 +1,45 @@ +using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans.Dtos; +using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults.Dtos; +using EasyAbp.EShop.Plugins.FlashSales.Web.Pages.EShop.Plugins.FlashSales.FlashSalePlans.FlashSalePlan.ViewModels; +using EasyAbp.EShop.Plugins.FlashSales.Web.Pages.EShop.Plugins.FlashSales.FlashSaleResults.FlashSaleResult.ViewModels; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.FlashSales.Web +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class CreateFlashSalePlanViewModelToFlashSalePlanCreateDtoMapper : MapperBase + { + [MapperIgnoreTarget(nameof(FlashSalePlanCreateDto.ExtraProperties))] + public override partial FlashSalePlanCreateDto Map(CreateFlashSalePlanViewModel source); + + [MapperIgnoreTarget(nameof(FlashSalePlanCreateDto.ExtraProperties))] + public override partial void Map(CreateFlashSalePlanViewModel source, FlashSalePlanCreateDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class EditFlashSalePlanViewModelToFlashSalePlanUpdateDtoMapper : MapperBase + { + [MapperIgnoreTarget(nameof(FlashSalePlanUpdateDto.ExtraProperties))] + public override partial FlashSalePlanUpdateDto Map(EditFlashSalePlanViewModel source); + + [MapperIgnoreTarget(nameof(FlashSalePlanUpdateDto.ExtraProperties))] + public override partial void Map(EditFlashSalePlanViewModel source, FlashSalePlanUpdateDto destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class FlashSalePlanDtoToEditFlashSalePlanViewModelMapper : MapperBase + { + public override partial EditFlashSalePlanViewModel Map(FlashSalePlanDto source); + + public override partial void Map(FlashSalePlanDto source, EditFlashSalePlanViewModel destination); + } + + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class FlashSaleResultDtoToViewFlashSaleResultViewModelMapper : MapperBase + { + public override partial ViewFlashSaleResultViewModel Map(FlashSaleResultDto source); + + public override partial void Map(FlashSaleResultDto source, ViewFlashSaleResultViewModel destination); + } +} diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp.EShop.Plugins.Promotions.Application.csproj b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp.EShop.Plugins.Promotions.Application.csproj index 9d32518f..d7ce8022 100644 --- a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp.EShop.Plugins.Promotions.Application.csproj +++ b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp.EShop.Plugins.Promotions.Application.csproj @@ -9,7 +9,8 @@ - + + diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/EShopPluginsPromotionsApplicationModule.cs b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/EShopPluginsPromotionsApplicationModule.cs index 15bfcbad..7df139c0 100644 --- a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/EShopPluginsPromotionsApplicationModule.cs +++ b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/EShopPluginsPromotionsApplicationModule.cs @@ -1,6 +1,6 @@ using EasyAbp.EShop.Stores; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.Modularity; using Volo.Abp.Application; @@ -11,16 +11,12 @@ namespace EasyAbp.EShop.Plugins.Promotions; typeof(EShopPluginsPromotionsApplicationContractsModule), typeof(EShopStoresApplicationSharedModule), typeof(AbpDddApplicationModule), - typeof(AbpAutoMapperModule) + typeof(AbpMapperlyModule) )] public class EShopPluginsPromotionsApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); } } \ No newline at end of file diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationAutoMapperProfile.cs b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationAutoMapperProfile.cs deleted file mode 100644 index 51155529..00000000 --- a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationAutoMapperProfile.cs +++ /dev/null @@ -1,16 +0,0 @@ -using EasyAbp.EShop.Plugins.Promotions.Promotions; -using EasyAbp.EShop.Plugins.Promotions.Promotions.Dtos; -using AutoMapper; - -namespace EasyAbp.EShop.Plugins.Promotions; - -public class PromotionsApplicationAutoMapperProfile : Profile -{ - public PromotionsApplicationAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap(); - } -} diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationMapperlyMappers.cs b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationMapperlyMappers.cs new file mode 100644 index 00000000..fc9663fd --- /dev/null +++ b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Application/EasyAbp/EShop/Plugins/Promotions/PromotionsApplicationMapperlyMappers.cs @@ -0,0 +1,15 @@ +using EasyAbp.EShop.Plugins.Promotions.Promotions; +using EasyAbp.EShop.Plugins.Promotions.Promotions.Dtos; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.Promotions +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class PromotionToPromotionDtoMapper : MapperBase + { + public override partial PromotionDto Map(Promotion source); + + public override partial void Map(Promotion source, PromotionDto destination); + } +} diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EShopPluginsPromotionsWebModule.cs b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EShopPluginsPromotionsWebModule.cs index c57c13ab..e4ef7b86 100644 --- a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EShopPluginsPromotionsWebModule.cs +++ b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EShopPluginsPromotionsWebModule.cs @@ -4,7 +4,7 @@ using EasyAbp.EShop.Plugins.Promotions.Localization; using EasyAbp.EShop.Plugins.Promotions.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; @@ -17,7 +17,7 @@ namespace EasyAbp.EShop.Plugins.Promotions.Web; typeof(EShopPluginsPromotionsApplicationContractsModule), typeof(EShopStoresWebSharedModule), typeof(AbpAspNetCoreMvcUiThemeSharedModule), - typeof(AbpAutoMapperModule) + typeof(AbpMapperlyModule) )] public class EShopPluginsPromotionsWebModule : AbpModule { @@ -46,11 +46,7 @@ public class EShopPluginsPromotionsWebModule : AbpModule options.FileSets.AddEmbedded(); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddMapperlyObjectMapper(); Configure(options => { diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EasyAbp.EShop.Plugins.Promotions.Web.csproj b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EasyAbp.EShop.Plugins.Promotions.Web.csproj index c54dc937..a3e8003c 100644 --- a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EasyAbp.EShop.Plugins.Promotions.Web.csproj +++ b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/EasyAbp.EShop.Plugins.Promotions.Web.csproj @@ -14,7 +14,8 @@ - + + diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebAutoMapperProfile.cs b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebAutoMapperProfile.cs deleted file mode 100644 index ad234751..00000000 --- a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebAutoMapperProfile.cs +++ /dev/null @@ -1,16 +0,0 @@ -using EasyAbp.EShop.Plugins.Promotions.Promotions.Dtos; -using AutoMapper; -using EasyAbp.EShop.Plugins.Promotions.Web.Pages.EShop.Plugins.Promotions.Promotions.Promotion.ViewModels; - -namespace EasyAbp.EShop.Plugins.Promotions.Web; - -public class PromotionsWebAutoMapperProfile : Profile -{ - public PromotionsWebAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - CreateMap(); - } -} diff --git a/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebMapperlyMappers.cs b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebMapperlyMappers.cs new file mode 100644 index 00000000..d1c9a440 --- /dev/null +++ b/plugins/Promotions/src/EasyAbp.EShop.Plugins.Promotions.Web/PromotionsWebMapperlyMappers.cs @@ -0,0 +1,15 @@ +using EasyAbp.EShop.Plugins.Promotions.Promotions.Dtos; +using EasyAbp.EShop.Plugins.Promotions.Web.Pages.EShop.Plugins.Promotions.Promotions.Promotion.ViewModels; +using Riok.Mapperly.Abstractions; +using Volo.Abp.Mapperly; + +namespace EasyAbp.EShop.Plugins.Promotions.Web +{ + [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] + public partial class PromotionDtoToEditPromotionViewModelMapper : MapperBase + { + public override partial EditPromotionViewModel Map(PromotionDto source); + + public override partial void Map(PromotionDto source, EditPromotionViewModel destination); + } +} diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationAutoMapperProfile.cs b/samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationAutoMapperProfile.cs deleted file mode 100644 index a16829aa..00000000 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationAutoMapperProfile.cs +++ /dev/null @@ -1,14 +0,0 @@ -using AutoMapper; - -namespace EShopSample -{ - public class EShopSampleApplicationAutoMapperProfile : Profile - { - public EShopSampleApplicationAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - } - } -} diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationModule.cs b/samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationModule.cs index da346f0e..d5145fc5 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationModule.cs +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSampleApplicationModule.cs @@ -12,7 +12,7 @@ using EasyAbp.PaymentService; using EasyAbp.PaymentService.Prepayment; using EasyAbp.PaymentService.WeChatPay; using Volo.Abp.Account; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.FeatureManagement; using Volo.Abp.Identity; using Volo.Abp.Modularity; @@ -47,10 +47,6 @@ namespace EShopSample { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => - { - options.AddMaps(); - }); } } } diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj index 393fcdda..dd864136 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj @@ -51,7 +51,7 @@ - + diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebAutoMapperProfile.cs b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebAutoMapperProfile.cs deleted file mode 100644 index b38258d6..00000000 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebAutoMapperProfile.cs +++ /dev/null @@ -1,12 +0,0 @@ -using AutoMapper; - -namespace EShopSample.Web -{ - public class EShopSampleWebAutoMapperProfile : Profile - { - public EShopSampleWebAutoMapperProfile() - { - //Define your AutoMapper configuration here for the Web project. - } - } -} diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs index 48c2c368..a221cbf6 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs @@ -44,7 +44,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; -using Volo.Abp.AutoMapper; +using Volo.Abp.Mapperly; using Volo.Abp.FeatureManagement; using Volo.Abp.Identity.Web; using Volo.Abp.Localization; @@ -152,11 +152,6 @@ namespace EShopSample.Web private void ConfigureAutoMapper() { - Configure(options => - { - options.AddMaps(); - - }); } private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)