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

2
Directory.Build.props

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

2
common.props

@ -1,7 +1,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Version>3.3.1</Version> <Version>3.3.2</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors> <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.Payments.Refunds;
using EasyAbp.EShop.Stores; using EasyAbp.EShop.Stores;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -17,16 +18,18 @@ namespace EasyAbp.EShop.Payments
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)
{ {
EShopPaymentsObjectExtensions.Configure();
Configure<AbpDistributedEntityEventOptions>(options => Configure<AbpDistributedEntityEventOptions>(options =>
{ {
options.EtoMappings.Add<Payment, EShopPaymentEto>(typeof(EShopPaymentsDomainModule)); options.EtoMappings.Add<Payment, EShopPaymentEto>(typeof(EShopPaymentsDomainModule));
options.EtoMappings.Add<Refund, EShopRefundEto>(typeof(EShopPaymentsDomainModule)); options.EtoMappings.Add<Refund, EShopRefundEto>(typeof(EShopPaymentsDomainModule));
options.AutoEventSelectors.Add<Payment>(); options.AutoEventSelectors.Add<Payment>();
options.AutoEventSelectors.Add<Refund>(); options.AutoEventSelectors.Add<Refund>();
}); });
} }
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAutoMapperObjectMapper<EShopPaymentsDomainModule>(); 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Orders; using EasyAbp.EShop.Orders.Orders;
using EasyAbp.EShop.Orders.Orders.Dtos; using EasyAbp.EShop.Orders.Orders.Dtos;
@ -7,6 +8,7 @@ using EasyAbp.EShop.Payments.Payments.Dtos;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using NSubstitute; using NSubstitute;
using Shouldly; using Shouldly;
using Volo.Abp.Data;
using Xunit; using Xunit;
namespace EasyAbp.EShop.Payments.Payments namespace EasyAbp.EShop.Payments.Payments
@ -41,7 +43,7 @@ namespace EasyAbp.EShop.Payments.Payments
} }
} }
})); }));
services.AddTransient(_ => orderService); services.AddTransient(_ => orderService);
} }
@ -66,8 +68,15 @@ namespace EasyAbp.EShop.Payments.Payments
// Act & Assert // Act & Assert
await _paymentAppService.CreateAsync(request); 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 class TestCreatePaymentEventHandler : IDistributedEventHandler<CreatePaymentEto>, ISingletonDependency
{ {
public bool IsEventPublished { get; protected set; } public bool IsEventPublished { get; protected set; }
public CreatePaymentEto CreatePaymentEto { get; protected set; }
public Task HandleEventAsync(CreatePaymentEto eventData) public Task HandleEventAsync(CreatePaymentEto eventData)
{ {
IsEventPublished = true; IsEventPublished = true;
CreatePaymentEto = eventData;
return Task.CompletedTask; return Task.CompletedTask;
} }
} }

Loading…
Cancel
Save