Browse Source

Register `EShopPaymentsObjectExtensions`

pull/235/head
gdlcf88 3 years ago
parent
commit
4ed29f3354
  1. 39
      .github/workflows/publish.yml
  2. 2
      Directory.Build.props
  3. 2
      common.props
  4. 11
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/EShopPaymentsDomainModule.cs
  5. 63
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/ObjectExtending/EShopPaymentsObjectExtensions.cs
  6. 17
      modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/PaymentAppServiceTests.cs
  7. 7
      modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/TestCreatePaymentEventHandler.cs

39
.github/workflows/publish.yml

@ -6,7 +6,7 @@ on:
- main
jobs:
publish:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: NuGet/setup-nuget@v1
@ -38,36 +38,37 @@ jobs:
run: dotnet test -c Release --no-restore --no-build
- name: dotnet pack
run: dotnet pack -c Release --no-build -o dest
run: dotnet pack -c Release --no-build --property PackageOutputPath=${{ github.workspace }}/nugetPackages/
- name: remove unused packages
run: |
cd dest
del * -Exclude EasyAbp.*
del * -Exclude *.${{ steps.getVersion.outputs.first_match }}.nupkg
del *.Blazor.Host.*
del *.Blazor.Server.Host.*
del *.Host.Shared.*
del *.HttpApi.Host.*
del *.IdentityServer.*
del *.AuthServer.*
del *.Web.Host.*
del *.Web.Unified.*
del *.HttpApi.Client.ConsoleTestApp.*
del *.Tests.*
del *.TestBase.*
dir -name
cd ${{ github.workspace }}/nugetPackages
shopt -s extglob
rm -f !(EasyAbp.*)
rm -f !(*.${{ steps.getVersion.outputs.first_match }}.nupkg)
rm -f *.Blazor.Host.*
rm -f *.Blazor.Server.Host.*
rm -f *.Host.Shared.*
rm -f *.HttpApi.Host.*
rm -f *.IdentityServer.*
rm -f *.AuthServer.*
rm -f *.Web.Host.*
rm -f *.Web.Unified.*
rm -f *.HttpApi.Client.ConsoleTestApp.*
rm -f *.Tests.*
rm -f *.TestBase.*
ls
- name: dotnet nuget push to GitHub
uses: tanaka-takayoshi/nuget-publish-to-github-packages-action@v2.1
with:
nupkg-path: 'dest\*.nupkg'
nupkg-path: '${{ github.workspace }}/nugetPackages/*.nupkg'
repo-owner: 'EasyAbp'
gh-user: 'EasyAbp'
token: ${{ secrets.GITHUB_TOKEN }}
- name: dotnet nuget push to NuGet
run: dotnet nuget push dest\*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
run: dotnet nuget push ${{ github.workspace }}/nugetPackages/*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
- name: determine if the tag exists
uses: mukunku/tag-exists-action@v1.0.0

2
Directory.Build.props

@ -3,7 +3,7 @@
<AbpVersion>7.0.0</AbpVersion>
<EasyAbpAbpTreesModuleVersion>2.9.0</EasyAbpAbpTreesModuleVersion>
<EasyAbpPaymentServiceModuleVersion>2.3.0</EasyAbpPaymentServiceModuleVersion>
<EasyAbpPaymentServiceModuleVersion>2.3.2</EasyAbpPaymentServiceModuleVersion>
<EasyAbpAbpTagHelperPlusModuleVersion>1.3.0</EasyAbpAbpTagHelperPlusModuleVersion>
<EasyAbpBookingServiceModuleVersion>0.4.0</EasyAbpBookingServiceModuleVersion>
<DaprSdkVersion>1.9.0</DaprSdkVersion>

2
common.props

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

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

@ -1,4 +1,5 @@
using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.ObjectExtending;
using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.Refunds;
using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection;
@ -17,16 +18,18 @@ namespace EasyAbp.EShop.Payments
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
EShopPaymentsObjectExtensions.Configure();
Configure<AbpDistributedEntityEventOptions>(options =>
{
options.EtoMappings.Add<Payment, EShopPaymentEto>(typeof(EShopPaymentsDomainModule));
options.EtoMappings.Add<Refund, EShopRefundEto>(typeof(EShopPaymentsDomainModule));
options.AutoEventSelectors.Add<Payment>();
options.AutoEventSelectors.Add<Refund>();
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<EShopPaymentsDomainModule>();
@ -37,4 +40,4 @@ namespace EasyAbp.EShop.Payments
});
}
}
}
}

63
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/ObjectExtending/EShopPaymentsObjectExtensions.cs

@ -0,0 +1,63 @@
using System;
using EasyAbp.EShop.Payments.Payments;
using EasyAbp.EShop.Payments.Refunds;
using EasyAbp.PaymentService.Payments;
using EasyAbp.PaymentService.Refunds;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
namespace EasyAbp.EShop.Payments.ObjectExtending
{
public static class EShopPaymentsObjectExtensions
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure()
{
OneTimeRunner.Run(() =>
{
/* You can configure extension properties to entities or other object types
* defined in the depended modules.
*
* If you are using EF Core and want to map the entity extension properties to new
* table fields in the database, then configure them in the DenturePlusEfCoreEntityExtensionMappings
*
* Example:
*
* ObjectExtensionManager.Instance
* .AddOrUpdateProperty<IdentityRole, string>("Title");
*
* See the documentation for more:
* https://docs.abp.io/en/abp/latest/Object-Extensions
*/
ObjectExtensionManager.Instance
.AddOrUpdate(new []
{
typeof(PaymentItem),
typeof(EShopPaymentItemEto),
typeof(PaymentItemEto),
typeof(CreatePaymentItemEto)
}, options =>
{
options.AddOrUpdateProperty<Guid>(nameof(PaymentItem.StoreId));
});
ObjectExtensionManager.Instance
.AddOrUpdate(new []
{
typeof(RefundItem),
typeof(EShopRefundItemEto),
typeof(RefundItemEto),
typeof(CreateRefundItemInput)
}, options =>
{
options.AddOrUpdateProperty<Guid>(nameof(RefundItem.StoreId));
options.AddOrUpdateProperty<Guid>(nameof(RefundItem.OrderId));
options.AddOrUpdateProperty<string>(nameof(RefundItem.OrderLines));
options.AddOrUpdateProperty<string>(nameof(RefundItem.OrderExtraFees));
});
});
}
}
}

