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
70eb14eb
authored
Jan 19, 2020
by
dingsongjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成 backet 领域模型
parent
8ff3faf3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
256 additions
and
4 deletions
samples/apis/Backet.Api/Backet.Api.csproj
samples/apis/Backet.Api/Domain/AggregatesModel/BacketAggregate/Backet.cs
samples/apis/Backet.Api/Domain/AggregatesModel/BacketAggregate/BacketItem.cs
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketEntityTypeConfiguration.cs
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketItemEntityTypeConfiguration.cs
samples/apis/Backet.Api/Migrations/20200119013821_Remove_BacketItem_FK_Constraint.Designer.cs
samples/apis/Backet.Api/Migrations/20200119013821_Remove_BacketItem_FK_Constraint.cs
samples/apis/Backet.Api/Migrations/20200119020249_Update_BacketItem_FK_Constraint.Designer.cs
samples/apis/Backet.Api/Migrations/20200119020249_Update_BacketItem_FK_Constraint.cs
samples/apis/Backet.Api/Migrations/BacketDbContextModelSnapshot.cs
samples/apis/Backet.Api/Backet.Api.csproj
View file @
70eb14eb
...
...
@@ -9,6 +9,12 @@
<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" />
<Compile Remove="Migrations\20200119012712_Remove_BacketItem_FK_Constraint.cs" />
<Compile Remove="Migrations\20200119012712_Remove_BacketItem_FK_Constraint.Designer.cs" />
<Compile Remove="Migrations\20200119013717_Remove_BacketItem_FK_Constraint.cs" />
<Compile Remove="Migrations\20200119013717_Remove_BacketItem_FK_Constraint.Designer.cs" />
<Compile Remove="Migrations\20200119020005_Update_BacketItem_FK_Constraint.cs" />
<Compile Remove="Migrations\20200119020005_Update_BacketItem_FK_Constraint.Designer.cs" />
</ItemGroup>
<ItemGroup>
...
...
samples/apis/Backet.Api/Domain/AggregatesModel/BacketAggregate/Backet.cs
View file @
70eb14eb
...
...
@@ -9,7 +9,7 @@ namespace Backet.Api.Domain.AggregatesModel.BacketAggregate
public
class
Backet
:
Entity
,
IAggregateRoot
{
public
string
UserId
{
get
;
set
;
}
public
I
ReadOnlyCollection
<
BacketItem
>
BacketItems
{
get
;
private
set
;
}
public
I
Enumerable
<
BacketItem
>
BacketItems
{
get
;
private
set
;
}
public
long
TotalPrice
{
get
;
set
;
}
}
}
samples/apis/Backet.Api/Domain/AggregatesModel/BacketAggregate/BacketItem.cs
View file @
70eb14eb
...
...
@@ -11,5 +11,6 @@ namespace Backet.Api.Domain.AggregatesModel.BacketAggregate
public
string
ProductId
{
get
;
set
;
}
public
string
ProductName
{
get
;
set
;
}
public
long
Price
{
get
;
set
;
}
public
string
BacketId
{
get
;
set
;
}
}
}
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketEntityTypeConfiguration.cs
View file @
70eb14eb
...
...
@@ -15,7 +15,7 @@ namespace Backet.Api.Infrastructure.EntityConfigurations
builder
.
Property
(
m
=>
m
.
Id
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
UserId
).
HasMaxLength
(
32
).
IsRequired
();
builder
.
HasMany
(
m
=>
m
.
BacketItems
).
WithOne
();
builder
.
HasMany
(
m
=>
m
.
BacketItems
).
WithOne
()
.
IsRequired
().
OnDelete
(
DeleteBehavior
.
Cascade
).
HasForeignKey
(
"BacketId"
)
;
builder
.
Ignore
(
m
=>
m
.
DomainEvents
);
...
...
samples/apis/Backet.Api/Infrastructure/EntityConfigurations/BacketItemEntityTypeConfiguration.cs
View file @
70eb14eb
...
...
@@ -17,6 +17,7 @@ namespace Backet.Api.Infrastructure.EntityConfigurations
builder
.
Property
(
m
=>
m
.
Id
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
ProductId
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
ProductName
).
HasMaxLength
(
256
).
IsRequired
();
builder
.
Property
(
m
=>
m
.
BacketId
).
HasMaxLength
(
32
).
IsRequired
();
builder
.
Ignore
(
m
=>
m
.
DomainEvents
);
...
...
samples/apis/Backet.Api/Migrations/20200119013821_Remove_BacketItem_FK_Constraint.Designer.cs
0 → 100644
View file @
70eb14eb
// <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
(
"20200119013821_Remove_BacketItem_FK_Constraint"
)]
partial
class
Remove_BacketItem_FK_Constraint
{
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"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
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"
)
.
OnDelete
(
DeleteBehavior
.
Restrict
);
});
#pragma warning restore 612, 618
}
}
}
samples/apis/Backet.Api/Migrations/20200119013821_Remove_BacketItem_FK_Constraint.cs
0 → 100644
View file @
70eb14eb
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Backet.Api.Migrations
{
public
partial
class
Remove_BacketItem_FK_Constraint
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"BacketId"
,
table
:
"BacketItem"
,
maxLength
:
32
,
nullable
:
false
,
oldClrType
:
typeof
(
string
),
oldType
:
"character varying(32)"
,
oldNullable
:
true
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"BacketId"
,
table
:
"BacketItem"
,
type
:
"character varying(32)"
,
nullable
:
true
,
oldClrType
:
typeof
(
string
),
oldMaxLength
:
32
);
}
}
}
samples/apis/Backet.Api/Migrations/20200119020249_Update_BacketItem_FK_Constraint.Designer.cs
0 → 100644
View file @
70eb14eb
// <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
(
"20200119020249_Update_BacketItem_FK_Constraint"
)]
partial
class
Update_BacketItem_FK_Constraint
{
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"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
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"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
});
#pragma warning restore 612, 618
}
}
}
samples/apis/Backet.Api/Migrations/20200119020249_Update_BacketItem_FK_Constraint.cs
0 → 100644
View file @
70eb14eb
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Backet.Api.Migrations
{
public
partial
class
Update_BacketItem_FK_Constraint
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_BacketItem_Backet_BacketId"
,
table
:
"BacketItem"
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_BacketItem_Backet_BacketId"
,
table
:
"BacketItem"
,
column
:
"BacketId"
,
principalTable
:
"Backet"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_BacketItem_Backet_BacketId"
,
table
:
"BacketItem"
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_BacketItem_Backet_BacketId"
,
table
:
"BacketItem"
,
column
:
"BacketId"
,
principalTable
:
"Backet"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Restrict
);
}
}
}
samples/apis/Backet.Api/Migrations/BacketDbContextModelSnapshot.cs
View file @
70eb14eb
...
...
@@ -46,7 +46,9 @@ namespace Backet.Api.Migrations
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"BacketId"
)
.
HasColumnType
(
"character varying(32)"
);
.
IsRequired
()
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
long
>(
"Price"
)
.
HasColumnType
(
"bigint"
);
...
...
@@ -73,7 +75,9 @@ namespace Backet.Api.Migrations
{
b
.
HasOne
(
"Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet"
,
null
)
.
WithMany
(
"BacketItems"
)
.
HasForeignKey
(
"BacketId"
);
.
HasForeignKey
(
"BacketId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
});
#pragma warning restore 612, 618
}
...
...
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