重构代码并抽取基础构建库
This commit is contained in:
1 parent
9e6b5be92c
commit
ccf1e7672d
55 files changed
+398
-104
No files matched your search
+1
-1
@@ -1,11 +1,11 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.DistributedEvents.Events;
|
||||
using HelloShop.OrderingService.Entities.Orders;
|
||||
using HelloShop.OrderingService.Infrastructure;
|
||||
using HelloShop.OrderingService.Services;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.EventHandling
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.DistributedEvents.Events;
|
||||
using HelloShop.OrderingService.Entities.Orders;
|
||||
using HelloShop.OrderingService.Infrastructure;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.EventHandling
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.DistributedEvents.Events;
|
||||
using HelloShop.OrderingService.Entities.Orders;
|
||||
using HelloShop.OrderingService.Infrastructure;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.EventHandling
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.Events
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.Events
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.Events
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.Events
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.Events
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.Events
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.DistributedEvents.Events
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace HelloShop.OrderingService.Entities.EventLogs
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.EventBus.Dapr;
|
||||
using HelloShop.OrderingService.Behaviors;
|
||||
using HelloShop.OrderingService.Constants;
|
||||
using HelloShop.OrderingService.Infrastructure;
|
||||
using HelloShop.OrderingService.Queries;
|
||||
using HelloShop.OrderingService.Services;
|
||||
using HelloShop.OrderingService.Workers;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.DaprBuildingBlocks;
|
||||
using HelloShop.ServiceDefaults.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
@@ -57,7 +57,7 @@ namespace HelloShop.OrderingService.Extensions
|
||||
|
||||
builder.Services.AddTransient<ISmsSender, MessageService>().AddTransient<IEmailSender, MessageService>();
|
||||
|
||||
builder.AddDaprDistributedEventBus().AddSubscriptionFromAssembly();
|
||||
builder.AddDaprEventBus().AddSubscriptionFromAssembly();
|
||||
|
||||
builder.Services.Configure<HostOptions>(hostOptions =>
|
||||
{
|
||||
@@ -79,7 +79,7 @@ namespace HelloShop.OrderingService.Extensions
|
||||
app.UseCors(options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
|
||||
app.UseOpenApi();
|
||||
app.UseDataSeedingProviders();
|
||||
app.MapDaprDistributedEventBus();
|
||||
app.MapDaprEventBus();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libraries\HelloShop.EventBus.Dapr\HelloShop.EventBus.Dapr.csproj" />
|
||||
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.Entities.EventLogs;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.Text.Json;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.Entities.EventLogs;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HelloShop.OrderingService.Services
|
||||
{
|
||||
public class DistributedEventService<TContext>(TContext dbContext, IDistributedEventBus distributedEventBus, ILogger<DistributedEventService<TContext>> logger) : IDistributedEventService, IDisposable where TContext : DbContext
|
||||
public class DistributedEventService<TContext>(TContext dbContext, IEventBus distributedEventBus, ILogger<DistributedEventService<TContext>> logger) : IDistributedEventService, IDisposable where TContext : DbContext
|
||||
{
|
||||
private volatile bool _disposedValue;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.Entities.EventLogs;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
|
||||
namespace HelloShop.OrderingService.Services
|
||||
{
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.DistributedEvents.Events;
|
||||
using HelloShop.OrderingService.Entities.Orders;
|
||||
using HelloShop.OrderingService.Infrastructure;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HelloShop.OrderingService.Workers
|
||||
@@ -23,7 +23,7 @@ namespace HelloShop.OrderingService.Workers
|
||||
|
||||
using var scope = serviceScopeFactory.CreateAsyncScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<OrderingServiceDbContext>();
|
||||
var distributedEventBus = scope.ServiceProvider.GetRequiredService<IDistributedEventBus>();
|
||||
var distributedEventBus = scope.ServiceProvider.GetRequiredService<IEventBus>();
|
||||
|
||||
DateTimeOffset dateTimeOffset = timeProvider.GetUtcNow().AddMinutes(-1);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using HelloShop.EventBus.Abstractions;
|
||||
using HelloShop.OrderingService.DistributedEvents.Events;
|
||||
using HelloShop.OrderingService.Entities.Orders;
|
||||
using HelloShop.OrderingService.Infrastructure;
|
||||
using HelloShop.ServiceDefaults.DistributedEvents.Abstractions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HelloShop.OrderingService.Workers
|
||||
@@ -23,7 +23,7 @@ namespace HelloShop.OrderingService.Workers
|
||||
|
||||
using var scope = serviceScopeFactory.CreateAsyncScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<OrderingServiceDbContext>();
|
||||
var distributedEventBus = scope.ServiceProvider.GetRequiredService<IDistributedEventBus>();
|
||||
var distributedEventBus = scope.ServiceProvider.GetRequiredService<IEventBus>();
|
||||
|
||||
bool paymentSucceeded = Random.Shared.NextDouble() > 0.3;
|
||||
|
||||
|
||||
Reference in new issue
Block a user