Skip to content

Commit

Permalink
Merge pull request #14 from netcorepal/fix
Browse files Browse the repository at this point in the history
fix IntegrationEventConverter
  • Loading branch information
witskeeper authored Sep 2, 2024
2 parents 6a9b8f3 + be53569 commit 55b7c20
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion eng/versions.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.5.0</VersionPrefix>
<VersionPrefix>1.5.1</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion template/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<NetCorePalVersion>2.0.0-preview.1.2408311353</NetCorePalVersion>
<NetCorePalVersion>2.0.0-preview.1.2409021337</NetCorePalVersion>
<FrameworkVersion>8.0.0</FrameworkVersion>
<ExtensionsVersion>8.0.0</ExtensionsVersion>
<EntityFrameworkVersion>8.0.0</EntityFrameworkVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NetCorePal.Extensions.Domain.Abstractions" Version="$(NetCorePalVersion)"/>
<PackageReference Include="NetCorePal.Extensions.Primitives" Version="$(NetCorePalVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NetCorePal.Extensions.Domain;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using NetCorePal.Extensions.Primitives;

namespace ABC.Template.Domain.AggregatesModel.OrderAggregate
{
Expand Down Expand Up @@ -32,7 +33,15 @@ public Order(string name, int count)

public void OrderPaid()
{
this.Paid = true;
if (Paid)
{
throw new KnownException("Order has been paid");
}
else
{
this.Paid = true;
this.AddDomainEvent(new OrderPaidDomainEvent(this));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using ABC.Template.Domain.AggregatesModel.OrderAggregate;
using NetCorePal.Extensions.Domain;

namespace ABC.Template.Domain.DomainEvents;

public record OrderPaidDomainEvent(Order Order) : IDomainEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
throw new ArgumentNullException(nameof(modelBuilder));
}

modelBuilder.ApplyConfiguration(new OrderEntityTypeConfiguration());
modelBuilder.ApplyConfiguration(new DeliverRecordConfiguration());
modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly);
base.OnModelCreating(modelBuilder);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using ABC.Template.Domain.DomainEvents;
using ABC.Template.Web.Application.IntegrationEventHandlers;
using NetCorePal.Extensions.DistributedTransactions;

namespace ABC.Template.Web.Application.IntegrationEventConverters;

public class OrderPaidIntegrationEventConverter
: IIntegrationEventConverter<OrderPaidDomainEvent, OrderPaidIntegrationEvent>
{
public OrderPaidIntegrationEvent Convert(OrderPaidDomainEvent domainEvent)
{
return new OrderPaidIntegrationEvent(domainEvent.Order.Id);
}
}
11 changes: 6 additions & 5 deletions template/src/ABC.Template.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@


#region 基础设施

builder.Services.AddMediatR(cfg =>
cfg.RegisterServicesFromAssemblies(Assembly.GetExecutingAssembly())
.AddKnownExceptionValidationBehavior()
.AddUnitOfWorkBehaviors());
builder.Services.AddRepositories(typeof(ApplicationDbContext).Assembly);

builder.Services.AddDbContext<ApplicationDbContext>(options =>
Expand All @@ -132,6 +127,7 @@
builder.Services.AddContext().AddEnvContext().AddCapContextProcessor();
builder.Services.AddNetCorePalServiceDiscoveryClient();
builder.Services.AddIntegrationEventServices(typeof(Program))
.AddIIntegrationEventConverter(typeof(Program))
.UseCap(typeof(Program))
.AddContextIntegrationFilters()
.AddEnvIntegrationFilters();
Expand All @@ -143,6 +139,11 @@
});

#endregion

builder.Services.AddMediatR(cfg =>
cfg.RegisterServicesFromAssemblies(Assembly.GetExecutingAssembly())
.AddKnownExceptionValidationBehavior()
.AddUnitOfWorkBehaviors());

#region 远程服务客户端配置

Expand Down

0 comments on commit 55b7c20

Please sign in to comment.