17
modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/PaymentAppServiceTests.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Orders;
using EasyAbp.EShop.Orders.Orders.Dtos;
@ -7,6 +8,7 @@ using EasyAbp.EShop.Payments.Payments.Dtos;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Shouldly;
using Volo.Abp.Data;
using Xunit;
namespace EasyAbp.EShop.Payments.Payments
@ -41,7 +43,7 @@ namespace EasyAbp.EShop.Payments.Payments
}
}
}));
services.AddTransient(_ => orderService);
}
@ -66,8 +68,15 @@ namespace EasyAbp.EShop.Payments.Payments
// Act & Assert
await _paymentAppService.CreateAsync(request);
_testCreatePaymentEventHandler.IsEventPublished.ShouldBe(true );
_testCreatePaymentEventHandler.IsEventPublished.ShouldBe(true);
_testCreatePaymentEventHandler.CreatePaymentEto.PaymentItems.Count.ShouldBe(1);
_testCreatePaymentEventHandler.CreatePaymentEto.PaymentItems.First().ItemType
.ShouldBe(PaymentsConsts.PaymentItemType);
_testCreatePaymentEventHandler.CreatePaymentEto.PaymentItems.First().ItemKey
.ShouldBe(PaymentsTestData.Order1.ToString());
_testCreatePaymentEventHandler.CreatePaymentEto.PaymentItems.First()
.GetProperty(nameof(PaymentItem.StoreId)).ShouldBe(PaymentsTestData.Store1);
}
}
}
}

7
modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Application.Tests/Payments/TestCreatePaymentEventHandler.cs

@ -8,11 +8,14 @@ namespace EasyAbp.EShop.Payments.Payments
public class TestCreatePaymentEventHandler : IDistributedEventHandler<CreatePaymentEto>, ISingletonDependency
{
public bool IsEventPublished { get; protected set; }
public CreatePaymentEto CreatePaymentEto { get; protected set; }
public Task HandleEventAsync(CreatePaymentEto eventData)
{
IsEventPublished = true;
CreatePaymentEto = eventData;
return Task.CompletedTask;
}
}

Loading…
Cancel
Save