Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
丁松杰
/
Pole
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8ff3faf3
authored
Jan 17, 2020
by
dingsongjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善 backet
parent
38809d97
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
613 additions
and
16 deletions
Pole.sln
samples/apis/Backet.Api/Application/IntegrationEvent/Handler/JustTestWhenProductAddedIntegrationEventHandler.cs
samples/apis/Backet.Api/Backet.Api.csproj
samples/apis/Backet.Api/Domain/AggregatesModel/BacketAggregate/Backet.cs
samples/apis/Product.Api/Application/IntegrationEvent/ProductAddedIntegrationEvent.cs → samples/apis/Backet.Api/Domain/AggregatesModel/BacketAggregate/BacketItem.cs
samples/apis/Backet.Api/Infrastructure/BacketDbContext.cs
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketEntityTypeConfiguration.cs
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketItemEntityTypeConfiguration.cs
samples/apis/Backet.Api/Migrations/20200117083109_Init.Designer.cs
samples/apis/Backet.Api/Migrations/20200117083109_Init.cs
samples/apis/Backet.Api/Migrations/20200117083456_Modify_Backet_Key.Designer.cs
samples/apis/Backet.Api/Migrations/20200117083456_Modify_Backet_Key.cs
samples/apis/Backet.Api/Migrations/BacketDbContextModelSnapshot.cs
samples/apis/Product.Api/Application/DomainEventHandler/AddDefaultProductWhenProductTypeAdded2DomainEventHandler.cs
samples/apis/Product.Api/Application/IntegrationEvent/CallBack/ProductAddedIntegrationEventCallback.cs
samples/apis/Product.Api/Product.Api.csproj
samples/intergrationEvents/Product.IntegrationEvents/Product.IntegrationEvents.csproj
samples/apis/Backet.Api/Application/IntegrationEvent/ProductAddedIntegrationEvent.cs → samples/intergrationEvents/Product.IntegrationEvents/ProductAddedIntegrationEvent.cs
src/Pole.ReliableMessage/EventBus/DefaultReliableEventFinder.cs
Pole.sln
View file @
8ff3faf3
...
...
@@ -41,7 +41,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Product.Api", "samples\apis
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Backet.Api", "samples\apis\Backet.Api\Backet.Api.csproj", "{C961F25C-1C11-4855-84E4-ADABE96451E7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "User.Api", "samples\apis\User.Api\User.Api.csproj", "{F65858EC-C34F-4121-BEC5-4E20DEA74A0A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "User.Api", "samples\apis\User.Api\User.Api.csproj", "{F65858EC-C34F-4121-BEC5-4E20DEA74A0A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integrationEvents", "integrationEvents", "{74422E64-29FE-4287-A86E-741D1DFF6698}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Product.IntegrationEvents", "samples\intergrationEvents\Product.IntegrationEvents\Product.IntegrationEvents.csproj", "{9C0DFC90-1AF9-424A-B5FB-2A7C3611970C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -109,6 +113,10 @@ Global
{F65858EC-C34F-4121-BEC5-4E20DEA74A0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F65858EC-C34F-4121-BEC5-4E20DEA74A0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F65858EC-C34F-4121-BEC5-4E20DEA74A0A}.Release|Any CPU.Build.0 = Release|Any CPU
{9C0DFC90-1AF9-424A-B5FB-2A7C3611970C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C0DFC90-1AF9-424A-B5FB-2A7C3611970C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C0DFC90-1AF9-424A-B5FB-2A7C3611970C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C0DFC90-1AF9-424A-B5FB-2A7C3611970C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
@@ -131,6 +139,8 @@ Global
{125B1E4B-B1C1-4F85-9C6A-38815960E654} = {475116FC-DEEC-4255-94E4-AE7B8C85038D}
{C961F25C-1C11-4855-84E4-ADABE96451E7} = {475116FC-DEEC-4255-94E4-AE7B8C85038D}
{F65858EC-C34F-4121-BEC5-4E20DEA74A0A} = {475116FC-DEEC-4255-94E4-AE7B8C85038D}
{74422E64-29FE-4287-A86E-741D1DFF6698} = {4A0FB696-EC29-4A5F-B40B-A6FC56001ADB}
{9C0DFC90-1AF9-424A-B5FB-2A7C3611970C} = {74422E64-29FE-4287-A86E-741D1DFF6698}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DB0775A3-F293-4043-ADB7-72BAC081E87E}
...
...
samples/apis/Backet.Api/Application/IntegrationEvent/Handler/JustTestWhenProductAddedIntegrationEventHandler.cs
View file @
8ff3faf3
using
Pole.Application.EventBus
;
using
Pole.ReliableMessage.Abstraction
;
using
Product.
Api.Application.IntergrationEvent
;
using
Product.
IntegrationEvents
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -16,6 +16,14 @@ namespace Backet.Api.Application.IntegrationEvent.Handler
public
override
Task
Handle
(
IReliableEventHandlerContext
<
ProductAddedIntegrationEvent
>
context
)
{
try
{
}
catch
(
Exception
ex
)
{
}
return
Task
.
FromResult
(
1
);
}
}
...
...
samples/apis/Backet.Api/Backet.Api.csproj
View file @
8ff3faf3
...
...
@@ -5,7 +5,18 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="Migrations\20200117082211_Init.cs" />
<Compile Remove="Migrations\20200117082211_Init.Designer.cs" />
<Compile Remove="Migrations\20200117091659_Set_Backet_BacketItem_IsRequired_false.cs" />
<Compile Remove="Migrations\20200117091659_Set_Backet_BacketItem_IsRequired_false.Designer.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
</ItemGroup>
...
...
@@ -15,10 +26,7 @@
<ProjectReference Include="..\..\..\src\Pole.Grpc\Pole.Grpc.csproj" />
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage.Masstransit\Pole.ReliableMessage.Masstransit.csproj" />
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage.Storage.Mongodb\Pole.ReliableMessage.Storage.Mongodb.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Domain\AggregatesModel\" />
<ProjectReference Include="..\..\intergrationEvents\Product.IntegrationEvents\Product.IntegrationEvents.csproj" />
</ItemGroup>
</Project>
samples/apis/Backet.Api/Domain/AggregatesModel/BacketAggregate/Backet.cs
0 → 100644
View file @
8ff3faf3
using
Pole.Domain
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Backet.Api.Domain.AggregatesModel.BacketAggregate
{
public
class
Backet
:
Entity
,
IAggregateRoot
{
public
string
UserId
{
get
;
set
;
}
public
IReadOnlyCollection
<
BacketItem
>
BacketItems
{
get
;
private
set
;
}
public
long
TotalPrice
{
get
;
set
;
}
}
}
samples/apis/
Product.Api/Application/IntegrationEvent/ProductAddedIntegrationEvent
.cs
→
samples/apis/
Backet.Api/Domain/AggregatesModel/BacketAggregate/BacketItem
.cs
View file @
8ff3faf3
using
System
;
using
Pole.Domain
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api.Application.IntergrationEvent
namespace
Backet.Api.Domain.AggregatesModel.BacketAggregate
{
public
class
ProductAddedIntegrationEvent
public
class
BacketItem
:
Entity
{
public
string
ProductId
{
get
;
set
;
}
public
string
ProductName
{
get
;
set
;
}
public
long
Price
{
get
;
set
;
}
}
...
...
samples/apis/Backet.Api/Infrastructure/BacketDbContext.cs
View file @
8ff3faf3
using
Microsoft.EntityFrameworkCore
;
using
Backet.Api.Domain.AggregatesModel.BacketAggregate
;
using
Backet.Api.Infrastructure.EntityConfigurations
;
using
Microsoft.EntityFrameworkCore
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -12,9 +14,14 @@ namespace Backet.Api.Infrastructure
{
}
public
DbSet
<
Backet
.
Api
.
Domain
.
AggregatesModel
.
BacketAggregate
.
Backet
>
Backets
{
get
;
set
;
}
public
DbSet
<
BacketItem
>
BacketItems
{
get
;
set
;
}
protected
override
void
OnModelCreating
(
ModelBuilder
builder
)
{
base
.
OnModelCreating
(
builder
);
builder
.
ApplyConfiguration
(
new
BacketItemEntityTypeConfiguration
());
builder
.
ApplyConfiguration
(
new
BacketEntityTypeConfiguration
());
}
}
}
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketEntityTypeConfiguration.cs
0 → 100644
View file @
8ff3faf3
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Backet.Api.Infrastructure.EntityConfigurations
{
public
class
BacketEntityTypeConfiguration
:
IEntityTypeConfiguration
<
Backet
.
Api
.
Domain
.
AggregatesModel
.
BacketAggregate
.
Backet
>
{
public
void
Configure
(
EntityTypeBuilder
<
Backet
.
Api
.
Domain
.
AggregatesModel
.
BacketAggregate
.
Backet
>
builder
)
{
builder
.
ToTable
(
nameof
(
Backet
.
Api
.
Domain
.
AggregatesModel
.
BacketAggregate
.
Backet
));
builder
.
Property
(
m
=>
m
.
Id
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
UserId
).
HasMaxLength
(
32
).
IsRequired
();
builder
.
HasMany
(
m
=>
m
.
BacketItems
).
WithOne
();
builder
.
Ignore
(
m
=>
m
.
DomainEvents
);
builder
.
HasKey
(
m
=>
m
.
Id
);
builder
.
HasIndex
(
m
=>
m
.
UserId
);
}
}
}
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketItemEntityTypeConfiguration.cs
0 → 100644
View file @
8ff3faf3
using
Backet.Api.Domain.AggregatesModel.BacketAggregate
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Backet.Api.Infrastructure.EntityConfigurations
{
public
class
BacketItemEntityTypeConfiguration
:
IEntityTypeConfiguration
<
BacketItem
>
{
public
void
Configure
(
EntityTypeBuilder
<
BacketItem
>
builder
)
{
builder
.
ToTable
(
nameof
(
BacketItem
));
builder
.
Property
(
m
=>
m
.
Id
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
ProductId
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
ProductName
).
HasMaxLength
(
256
).
IsRequired
();
builder
.
Ignore
(
m
=>
m
.
DomainEvents
);
builder
.
HasKey
(
m
=>
m
.
Id
);
builder
.
HasIndex
(
m
=>
m
.
ProductId
);
}
}
}
samples/apis/Backet.Api/Migrations/20200117083109_Init.Designer.cs
0 → 100644
View file @
8ff3faf3
// <auto-generated />
using
Backet.Api.Infrastructure
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
namespace
Backet.Api.Migrations
{
[
DbContext
(
typeof
(
BacketDbContext
))]
[
Migration
(
"20200117083109_Init"
)]
partial
class
Init
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"3.1.0"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet"
,
b
=>
{
b
.
Property
<
string
>(
"UserId"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
long
>(
"TotalPrice"
)
.
HasColumnType
(
"bigint"
);
b
.
HasKey
(
"UserId"
);
b
.
ToTable
(
"Backet"
);
});
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.BacketItem"
,
b
=>
{
b
.
Property
<
string
>(
"ProductId"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"BacketUserId"
)
.
HasColumnType
(
"character varying(32)"
);
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
long
>(
"Price"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"ProductName"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(256)"
)
.
HasMaxLength
(
256
);
b
.
HasKey
(
"ProductId"
);
b
.
HasIndex
(
"BacketUserId"
);
b
.
ToTable
(
"BacketItem"
);
});
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.BacketItem"
,
b
=>
{
b
.
HasOne
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet"
,
null
)
.
WithMany
(
"BacketItems"
)
.
HasForeignKey
(
"BacketUserId"
);
});
#pragma warning restore 612, 618
}
}
}
samples/apis/Backet.Api/Migrations/20200117083109_Init.cs
0 → 100644
View file @
8ff3faf3
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Backet.Api.Migrations
{
public
partial
class
Init
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
CreateTable
(
name
:
"Backet"
,
columns
:
table
=>
new
{
UserId
=
table
.
Column
<
string
>(
maxLength
:
32
,
nullable
:
false
),
Id
=
table
.
Column
<
string
>(
maxLength
:
32
,
nullable
:
true
),
TotalPrice
=
table
.
Column
<
long
>(
nullable
:
false
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_Backet"
,
x
=>
x
.
UserId
);
});
migrationBuilder
.
CreateTable
(
name
:
"BacketItem"
,
columns
:
table
=>
new
{
ProductId
=
table
.
Column
<
string
>(
maxLength
:
32
,
nullable
:
false
),
Id
=
table
.
Column
<
string
>(
maxLength
:
32
,
nullable
:
true
),
ProductName
=
table
.
Column
<
string
>(
maxLength
:
256
,
nullable
:
false
),
Price
=
table
.
Column
<
long
>(
nullable
:
false
),
BacketUserId
=
table
.
Column
<
string
>(
nullable
:
true
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_BacketItem"
,
x
=>
x
.
ProductId
);
table
.
ForeignKey
(
name
:
"FK_BacketItem_Backet_BacketUserId"
,
column
:
x
=>
x
.
BacketUserId
,
principalTable
:
"Backet"
,
principalColumn
:
"UserId"
,
onDelete
:
ReferentialAction
.
Restrict
);
});
migrationBuilder
.
CreateIndex
(
name
:
"IX_BacketItem_BacketUserId"
,
table
:
"BacketItem"
,
column
:
"BacketUserId"
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"BacketItem"
);
migrationBuilder
.
DropTable
(
name
:
"Backet"
);
}
}
}
samples/apis/Backet.Api/Migrations/20200117083456_Modify_Backet_Key.Designer.cs
0 → 100644
View file @
8ff3faf3
// <auto-generated />
using
Backet.Api.Infrastructure
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
namespace
Backet.Api.Migrations
{
[
DbContext
(
typeof
(
BacketDbContext
))]
[
Migration
(
"20200117083456_Modify_Backet_Key"
)]
partial
class
Modify_Backet_Key
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"3.1.0"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
long
>(
"TotalPrice"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"UserId"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"UserId"
);
b
.
ToTable
(
"Backet"
);
});
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.BacketItem"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"BacketId"
)
.
HasColumnType
(
"character varying(32)"
);
b
.
Property
<
long
>(
"Price"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"ProductId"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"ProductName"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(256)"
)
.
HasMaxLength
(
256
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"BacketId"
);
b
.
HasIndex
(
"ProductId"
);
b
.
ToTable
(
"BacketItem"
);
});
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.BacketItem"
,
b
=>
{
b
.
HasOne
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet"
,
null
)
.
WithMany
(
"BacketItems"
)
.
HasForeignKey
(
"BacketId"
);
});
#pragma warning restore 612, 618
}
}
}
samples/apis/Backet.Api/Migrations/20200117083456_Modify_Backet_Key.cs
0 → 100644
View file @
8ff3faf3
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Backet.Api.Migrations
{
public
partial
class
Modify_Backet_Key
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_BacketItem_Backet_BacketUserId"
,
table
:
"BacketItem"
);
migrationBuilder
.
DropPrimaryKey
(
name
:
"PK_BacketItem"
,
table
:
"BacketItem"
);
migrationBuilder
.
DropIndex
(
name
:
"IX_BacketItem_BacketUserId"
,
table
:
"BacketItem"
);
migrationBuilder
.
DropPrimaryKey
(
name
:
"PK_Backet"
,
table
:
"Backet"
);
migrationBuilder
.
DropColumn
(
name
:
"BacketUserId"
,
table
:
"BacketItem"
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"Id"
,
table
:
"BacketItem"
,
maxLength
:
32
,
nullable
:
false
,
oldClrType
:
typeof
(
string
),
oldType
:
"character varying(32)"
,
oldMaxLength
:
32
,
oldNullable
:
true
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"ProductId"
,
table
:
"BacketItem"
,
maxLength
:
32
,
nullable
:
true
,
oldClrType
:
typeof
(
string
),
oldType
:
"character varying(32)"
,
oldMaxLength
:
32
);
migrationBuilder
.
AddColumn
<
string
>(
name
:
"BacketId"
,
table
:
"BacketItem"
,
nullable
:
true
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"Id"
,
table
:
"Backet"
,
maxLength
:
32
,
nullable
:
false
,
oldClrType
:
typeof
(
string
),
oldType
:
"character varying(32)"
,
oldMaxLength
:
32
,
oldNullable
:
true
);
migrationBuilder
.
AddPrimaryKey
(
name
:
"PK_BacketItem"
,
table
:
"BacketItem"
,
column
:
"Id"
);
migrationBuilder
.
AddPrimaryKey
(
name
:
"PK_Backet"
,
table
:
"Backet"
,
column
:
"Id"
);
migrationBuilder
.
CreateIndex
(
name
:
"IX_BacketItem_BacketId"
,
table
:
"BacketItem"
,
column
:
"BacketId"
);
migrationBuilder
.
CreateIndex
(
name
:
"IX_BacketItem_ProductId"
,
table
:
"BacketItem"
,
column
:
"ProductId"
);
migrationBuilder
.
CreateIndex
(
name
:
"IX_Backet_UserId"
,
table
:
"Backet"
,
column
:
"UserId"
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_BacketItem_Backet_BacketId"
,
table
:
"BacketItem"
,
column
:
"BacketId"
,
principalTable
:
"Backet"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Restrict
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_BacketItem_Backet_BacketId"
,
table
:
"BacketItem"
);
migrationBuilder
.
DropPrimaryKey
(
name
:
"PK_BacketItem"
,
table
:
"BacketItem"
);
migrationBuilder
.
DropIndex
(
name
:
"IX_BacketItem_BacketId"
,
table
:
"BacketItem"
);
migrationBuilder
.
DropIndex
(
name
:
"IX_BacketItem_ProductId"
,
table
:
"BacketItem"
);
migrationBuilder
.
DropPrimaryKey
(
name
:
"PK_Backet"
,
table
:
"Backet"
);
migrationBuilder
.
DropIndex
(
name
:
"IX_Backet_UserId"
,
table
:
"Backet"
);
migrationBuilder
.
DropColumn
(
name
:
"BacketId"
,
table
:
"BacketItem"
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"ProductId"
,
table
:
"BacketItem"
,
type
:
"character varying(32)"
,
maxLength
:
32
,
nullable
:
false
,
oldClrType
:
typeof
(
string
),
oldMaxLength
:
32
,
oldNullable
:
true
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"Id"
,
table
:
"BacketItem"
,
type
:
"character varying(32)"
,
maxLength
:
32
,
nullable
:
true
,
oldClrType
:
typeof
(
string
),
oldMaxLength
:
32
);
migrationBuilder
.
AddColumn
<
string
>(
name
:
"BacketUserId"
,
table
:
"BacketItem"
,
type
:
"character varying(32)"
,
nullable
:
true
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"Id"
,
table
:
"Backet"
,
type
:
"character varying(32)"
,
maxLength
:
32
,
nullable
:
true
,
oldClrType
:
typeof
(
string
),
oldMaxLength
:
32
);
migrationBuilder
.
AddPrimaryKey
(
name
:
"PK_BacketItem"
,
table
:
"BacketItem"
,
column
:
"ProductId"
);
migrationBuilder
.
AddPrimaryKey
(
name
:
"PK_Backet"
,
table
:
"Backet"
,
column
:
"UserId"
);
migrationBuilder
.
CreateIndex
(
name
:
"IX_BacketItem_BacketUserId"
,
table
:
"BacketItem"
,
column
:
"BacketUserId"
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_BacketItem_Backet_BacketUserId"
,
table
:
"BacketItem"
,
column
:
"BacketUserId"
,
principalTable
:
"Backet"
,
principalColumn
:
"UserId"
,
onDelete
:
ReferentialAction
.
Restrict
);
}
}
}
samples/apis/Backet.Api/Migrations/BacketDbContextModelSnapshot.cs
0 → 100644
View file @
8ff3faf3
// <auto-generated />
using
Backet.Api.Infrastructure
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
namespace
Backet.Api.Migrations
{
[
DbContext
(
typeof
(
BacketDbContext
))]
partial
class
BacketDbContextModelSnapshot
:
ModelSnapshot
{
protected
override
void
BuildModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"3.1.0"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
long
>(
"TotalPrice"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"UserId"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"UserId"
);
b
.
ToTable
(
"Backet"
);
});
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.BacketItem"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"BacketId"
)
.
HasColumnType
(
"character varying(32)"
);
b
.
Property
<
long
>(
"Price"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"ProductId"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"ProductName"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(256)"
)
.
HasMaxLength
(
256
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"BacketId"
);
b
.
HasIndex
(
"ProductId"
);
b
.
ToTable
(
"BacketItem"
);
});
modelBuilder
.
Entity
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.BacketItem"
,
b
=>
{
b
.
HasOne
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet"
,
null
)
.
WithMany
(
"BacketItems"
)
.
HasForeignKey
(
"BacketId"
);
});
#pragma warning restore 612, 618
}
}
}
samples/apis/Product.Api/Application/DomainEventHandler/AddDefaultProductWhenProductTypeAdded2DomainEventHandler.cs
View file @
8ff3faf3
using
Pole.Application.EventBus
;
using
Pole.Domain
;
using
Product.Api.Application.IntergrationEvent
;
using
Product.Api.Domain.Event
;
using
Product.Api.Domain.ProductAggregate
;
using
Product.IntegrationEvents
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
samples/apis/Product.Api/Application/IntegrationEvent/CallBack/ProductAddedIntegrationEventCallback.cs
View file @
8ff3faf3
using
Pole.ReliableMessage.Abstraction
;
using
Product.Api.Application.IntergrationEvent
;
using
Product.Api.Application.Query.Abstraction
;
using
Product.Api.Domain.ProductAggregate
;
using
Product.IntegrationEvents
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
samples/apis/Product.Api/Product.Api.csproj
View file @
8ff3faf3
...
...
@@ -27,5 +27,6 @@
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage.Masstransit\Pole.ReliableMessage.Masstransit.csproj" />
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage.Storage.Mongodb\Pole.ReliableMessage.Storage.Mongodb.csproj" />
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage\Pole.ReliableMessage.csproj" />
<ProjectReference Include="..\..\intergrationEvents\Product.IntegrationEvents\Product.IntegrationEvents.csproj" />
</ItemGroup>
</Project>
\ No newline at end of file
samples/intergrationEvents/Product.IntegrationEvents/Product.IntegrationEvents.csproj
0 → 100644
View file @
8ff3faf3
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
samples/
apis/Backet.Api/Application/IntegrationEvent
/ProductAddedIntegrationEvent.cs
→
samples/
intergrationEvents/Product.IntegrationEvents
/ProductAddedIntegrationEvent.cs
View file @
8ff3faf3
...
...
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.
Api.Application.IntergrationEvent
namespace
Product.
IntegrationEvents
{
public
class
ProductAddedIntegrationEvent
{
...
...
src/Pole.ReliableMessage/EventBus/DefaultReliableEventFinder.cs
View file @
8ff3faf3
...
...
@@ -11,10 +11,10 @@ namespace Pole.ReliableMessage.EventBus
{
public
List
<
Type
>
FindAll
(
IEnumerable
<
Assembly
>
assemblies
)
{
var
event
Type
=
typeof
(
IReliableEventCallback
);
var
callback
Type
=
typeof
(
IReliableEventCallback
);
var
eventTypes
=
assemblies
.
SelectMany
(
m
=>
m
.
GetTypes
().
Where
(
type
=>
event
Type
.
IsAssignableFrom
(
type
)));
return
event
Types
.
ToList
();
;
var
callbackTypes
=
assemblies
.
SelectMany
(
m
=>
m
.
GetTypes
().
Where
(
type
=>
callback
Type
.
IsAssignableFrom
(
type
)));
return
callback
Types
.
ToList
();
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment