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
2bb0a31b
authored
5 years ago
by
丁松杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 产品 微服务 数据
parent
12b51940
master
…
v1.0.0
v0.0.1
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
595 additions
and
6 deletions
Pole.sln
samples/apis/Order.Api/Order.Api.csproj
samples/apis/Product.Api/Domain/ProductAggregate/IProductRepository.cs
samples/apis/Product.Api/Domain/ProductAggregate/Product.cs
samples/apis/Product.Api/Domain/ProductTypeAggregate/ProductType.cs
samples/apis/Product.Api/Infrastructure/EntityConfigurations/ProductEntityTypeConfiguration.cs
samples/apis/Product.Api/Infrastructure/EntityConfigurations/ProductTypeEntityTypeConfiguration.cs
samples/apis/Product.Api/Infrastructure/ProductDbContext.cs
samples/apis/Product.Api/Migrations/20200108090435_init.Designer.cs
samples/apis/Product.Api/Migrations/20200108090435_init.cs
samples/apis/Product.Api/Migrations/20200108092455_Modify_Product_ProductId.Designer.cs
samples/apis/Product.Api/Migrations/20200108092455_Modify_Product_ProductId.cs
samples/apis/Product.Api/Migrations/ProductDbContextModelSnapshot.cs
samples/apis/Product.Api/Product.Api.csproj
samples/apis/Product.Api/ProductDbContextDesignFactory.cs
samples/apis/Product.Api/Startup.cs
samples/apis/Product.Api/appsettings.Development.json
samples/proto/service/Order/order.proto
samples/proto/service/Product/product.proto
samples/proto/service/Product/productType.proto
src/Pole.Core/MediatR/IServiceCollectionExtensions.cs
src/Pole.Core/Pole.Core.csproj
src/Pole.Domain.EntityframeworkCore/MediatR/NoMediator.cs
src/Pole.Domain/Entity/AggregateRoot.cs → src/Pole.Domain/Entity/IAggregateRoot.cs
src/Pole.Domain/IRepository.cs
src/Pole.Domain/Pole.Domain.csproj
src/Pole.Domain/ServiceCollectionExtensions.cs
Pole.sln
View file @
2bb0a31b
...
@@ -35,11 +35,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pole.ReliableMessage.Storag
...
@@ -35,11 +35,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pole.ReliableMessage.Storag
EndProject
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "webs", "webs", "{452B9D9E-881E-4E0E-A90B-98F2253F20F1}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "webs", "webs", "{452B9D9E-881E-4E0E-A90B-98F2253F20F1}"
EndProject
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "Order.Api", "samples\apis\Order.Api\Order.Api.csproj", "{098DF771-6DC6-45D4-ABFA-FF84E8F7750B}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "Order.Api", "samples\apis\Order.Api\Order.Api.csproj", "{098DF771-6DC6-45D4-ABFA-FF84E8F7750B}"
EndProject
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "Product.Api", "samples\apis\Product.Api\Product.Api.csproj", "{125B1E4B-B1C1-4F85-9C6A-38815960E654}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "Product.Api", "samples\apis\Product.Api\Product.Api.csproj", "{125B1E4B-B1C1-4F85-9C6A-38815960E654}"
EndProject
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "Backet.Api", "samples\apis\Backet.Api\Backet.Api.csproj", "{C961F25C-1C11-4855-84E4-ADABE96451E7}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "Backet.Api", "samples\apis\Backet.Api\Backet.Api.csproj", "{C961F25C-1C11-4855-84E4-ADABE96451E7}"
EndProject
EndProject
Global
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
This diff is collapsed.
Click to expand it.
samples/apis/Order.Api/Order.Api.csproj
View file @
2bb0a31b
...
@@ -5,6 +5,13 @@
...
@@ -5,6 +5,13 @@
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage.Masstransit\Pole.ReliableMessage.Masstransit.csproj" />
<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.Storage.Mongodb\Pole.ReliableMessage.Storage.Mongodb.csproj" />
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage\Pole.ReliableMessage.csproj" />
<ProjectReference Include="..\..\..\src\Pole.ReliableMessage\Pole.ReliableMessage.csproj" />
...
...
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Domain/ProductAggregate/IProductRepository.cs
0 → 100644
View file @
2bb0a31b
using
Pole.Domain
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api.Domain.ProductAggregate
{
public
interface
IProductRepository
:
IRepository
<
Product
>
{
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Domain/ProductAggregate/Product.cs
0 → 100644
View file @
2bb0a31b
using
Pole.Domain
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api.Domain.ProductAggregate
{
public
class
Product
:
Entity
,
IAggregateRoot
{
public
string
Name
{
get
;
set
;
}
public
long
Price
{
get
;
set
;
}
public
string
ProductId
{
get
;
set
;
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Domain/ProductTypeAggregate/ProductType.cs
0 → 100644
View file @
2bb0a31b
using
Pole.Domain
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api.Domain.ProductTypeAggregate
{
public
class
ProductType
:
Entity
,
IAggregateRoot
{
public
string
Name
{
get
;
set
;
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Infrastructure/EntityConfigurations/ProductEntityTypeConfiguration.cs
0 → 100644
View file @
2bb0a31b
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api.Infrastructure.EntityConfigurations
{
public
class
ProductEntityTypeEntityTypeConfiguration
:
IEntityTypeConfiguration
<
Product
.
Api
.
Domain
.
ProductAggregate
.
Product
>
{
public
void
Configure
(
EntityTypeBuilder
<
Product
.
Api
.
Domain
.
ProductAggregate
.
Product
>
builder
)
{
builder
.
ToTable
(
nameof
(
Product
));
builder
.
Property
(
m
=>
m
.
Id
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
Name
).
HasMaxLength
(
256
).
IsRequired
();
builder
.
Property
(
m
=>
m
.
ProductId
).
HasMaxLength
(
32
).
IsRequired
();
builder
.
Ignore
(
m
=>
m
.
DomainEvents
);
builder
.
HasIndex
(
m
=>
m
.
ProductId
);
builder
.
HasKey
(
m
=>
m
.
Id
);
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Infrastructure/EntityConfigurations/ProductTypeEntityTypeConfiguration.cs
0 → 100644
View file @
2bb0a31b
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
Product.Api.Domain.ProductTypeAggregate
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api.Infrastructure.EntityConfigurations
{
public
class
ProductTypeEntityTypeConfiguration
:
IEntityTypeConfiguration
<
ProductType
>
{
public
void
Configure
(
EntityTypeBuilder
<
ProductType
>
builder
)
{
builder
.
ToTable
(
nameof
(
ProductType
));
builder
.
Property
(
m
=>
m
.
Id
).
HasMaxLength
(
32
);
builder
.
Property
(
m
=>
m
.
Name
).
HasMaxLength
(
256
).
IsRequired
();
builder
.
Ignore
(
m
=>
m
.
DomainEvents
);
builder
.
HasKey
(
m
=>
m
.
Id
);
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Infrastructure/ProductDbContext.cs
0 → 100644
View file @
2bb0a31b
using
MediatR
;
using
Microsoft.EntityFrameworkCore
;
using
Pole.EntityframeworkCore
;
using
Product.Api.Infrastructure.EntityConfigurations
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api.Infrastructure
{
public
class
ProductDbContext
:
DbContextBase
{
public
ProductDbContext
(
DbContextOptions
options
,
IMediator
mediator
)
:
base
(
options
,
mediator
)
{
}
protected
override
void
OnModelCreating
(
ModelBuilder
builder
)
{
base
.
OnModelCreating
(
builder
);
builder
.
ApplyConfiguration
(
new
ProductEntityTypeEntityTypeConfiguration
());
builder
.
ApplyConfiguration
(
new
ProductTypeEntityTypeConfiguration
());
//builder.ApplyConfiguration(new ThinkNestDirectSalesManagerEntityTypeConfiguration());
//builder.ApplyConfiguration(new ThinkNestInDirectSalesManagerEntityTypeConfiguration());
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Migrations/20200108090435_init.Designer.cs
0 → 100644
View file @
2bb0a31b
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
using
Product.Api.Infrastructure
;
namespace
Product.Api.Migrations
{
[
DbContext
(
typeof
(
ProductDbContext
))]
[
Migration
(
"20200108090435_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
(
"Product.Api.Domain.ProductAggregate.Product"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"Name"
)
.
HasColumnType
(
"character varying(256)"
)
.
HasMaxLength
(
256
);
b
.
Property
<
long
>(
"Price"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"ProductId"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"ProductId"
);
b
.
ToTable
(
"Product"
);
});
#pragma warning restore 612, 618
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Migrations/20200108090435_init.cs
0 → 100644
View file @
2bb0a31b
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Product.Api.Migrations
{
public
partial
class
init
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
CreateTable
(
name
:
"Product"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
string
>(
maxLength
:
32
,
nullable
:
false
),
Name
=
table
.
Column
<
string
>(
maxLength
:
256
,
nullable
:
true
),
Price
=
table
.
Column
<
long
>(
nullable
:
false
),
ProductId
=
table
.
Column
<
string
>(
maxLength
:
32
,
nullable
:
true
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_Product"
,
x
=>
x
.
Id
);
});
migrationBuilder
.
CreateIndex
(
name
:
"IX_Product_ProductId"
,
table
:
"Product"
,
column
:
"ProductId"
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"Product"
);
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Migrations/20200108092455_Modify_Product_ProductId.Designer.cs
0 → 100644
View file @
2bb0a31b
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
using
Product.Api.Infrastructure
;
namespace
Product.Api.Migrations
{
[
DbContext
(
typeof
(
ProductDbContext
))]
[
Migration
(
"20200108092455_Modify_Product_ProductId"
)]
partial
class
Modify_Product_ProductId
{
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
(
"Product.Api.Domain.ProductAggregate.Product"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(256)"
)
.
HasMaxLength
(
256
);
b
.
Property
<
long
>(
"Price"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"ProductId"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"ProductId"
);
b
.
ToTable
(
"Product"
);
});
#pragma warning restore 612, 618
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Migrations/20200108092455_Modify_Product_ProductId.cs
0 → 100644
View file @
2bb0a31b
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Product.Api.Migrations
{
public
partial
class
Modify_Product_ProductId
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"ProductId"
,
table
:
"Product"
,
maxLength
:
32
,
nullable
:
false
,
oldClrType
:
typeof
(
string
),
oldType
:
"character varying(32)"
,
oldMaxLength
:
32
,
oldNullable
:
true
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"Name"
,
table
:
"Product"
,
maxLength
:
256
,
nullable
:
false
,
oldClrType
:
typeof
(
string
),
oldType
:
"character varying(256)"
,
oldMaxLength
:
256
,
oldNullable
:
true
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"ProductId"
,
table
:
"Product"
,
type
:
"character varying(32)"
,
maxLength
:
32
,
nullable
:
true
,
oldClrType
:
typeof
(
string
),
oldMaxLength
:
32
);
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"Name"
,
table
:
"Product"
,
type
:
"character varying(256)"
,
maxLength
:
256
,
nullable
:
true
,
oldClrType
:
typeof
(
string
),
oldMaxLength
:
256
);
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Migrations/ProductDbContextModelSnapshot.cs
0 → 100644
View file @
2bb0a31b
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
using
Product.Api.Infrastructure
;
namespace
Product.Api.Migrations
{
[
DbContext
(
typeof
(
ProductDbContext
))]
partial
class
ProductDbContextModelSnapshot
:
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
(
"Product.Api.Domain.ProductAggregate.Product"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(256)"
)
.
HasMaxLength
(
256
);
b
.
Property
<
long
>(
"Price"
)
.
HasColumnType
(
"bigint"
);
b
.
Property
<
string
>(
"ProductId"
)
.
IsRequired
()
.
HasColumnType
(
"character varying(32)"
)
.
HasMaxLength
(
32
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"ProductId"
);
b
.
ToTable
(
"Product"
);
});
#pragma warning restore 612, 618
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Product.Api.csproj
View file @
2bb0a31b
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</PropertyGroup>
<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="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" 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>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Pole.Domain.EntityframeworkCore\Pole.Domain.EntityframeworkCore.csproj" />
<ProjectReference Include="..\..\..\src\Pole.Domain\Pole.Domain.csproj" />
</ItemGroup>
</Project>
</Project>
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/ProductDbContextDesignFactory.cs
0 → 100644
View file @
2bb0a31b
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Design
;
using
Microsoft.Extensions.Configuration
;
using
Pole.Domain.EntityframeworkCore.MediatR
;
using
Product.Api.Infrastructure
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Product.Api
{
public
class
ProductDbContextDesignFactory
:
IDesignTimeDbContextFactory
<
ProductDbContext
>
{
public
ProductDbContext
CreateDbContext
(
string
[]
args
)
{
IConfigurationRoot
configuration
=
new
ConfigurationBuilder
()
.
SetBasePath
(
Directory
.
GetCurrentDirectory
())
.
AddJsonFile
(
"appsettings.Development.json"
)
.
Build
();
var
optionsBuilder
=
new
DbContextOptionsBuilder
<
ProductDbContext
>()
.
UseNpgsql
(
configuration
[
"postgres:main"
]);
return
new
ProductDbContext
(
optionsBuilder
.
Options
,
new
NoMediator
());
}
}
}
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/Startup.cs
View file @
2bb0a31b
...
@@ -5,17 +5,31 @@ using System.Threading.Tasks;
...
@@ -5,17 +5,31 @@ using System.Threading.Tasks;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
Product.Api.Infrastructure
;
namespace
Product.Api
namespace
Product.Api
{
{
public
class
Startup
public
class
Startup
{
{
private
IConfiguration
Configuration
{
get
;
}
private
IWebHostEnvironment
Environment
{
get
;
}
public
Startup
(
IConfiguration
configuration
,
IWebHostEnvironment
env
)
{
this
.
Configuration
=
configuration
;
this
.
Environment
=
env
;
}
// This method gets called by the runtime. Use this method to add services to the container.
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public
void
ConfigureServices
(
IServiceCollection
services
)
public
void
ConfigureServices
(
IServiceCollection
services
)
{
{
services
.
AddDbContext
<
ProductDbContext
>(
options
=>
options
.
UseNpgsql
(
Configuration
[
"postgres:main"
]));
services
.
AddPoleDomain
();
}
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
This diff is collapsed.
Click to expand it.
samples/apis/Product.Api/appsettings.Development.json
View file @
2bb0a31b
...
@@ -5,5 +5,8 @@
...
@@ -5,5 +5,8 @@
"Microsoft"
:
"Warning"
,
"Microsoft"
:
"Warning"
,
"Microsoft.Hosting.Lifetime"
:
"Information"
"Microsoft.Hosting.Lifetime"
:
"Information"
}
}
},
"postgres"
:
{
"main"
:
"Server=192.168.0.248;Port=5432;Username=postgres;Password=comteck2020!@#;Database=Pole_samples_Product;Enlist=True;Timeout=0;Command Timeout=600;Pooling=false;MinPoolSize=20;MaxPoolSize=500;"
}
}
}
}
This diff is collapsed.
Click to expand it.
samples/proto/service/Order/order.proto
0 → 100644
View file @
2bb0a31b
syntax
=
"proto3"
;
package
newArchitectureLab
.
apps.order
;
service
Order
{
rpc
GetById
(
GetByIdRequest
)
returns
(
GetByIdResponse
);
}
message
GetByIdRequest
{
string
id
=
1
;
}
message
GetByIdResponse
{
string
id
=
1
;
double
totalprice
=
2
;
repeated
Product
products
=
3
;
message
Product
{
string
id
=
1
;
string
name
=
2
;
double
price
=
3
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
samples/proto/service/Product/product.proto
0 → 100644
View file @
2bb0a31b
syntax
=
"proto3"
;
package
newArchitectureLab
.
apps.product
;
// The product service definition.
service
Product
{
rpc
GetById
(
GetByIdRequest
)
returns
(
GetByIdResponse
);
}
message
GetByIdRequest
{
string
Id
=
1
;
}
message
GetByIdResponse
{
string
id
=
1
;
string
name
=
2
;
double
price
=
3
;
int64
stock
=
4
;
string
productTypeId
=
5
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
samples/proto/service/Product/productType.proto
0 → 100644
View file @
2bb0a31b
syntax
=
"proto3"
;
package
newArchitectureLab
.
apps.product
;
// The greeting service definition.
service
ProductType
{
// Sends a greeting
rpc
GetById
(
GetProductTypeRequest
)
returns
(
GetProductTypeResponse
);
}
// The request message containing the user's name.
message
GetProductTypeRequest
{
string
id
=
1
;
}
// The response message containing the greetings.
message
GetProductTypeResponse
{
string
id
=
1
;
string
name
=
2
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Pole.Core/MediatR/IServiceCollectionExtensions.cs
0 → 100644
View file @
2bb0a31b
using
MediatR
;
using
MediatR.Registration
;
using
Microsoft.Extensions.DependencyInjection
;
using
System
;
using
System.Collections.Generic
;
using
System.Reflection
;
using
System.Text
;
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
IServiceCollectionExtensions
{
public
static
IServiceCollection
AddMediatR
(
this
IServiceCollection
services
)
{
var
serviceConfig
=
new
MediatRServiceConfiguration
();
ServiceRegistrar
.
AddRequiredServices
(
services
,
serviceConfig
);
ServiceRegistrar
.
AddMediatRClasses
(
services
,
new
Assembly
[
0
]);
return
services
;
}
}
}
This diff is collapsed.
Click to expand it.
src/Pole.Core/Pole.Core.csproj
View file @
2bb0a31b
...
@@ -4,4 +4,8 @@
...
@@ -4,4 +4,8 @@
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="8.0.0" />
</ItemGroup>
</Project>
</Project>
This diff is collapsed.
Click to expand it.
src/Pole.Domain.EntityframeworkCore/MediatR/NoMediator.cs
0 → 100644
View file @
2bb0a31b
using
MediatR
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
Pole.Domain.EntityframeworkCore.MediatR
{
public
class
NoMediator
:
IMediator
{
public
Task
Publish
(
object
notification
,
CancellationToken
cancellationToken
=
default
)
{
return
Task
.
CompletedTask
;
}
public
Task
Publish
<
TNotification
>(
TNotification
notification
,
CancellationToken
cancellationToken
=
default
)
where
TNotification
:
INotification
{
return
Task
.
CompletedTask
;
}
public
Task
<
TResponse
>
Send
<
TResponse
>(
IRequest
<
TResponse
>
request
,
CancellationToken
cancellationToken
=
default
)
{
return
Task
.
FromResult
(
default
(
TResponse
));
}
public
Task
<
object
>
Send
(
object
request
,
CancellationToken
cancellationToken
=
default
)
{
return
Task
.
FromResult
(
default
(
object
));
}
}
}
This diff is collapsed.
Click to expand it.
src/Pole.Domain/Entity/AggregateRoot.cs
→
src/Pole.Domain/Entity/
I
AggregateRoot.cs
View file @
2bb0a31b
...
@@ -5,5 +5,5 @@ using System.Text;
...
@@ -5,5 +5,5 @@ using System.Text;
namespace
Pole.Domain
namespace
Pole.Domain
{
{
public
interface
AggregateRoot
{
}
public
interface
I
AggregateRoot
{
}
}
}
This diff is collapsed.
Click to expand it.
src/Pole.Domain/IRepository.cs
View file @
2bb0a31b
...
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
...
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace
Pole.Domain
namespace
Pole.Domain
{
{
public
interface
IRepository
<
T
>
:
IRepository
where
T
:
AggregateRoot
public
interface
IRepository
<
T
>
:
IRepository
where
T
:
I
AggregateRoot
{
{
void
Update
(
T
entity
);
void
Update
(
T
entity
);
void
Delete
(
T
entity
);
void
Delete
(
T
entity
);
...
...
This diff is collapsed.
Click to expand it.
src/Pole.Domain/Pole.Domain.csproj
View file @
2bb0a31b
...
@@ -6,6 +6,12 @@
...
@@ -6,6 +6,12 @@
<ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="8.0.0" />
<PackageReference Include="MediatR" Version="8.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pole.Core\Pole.Core.csproj" />
</ItemGroup>
</ItemGroup>
</Project>
</Project>
This diff is collapsed.
Click to expand it.
src/Pole.Domain/ServiceCollectionExtensions.cs
0 → 100644
View file @
2bb0a31b
using
MediatR
;
using
Microsoft.Extensions.DependencyInjection
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
ServiceCollectionExtensions
{
public
static
IServiceCollection
AddPoleDomain
(
this
IServiceCollection
service
)
{
service
.
AddMediatR
();
return
service
;
}
}
}
This diff is collapsed.
Click to expand it.
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