committed by
GitHub
61 changed files with 3359 additions and 2820 deletions
@ -1,114 +0,0 @@ |
|||||
{ |
|
||||
"App": { |
|
||||
"TrackingEntitiesChanged": true, |
|
||||
"SelfUrl": "http://localhost:44385/", |
|
||||
"CorsOrigins": "http://localhost:4200,http://localhost:9528,http://127.0.0.1:63898" |
|
||||
}, |
|
||||
"AppSelfUrl": "http://localhost:44385/", |
|
||||
"ConnectionStrings": { |
|
||||
"Default": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpIdentity": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" |
|
||||
}, |
|
||||
"CAP": { |
|
||||
"EventBus": { |
|
||||
"DefaultGroupName": "AuthServer", |
|
||||
"Version": "v1", |
|
||||
"FailedRetryInterval": 300, |
|
||||
"FailedRetryCount": 10 |
|
||||
}, |
|
||||
"RabbitMQ": { |
|
||||
"HostName": "127.0.0.1", |
|
||||
"Port": 5672, |
|
||||
"UserName": "admin", |
|
||||
"Password": "admin", |
|
||||
"ExchangeName": "LINGYUN.AbpApplication", |
|
||||
"VirtualHost": "multi.service.test" |
|
||||
} |
|
||||
}, |
|
||||
"Redis": { |
|
||||
"Configuration": "127.0.0.1", |
|
||||
"InstanceName": "LINGYUN.AbpApplication", |
|
||||
"DefaultDatabase": 10 |
|
||||
}, |
|
||||
"AuthServer": { |
|
||||
"Authority": "http://localhost:44385/", |
|
||||
"ApiName": "lingyun-abp-application" |
|
||||
}, |
|
||||
"IdentityServer": { |
|
||||
"Clients": { |
|
||||
"AuthManagement": { |
|
||||
"ClientId": "auth-management", |
|
||||
"RootUrl": "http://localhost:44313/" |
|
||||
}, |
|
||||
"AuthVueAdmin": { |
|
||||
"ClientId": "vue-admin-element" |
|
||||
}, |
|
||||
"AuthApiGateway": { |
|
||||
"ClientId": "ApigatewayHostClient" |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
"Serilog": { |
|
||||
"MinimumLevel": { |
|
||||
"Default": "Information", |
|
||||
"Override": { |
|
||||
"System": "Warning", |
|
||||
"Microsoft": "Warning", |
|
||||
"DotNetCore": "Information" |
|
||||
} |
|
||||
}, |
|
||||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId" ], |
|
||||
"WriteTo": [ |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Debug-.log", |
|
||||
"restrictedToMinimumLevel": "Debug", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Info-.log", |
|
||||
"restrictedToMinimumLevel": "Information", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Warn-.log", |
|
||||
"restrictedToMinimumLevel": "Warning", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Error-.log", |
|
||||
"restrictedToMinimumLevel": "Error", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Fatal-.log", |
|
||||
"restrictedToMinimumLevel": "Fatal", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
} |
|
||||
@ -1,143 +0,0 @@ |
|||||
{ |
|
||||
"App": { |
|
||||
"TrackingEntitiesChanged": true, |
|
||||
"SelfUrl": "http://localhost:44385/" |
|
||||
}, |
|
||||
"ConnectionStrings": { |
|
||||
"Default": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpIdentity": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" |
|
||||
}, |
|
||||
"Logging": { |
|
||||
"Serilog": { |
|
||||
"Elasticsearch": { |
|
||||
"IndexFormat": "linyun.abp.logging-{0:yyyy.MM.dd}" |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
"AuditLogging": { |
|
||||
"Elasticsearch": { |
|
||||
"IndexPrefix": "lingyun.abp.auditing" |
|
||||
} |
|
||||
}, |
|
||||
"Elasticsearch": { |
|
||||
"NodeUris": "http://localhost:9200" |
|
||||
}, |
|
||||
"Location": { |
|
||||
"Baidu": { |
|
||||
"AccessKey": "你自己的百度地图WebAPI Key", |
|
||||
"ExtensionsRoad": true, |
|
||||
"ExtensionsTown": true, |
|
||||
"ExtensionsPoi": "1", |
|
||||
"VisableErrorToClient": true |
|
||||
}, |
|
||||
"Tencent": { |
|
||||
"AccessKey": "你自己的腾讯地图WebAPI Key", |
|
||||
"SecretKey": "你自己的腾讯地图WebAPI SecretKey Key, 不填的话不计算签名", |
|
||||
"VisableErrorToClient": true |
|
||||
} |
|
||||
}, |
|
||||
"CAP": { |
|
||||
"EventBus": { |
|
||||
"DefaultGroupName": "BackendAdmin", |
|
||||
"Version": "v1", |
|
||||
"FailedRetryInterval": 300, |
|
||||
"FailedRetryCount": 10 |
|
||||
}, |
|
||||
"RabbitMQ": { |
|
||||
"HostName": "Your RabbitMQ server connection address", |
|
||||
"Port": 5672, |
|
||||
"UserName": "Your RabbitMQ server connection user", |
|
||||
"Password": "Your RabbitMQ server connection user password", |
|
||||
"ExchangeName": "The name of your RabbitMQ server switch", |
|
||||
"VirtualHost": "Name of your RabbitMQ server VirtualHost" |
|
||||
} |
|
||||
}, |
|
||||
"Redis": { |
|
||||
"Configuration": "127.0.0.1", |
|
||||
"InstanceName": "LINGYUN.AbpApplication", |
|
||||
"DefaultDatabase": 10 |
|
||||
}, |
|
||||
"AuthServer": { |
|
||||
"Authority": "http://localhost:44385/", |
|
||||
"ApiName": "lingyun-abp-application" |
|
||||
}, |
|
||||
"Serilog": { |
|
||||
"MinimumLevel": { |
|
||||
"Default": "Debug", |
|
||||
"Override": { |
|
||||
"Microsoft.EntityFrameworkCore": "Debug", |
|
||||
"System": "Warning", |
|
||||
"Microsoft": "Warning" |
|
||||
} |
|
||||
}, |
|
||||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId" ], |
|
||||
"WriteTo": [ |
|
||||
{ |
|
||||
"Name": "Console", |
|
||||
"Args": { |
|
||||
"restrictedToMinimumLevel": "Debug", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "Elasticsearch", |
|
||||
"Args": { |
|
||||
"nodeUris": "http://localhost:9200", |
|
||||
"indexFormat": "linyun.abp.logging-{0:yyyy.MM.dd}", |
|
||||
"autoRegisterTemplate": true, |
|
||||
"autoRegisterTemplateVersion": "ESv7" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Debug-.log", |
|
||||
"restrictedToMinimumLevel": "Debug", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Info-.log", |
|
||||
"restrictedToMinimumLevel": "Information", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Warn-.log", |
|
||||
"restrictedToMinimumLevel": "Warning", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Error-.log", |
|
||||
"restrictedToMinimumLevel": "Error", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Fatal-.log", |
|
||||
"restrictedToMinimumLevel": "Fatal", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
} |
|
||||
@ -1,107 +0,0 @@ |
|||||
{ |
|
||||
"App": { |
|
||||
"CorsOrigins": "http://localhost:9527,http://127.0.0.1:30000" |
|
||||
}, |
|
||||
"ConnectionStrings": { |
|
||||
"Default": "Server=127.0.0.1;Database=Messages;User Id=root;Password=123456", |
|
||||
"MessageService": "Server=127.0.0.1;Database=Messages;User Id=root;Password=123456", |
|
||||
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" |
|
||||
}, |
|
||||
"Redis": { |
|
||||
"Configuration": "127.0.0.1,defaultDatabase=10", |
|
||||
"InstanceName": "LINGYUN.AbpApplication" |
|
||||
}, |
|
||||
"AuthServer": { |
|
||||
"Authority": "http://localhost:44385/", |
|
||||
"ApiName": "lingyun-abp-application" |
|
||||
}, |
|
||||
"Hangfire": { |
|
||||
"MySql": { |
|
||||
"Connection": "Server=127.0.0.1;Database=Messages;User Id=root;Password=123456;Allow User Variables=true", |
|
||||
"TablePrefix": "AppHangfire" |
|
||||
} |
|
||||
}, |
|
||||
"Notifications": { |
|
||||
"WeChat": { |
|
||||
"WeApp": { |
|
||||
"DefaultWeAppState": "formal" |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
"CAP": { |
|
||||
"EventBus": { |
|
||||
"DefaultGroupName": "MessageService", |
|
||||
"Version": "v1", |
|
||||
"FailedRetryInterval": 300, |
|
||||
"FailedRetryCount": 10 |
|
||||
}, |
|
||||
"RabbitMQ": { |
|
||||
"HostName": "127.0.0.1", |
|
||||
"Port": 5672, |
|
||||
"UserName": "admin", |
|
||||
"Password": "admin", |
|
||||
"ExchangeName": "LINGYUN.AbpApplication", |
|
||||
"VirtualHost": "multi.service.test" |
|
||||
} |
|
||||
}, |
|
||||
"Serilog": { |
|
||||
"MinimumLevel": { |
|
||||
"Default": "Debug", |
|
||||
"Override": { |
|
||||
"Microsoft.EntityFrameworkCore": "Debug", |
|
||||
"System": "Warning", |
|
||||
"Microsoft": "Warning" |
|
||||
} |
|
||||
}, |
|
||||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId" ], |
|
||||
"WriteTo": [ |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Debug-.log", |
|
||||
"restrictedToMinimumLevel": "Debug", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Info-.log", |
|
||||
"restrictedToMinimumLevel": "Information", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Warn-.log", |
|
||||
"restrictedToMinimumLevel": "Warning", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Error-.log", |
|
||||
"restrictedToMinimumLevel": "Error", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Fatal-.log", |
|
||||
"restrictedToMinimumLevel": "Fatal", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
} |
|
||||
@ -1,119 +0,0 @@ |
|||||
{ |
|
||||
"App": { |
|
||||
"CorsOrigins": "http://localhost:9527,http://127.0.0.1:30000" |
|
||||
}, |
|
||||
"ConnectionStrings": { |
|
||||
"Default": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AppPlatform": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" |
|
||||
}, |
|
||||
"Features": { |
|
||||
"Validation": { |
|
||||
"Redis": { |
|
||||
"Configuration": "127.0.0.1,defaultDatabase=11", |
|
||||
"InstanceName": "LINGYUN.Abp.Application" |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
"CAP": { |
|
||||
"EventBus": { |
|
||||
"DefaultGroupName": "Platform", |
|
||||
"Version": "v1", |
|
||||
"FailedRetryInterval": 300, |
|
||||
"FailedRetryCount": 10 |
|
||||
}, |
|
||||
"RabbitMQ": { |
|
||||
"HostName": "Your RabbitMQ server connection address", |
|
||||
"Port": 5672, |
|
||||
"UserName": "Your RabbitMQ server connection user", |
|
||||
"Password": "Your RabbitMQ server connection user password", |
|
||||
"ExchangeName": "The name of your RabbitMQ server switch", |
|
||||
"VirtualHost": "Name of your RabbitMQ server VirtualHost" |
|
||||
} |
|
||||
}, |
|
||||
"RemoteServices": { |
|
||||
"AbpIdentity": { |
|
||||
"BaseUrl": "http://localhost:30015/", |
|
||||
"IdentityClient": "internal-service-client" |
|
||||
} |
|
||||
}, |
|
||||
"IdentityClients": { |
|
||||
"internal-service-client": { |
|
||||
"Authority": "http://localhost:44385", |
|
||||
"RequireHttps": false, |
|
||||
"GrantType": "client_credentials", |
|
||||
"Scope": "lingyun-abp-application", |
|
||||
"ClientId": "internal-service-client", |
|
||||
"ClientSecret": "1q2w3e*" |
|
||||
} |
|
||||
}, |
|
||||
"Redis": { |
|
||||
"Configuration": "127.0.0.1,defaultDatabase=10", |
|
||||
"InstanceName": "LINGYUN.AbpApplication" |
|
||||
}, |
|
||||
"AuthServer": { |
|
||||
"Authority": "http://localhost:44385/", |
|
||||
"ApiName": "lingyun-abp-application" |
|
||||
}, |
|
||||
"Serilog": { |
|
||||
"MinimumLevel": { |
|
||||
"Default": "Debug", |
|
||||
"Override": { |
|
||||
"Microsoft.EntityFrameworkCore": "Debug", |
|
||||
"System": "Warning", |
|
||||
"Microsoft": "Warning" |
|
||||
} |
|
||||
}, |
|
||||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId" ], |
|
||||
"WriteTo": [ |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Debug-.log", |
|
||||
"restrictedToMinimumLevel": "Debug", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Info-.log", |
|
||||
"restrictedToMinimumLevel": "Information", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Warn-.log", |
|
||||
"restrictedToMinimumLevel": "Warning", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Error-.log", |
|
||||
"restrictedToMinimumLevel": "Error", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"Name": "File", |
|
||||
"Args": { |
|
||||
"path": "Logs/Fatal-.log", |
|
||||
"restrictedToMinimumLevel": "Fatal", |
|
||||
"rollingInterval": "Day", |
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|
||||
} |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,32 @@ |
|||||
|
# LINGYUN.Abp.AuditLogging.EntityFrameworkCore |
||||
|
|
||||
|
审计模块 EntityFrameworkCore 实现, 此模块仅作为桥梁, 具体实现交给abp官方模块 |
||||
|
|
||||
|
AuditLogManager 实现了 IAuditLogManager, 审计日志由Volo.Abp.AuditLogging模块管理 |
||||
|
SecurityLogManager 实现了 ISecurityLogManager, 安全日志由Volo.Abp.Identity模块管理 |
||||
|
|
||||
|
## 模块引用 |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpAuditLoggingEntityFrameworkCoreModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 配置项 |
||||
|
|
||||
|
请遵循 Volo.Abp.AuditLogging、Volo.Abp.Identity模块中的配置 |
||||
|
|
||||
|
## appsettings.json |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"AbpIdentity": "Server=127.0.0.1;Database=Identity;User Id=root;Password=*", |
||||
|
"AbpAuditLogging": "Server=127.0.0.1;Database=AuditLogging;User Id=root;Password=*", |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
``` |
||||
@ -0,0 +1,32 @@ |
|||||
|
# LINGYUN.Abp.Logging.Serilog.Elasticsearch |
||||
|
|
||||
|
ILoggingManager 接口的ES实现, 从ES中检索日志信息 |
||||
|
|
||||
|
## 模块引用 |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpLoggingSerilogElasticsearchModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 配置项 |
||||
|
|
||||
|
* AbpLoggingSerilogElasticsearchOptions.IndexFormat 必须和Serilog配置项中的IndexFormat相同,否则无法定位到正确的索引 |
||||
|
|
||||
|
## appsettings.json |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"Logging": { |
||||
|
"Serilog": { |
||||
|
"Elasticsearch": { |
||||
|
"IndexFormat": "logstash-{0:yyyy.MM.dd}" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
``` |
||||
@ -0,0 +1,8 @@ |
|||||
|
namespace LINGYUN.Abp.Logging |
||||
|
{ |
||||
|
public class AbpLoggingEnricherPropertyNames |
||||
|
{ |
||||
|
public const string MachineName = "MachineName"; |
||||
|
public const string EnvironmentName = "EnvironmentName"; |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,15 @@ |
|||||
using System; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Volo.Abp.Modularity; |
using Volo.Abp.Modularity; |
||||
|
|
||||
namespace LINGYUN.Abp.Logging |
namespace LINGYUN.Abp.Logging |
||||
{ |
{ |
||||
public class AbpLoggingModule : AbpModule |
public class AbpLoggingModule : AbpModule |
||||
{ |
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
var configuration = context.Services.GetConfiguration(); |
||||
|
|
||||
|
Configure<AbpLoggingEnricherPropertyNames>(configuration.GetSection("Logging")); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,31 @@ |
|||||
|
# LINGYUN.Abp.Logging |
||||
|
|
||||
|
日志基础模块 |
||||
|
|
||||
|
定义 ILoggingManager 接口, 实现日志信息查询 |
||||
|
|
||||
|
## 模块引用 |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpLoggingModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 配置项 |
||||
|
|
||||
|
* AbpLoggingOptions.ApplicationPropertyName 用于自定义ApplicationName字段的名称 |
||||
|
* AbpLoggingOptions.ApplicationName 在日志中标识当前应用的名称 |
||||
|
|
||||
|
## appsettings.json |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"Logging": { |
||||
|
"ApplicationName": "app" |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
``` |
||||
@ -0,0 +1,169 @@ |
|||||
|
using Microsoft.AspNetCore.Cors; |
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using Microsoft.AspNetCore.Identity; |
||||
|
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using System.Text.Encodings.Web; |
||||
|
using System.Text.Unicode; |
||||
|
using Volo.Abp.Account.Localization; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Json.SystemTextJson; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.UI.Navigation.Urls; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace AuthServer.Host |
||||
|
{ |
||||
|
public partial class AuthIdentityServerModule |
||||
|
{ |
||||
|
private void ConfigureDbContext() |
||||
|
{ |
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureJsonSerializer() |
||||
|
{ |
||||
|
// 中文序列化的编码问题
|
||||
|
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
|
{ |
||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureCaching(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
|
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
|
// 滑动过期30天
|
||||
|
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
|
// 绝对过期60天
|
||||
|
options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); |
||||
|
}); |
||||
|
|
||||
|
Configure<RedisCacheOptions>(options => |
||||
|
{ |
||||
|
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
|
options.ConfigurationOptions = redisConfig; |
||||
|
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureIdentity(IConfiguration configuration) |
||||
|
{ |
||||
|
// 增加配置文件定义,在新建租户时需要
|
||||
|
Configure<IdentityOptions>(options => |
||||
|
{ |
||||
|
var identityConfiguration = configuration.GetSection("Identity"); |
||||
|
if (identityConfiguration.Exists()) |
||||
|
{ |
||||
|
identityConfiguration.Bind(options); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureVirtualFileSystem() |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AuthIdentityServerModule>("AuthServer"); |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
|
||||
|
options.Resources |
||||
|
.Get<AccountResource>() |
||||
|
.AddVirtualJson("/Localization/Resources"); |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureAuditing() |
||||
|
{ |
||||
|
Configure<AbpAuditingOptions>(options => |
||||
|
{ |
||||
|
// options.IsEnabledForGetRequests = true;
|
||||
|
options.ApplicationName = "Identity-Server-STS"; |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureUrls(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AppUrlOptions>(options => |
||||
|
{ |
||||
|
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; |
||||
|
// 邮件登录地址
|
||||
|
options.Applications["MVC"].Urls["EmailVerifyLogin"] = "Account/VerifyCode"; |
||||
|
}); |
||||
|
} |
||||
|
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
||||
|
{ |
||||
|
services.AddAuthentication() |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
|
}); |
||||
|
|
||||
|
if (!isDevelopment) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
services |
||||
|
.AddDataProtection() |
||||
|
.PersistKeysToStackExchangeRedis(redis, "AuthServer-Protection-Keys"); |
||||
|
} |
||||
|
} |
||||
|
private void ConfigureMultiTenancy(IConfiguration configuration) |
||||
|
{ |
||||
|
// 多租户
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = true; |
||||
|
}); |
||||
|
|
||||
|
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
||||
|
if (tenantResolveCfg.Exists()) |
||||
|
{ |
||||
|
Configure<AbpTenantResolveOptions>(options => |
||||
|
{ |
||||
|
var domains = tenantResolveCfg.Get<string[]>(); |
||||
|
foreach (var domain in domains) |
||||
|
{ |
||||
|
options.AddDomainTenantResolver(domain); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
private void ConfigureCors(IServiceCollection services, IConfiguration configuration) |
||||
|
{ |
||||
|
services.AddCors(options => |
||||
|
{ |
||||
|
options.AddPolicy(DefaultCorsPolicyName, builder => |
||||
|
{ |
||||
|
builder |
||||
|
.WithOrigins( |
||||
|
configuration["App:CorsOrigins"] |
||||
|
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
||||
|
.Select(o => o.RemovePostFix("/")) |
||||
|
.ToArray() |
||||
|
) |
||||
|
.WithAbpExposedHeaders() |
||||
|
.SetIsOriginAllowedToAllowWildcardSubdomains() |
||||
|
.AllowAnyHeader() |
||||
|
.AllowAnyMethod() |
||||
|
.AllowCredentials(); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace AuthServer.Host |
||||
|
{ |
||||
|
public partial class AuthIdentityServerModule |
||||
|
{ |
||||
|
private void SeedData(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
if (context.GetEnvironment().IsDevelopment()) |
||||
|
{ |
||||
|
AsyncHelper.RunSync(async () => |
||||
|
{ |
||||
|
using var scope = context.ServiceProvider.CreateScope(); |
||||
|
await scope.ServiceProvider.GetRequiredService<IDataSeeder>().SeedAsync(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,118 @@ |
|||||
|
{ |
||||
|
"App": { |
||||
|
"TrackingEntitiesChanged": true, |
||||
|
"SelfUrl": "http://localhost:44385/", |
||||
|
"CorsOrigins": "http://localhost:4200,http://localhost:9527,http://localhost:3100" |
||||
|
}, |
||||
|
"AppSelfUrl": "http://localhost:44385/", |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456", |
||||
|
"AbpIdentity": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456", |
||||
|
"AbpIdentityServer": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456", |
||||
|
"AbpTenantManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpSettingManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpFeatureManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"CAP": { |
||||
|
"EventBus": { |
||||
|
"DefaultGroupName": "AuthServer", |
||||
|
"Version": "v1", |
||||
|
"FailedRetryInterval": 300, |
||||
|
"FailedRetryCount": 10 |
||||
|
}, |
||||
|
"MySql": { |
||||
|
"TableNamePrefix": "auth", |
||||
|
"ConnectionString": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"RabbitMQ": { |
||||
|
"HostName": "localhost", |
||||
|
"Port": 5672, |
||||
|
"UserName": "guest", |
||||
|
"Password": "guest", |
||||
|
"ExchangeName": "LINGYUN.Abp.Application", |
||||
|
"VirtualHost": "/" |
||||
|
} |
||||
|
}, |
||||
|
"Redis": { |
||||
|
"Configuration": "localhost", |
||||
|
"InstanceName": "LINGYUN.Abp.Application", |
||||
|
"DefaultDatabase": 10 |
||||
|
}, |
||||
|
"AuthServer": { |
||||
|
"Authority": "http://localhost:44385/", |
||||
|
"ApiName": "lingyun-abp-application" |
||||
|
}, |
||||
|
"IdentityServer": { |
||||
|
"Clients": { |
||||
|
"AuthManagement": { |
||||
|
"ClientId": "auth-management", |
||||
|
"RootUrl": "http://localhost:44313/" |
||||
|
}, |
||||
|
"AuthVueAdmin": { |
||||
|
"ClientId": "vue-admin-element" |
||||
|
}, |
||||
|
"AuthApiGateway": { |
||||
|
"ClientId": "ApigatewayHostClient" |
||||
|
}, |
||||
|
"InternalService": { |
||||
|
"ClientId": "internal-service-client" |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"Identity": { |
||||
|
"Password": { |
||||
|
"RequiredLength": 6, |
||||
|
"RequiredUniqueChars": 0, |
||||
|
"RequireNonAlphanumeric": false, |
||||
|
"RequireLowercase": false, |
||||
|
"RequireUppercase": false, |
||||
|
"RequireDigit": false |
||||
|
}, |
||||
|
"Lockout": { |
||||
|
"AllowedForNewUsers": false, |
||||
|
"LockoutDuration": 5, |
||||
|
"MaxFailedAccessAttempts": 5 |
||||
|
}, |
||||
|
"SignIn": { |
||||
|
"RequireConfirmedEmail": false, |
||||
|
"RequireConfirmedPhoneNumber": false |
||||
|
} |
||||
|
}, |
||||
|
"AuditLogging": { |
||||
|
"Elasticsearch": { |
||||
|
"IndexPrefix": "lingyun.abp.auditing" |
||||
|
} |
||||
|
}, |
||||
|
"Elasticsearch": { |
||||
|
"NodeUris": "http://localhost:9200" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Debug", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
|
} |
||||
|
}, |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "Elasticsearch", |
||||
|
"Args": { |
||||
|
"nodeUris": "http://localhost:9200", |
||||
|
"indexFormat": "lingyun.abp.logging-{0:yyyy.MM.dd}", |
||||
|
"autoRegisterTemplate": true, |
||||
|
"autoRegisterTemplateVersion": "ESv7" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -1,58 +1,27 @@ |
|||||
{ |
{ |
||||
"ApiGateway": { |
"StringEncryption": { |
||||
"AppId": "TEST-APP"//这里是用于Ocelot主机去API服务器获取参数的标识,指定需要获取什么类型的网关配置 |
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
}, |
"InitVectorBytes": "s83ng0abvd02js84", |
||||
"Redis": { |
"DefaultSalt": "sf&5)s3#" |
||||
"Configuration": "127.0.0.1,defaultDatabase=10", |
|
||||
"InstanceName": "LINGYUN.AbpApplication" |
|
||||
}, |
|
||||
"RemoteServices": { |
|
||||
"ApiGateway": { |
|
||||
"BaseUrl": "http://localhost:30001/", |
|
||||
"IdentityClient": "ApigatewayHostClient" |
|
||||
} |
|
||||
}, |
|
||||
"IdentityClients": { |
|
||||
"ApigatewayHostClient": { |
|
||||
"Authority": "http://localhost:44385", |
|
||||
"RequireHttps": false, |
|
||||
"GrantType": "client_credentials", |
|
||||
"ClientId": "ApigatewayHostClient", |
|
||||
"ClientSecret": "1q2w3e*", |
|
||||
"Scope": "lingyun-abp-application" |
|
||||
} |
|
||||
}, |
|
||||
"EnabledDynamicOcelot": true, |
|
||||
"CAP": { |
|
||||
"EventBus": { |
|
||||
"DefaultGroupName": "ApiGateway-Host", |
|
||||
"Version": "v1", |
|
||||
"FailedRetryInterval": 300, |
|
||||
"FailedRetryCount": 10 |
|
||||
}, |
|
||||
"RabbitMQ": { |
|
||||
"HostName": "127.0.0.1", |
|
||||
"Port": 5672, |
|
||||
"UserName": "admin", |
|
||||
"Password": "admin", |
|
||||
"ExchangeName": "LINGYUN.ApiGateway", |
|
||||
"VirtualHost": "multi.service.test" |
|
||||
} |
|
||||
}, |
|
||||
"AuthServer": { |
|
||||
"Authority": "http://localhost:44385/", |
|
||||
"ApiName": "lingyun-abp-application" |
|
||||
}, |
}, |
||||
"Serilog": { |
"Serilog": { |
||||
"MinimumLevel": { |
"MinimumLevel": { |
||||
"Default": "Debug", |
"Default": "Debug", |
||||
"Override": { |
"Override": { |
||||
"System": "Warning", |
"System": "Warning", |
||||
"Microsoft": "Warning" |
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
} |
} |
||||
}, |
}, |
||||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId" ], |
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName" ], |
||||
"WriteTo": [ |
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
{ |
{ |
||||
"Name": "File", |
"Name": "File", |
||||
"Args": { |
"Args": { |
||||
@ -0,0 +1,259 @@ |
|||||
|
using DotNetCore.CAP; |
||||
|
using LINGYUN.Abp.ExceptionHandling; |
||||
|
using LINGYUN.Abp.ExceptionHandling.Emailing; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.Text.Encodings.Web; |
||||
|
using System.Text.Unicode; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.Domain.Entities.Events.Distributed; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Identity.Localization; |
||||
|
using Volo.Abp.Json.SystemTextJson; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace LINGYUN.Abp.BackendAdmin |
||||
|
{ |
||||
|
public partial class BackendAdminHostModule |
||||
|
{ |
||||
|
private void PreConfigureCAP(IConfiguration configuration) |
||||
|
{ |
||||
|
PreConfigure<CapOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.UseMySql(configuration.GetConnectionString("Default")) |
||||
|
.UseRabbitMQ(rabbitMQOptions => |
||||
|
{ |
||||
|
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
||||
|
}) |
||||
|
.UseDashboard(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureDbContext() |
||||
|
{ |
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureJsonSerializer() |
||||
|
{ |
||||
|
// 中文序列化的编码问题
|
||||
|
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
|
{ |
||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigurePermissionManagement() |
||||
|
{ |
||||
|
Configure<PermissionManagementOptions>(options => |
||||
|
{ |
||||
|
// Rename IdentityServer.Client.ManagePermissions
|
||||
|
// See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs
|
||||
|
options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = |
||||
|
LINGYUN.Abp.IdentityServer.AbpIdentityServerPermissions.Clients.ManagePermissions; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureExceptionHandling() |
||||
|
{ |
||||
|
// 自定义需要处理的异常
|
||||
|
Configure<AbpExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 加入需要处理的异常类型
|
||||
|
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
||||
|
options.Handlers.Add<AbpInitializationException>(); |
||||
|
options.Handlers.Add<ObjectDisposedException>(); |
||||
|
options.Handlers.Add<StackOverflowException>(); |
||||
|
options.Handlers.Add<OutOfMemoryException>(); |
||||
|
options.Handlers.Add<System.Data.Common.DbException>(); |
||||
|
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
||||
|
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
||||
|
}); |
||||
|
|
||||
|
// 自定义需要发送邮件通知的异常类型
|
||||
|
Configure<AbpEmailExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 是否发送堆栈信息
|
||||
|
options.SendStackTrace = true; |
||||
|
// 未指定异常接收者的默认接收邮件
|
||||
|
// 请指定自己的邮件地址
|
||||
|
// options.DefaultReceiveEmail = "colin.in@foxmail.com";
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureCaching(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
|
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
|
// 滑动过期30天
|
||||
|
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
|
// 绝对过期60天
|
||||
|
options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpDistributedEntityEventOptions>(options => |
||||
|
{ |
||||
|
options.AutoEventSelectors.AddNamespace("Volo.Abp.TenantManagement"); |
||||
|
}); |
||||
|
|
||||
|
Configure<RedisCacheOptions>(options => |
||||
|
{ |
||||
|
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
|
options.ConfigurationOptions = redisConfig; |
||||
|
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureVirtualFileSystem() |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<BackendAdminHostModule>("LINGYUN.Abp.BackendAdmin"); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureMultiTenancy(IConfiguration configuration) |
||||
|
{ |
||||
|
// 多租户
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = true; |
||||
|
}); |
||||
|
|
||||
|
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
||||
|
if (tenantResolveCfg.Exists()) |
||||
|
{ |
||||
|
Configure<AbpTenantResolveOptions>(options => |
||||
|
{ |
||||
|
var domains = tenantResolveCfg.Get<string[]>(); |
||||
|
foreach (var domain in domains) |
||||
|
{ |
||||
|
options.AddDomainTenantResolver(domain); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAuditing(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpAuditingOptions>(options => |
||||
|
{ |
||||
|
options.ApplicationName = "Backend-Admin"; |
||||
|
// 是否启用实体变更记录
|
||||
|
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
||||
|
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
||||
|
{ |
||||
|
options |
||||
|
.EntityHistorySelectors |
||||
|
.AddAllEntities(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSwagger(IServiceCollection services) |
||||
|
{ |
||||
|
// Swagger
|
||||
|
services.AddSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "BackendAdmin API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
options.CustomSchemaIds(type => type.FullName); |
||||
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
||||
|
Name = "Authorization", |
||||
|
In = ParameterLocation.Header, |
||||
|
Scheme = "bearer", |
||||
|
Type = SecuritySchemeType.Http, |
||||
|
BearerFormat = "JWT" |
||||
|
}); |
||||
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
||||
|
{ |
||||
|
{ |
||||
|
new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
||||
|
}, |
||||
|
new string[] { } |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
// 支持本地化语言类型
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
|
||||
|
options.Resources |
||||
|
.Get<IdentityResource>() |
||||
|
.AddVirtualJson("/Localization"); |
||||
|
options |
||||
|
.AddLanguagesMapOrUpdate( |
||||
|
"vue-admin-element-ui", |
||||
|
new NameValue("zh-Hans", "zh"), |
||||
|
new NameValue("en", "en")); |
||||
|
|
||||
|
// vben admin 语言映射
|
||||
|
options |
||||
|
.AddLanguagesMapOrUpdate( |
||||
|
"vben-admin-ui", |
||||
|
new NameValue("zh_CN", "zh-Hans")); |
||||
|
|
||||
|
options |
||||
|
.AddLanguageFilesMapOrUpdate( |
||||
|
"vue-admin-element-ui", |
||||
|
new NameValue("zh-Hans", "zh"), |
||||
|
new NameValue("en", "en")); |
||||
|
options |
||||
|
.AddLanguageFilesMapOrUpdate( |
||||
|
"vben-admin-ui", |
||||
|
new NameValue("zh_CN", "zh-Hans")); |
||||
|
|
||||
|
options.Resources.AddDynamic(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
||||
|
{ |
||||
|
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
|
}); |
||||
|
|
||||
|
if (!isDevelopment) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
services |
||||
|
.AddDataProtection() |
||||
|
.PersistKeysToStackExchangeRedis(redis, "BackendAdmin-Protection-Keys"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Volo.Abp; |
||||
|
|
||||
|
namespace LINGYUN.Abp.BackendAdmin |
||||
|
{ |
||||
|
public partial class BackendAdminHostModule |
||||
|
{ |
||||
|
private void UseDevelopment(IApplicationBuilder app, ApplicationInitializationContext context) |
||||
|
{ |
||||
|
if (context.GetEnvironment().IsDevelopment()) |
||||
|
{ |
||||
|
app.UseProxyConnectTest(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace LINGYUN.Abp.BackendAdmin |
||||
|
{ |
||||
|
public partial class BackendAdminHostModule |
||||
|
{ |
||||
|
private static void SeedData(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
if (context.GetEnvironment().IsDevelopment()) |
||||
|
{ |
||||
|
AsyncHelper.RunSync(async () => |
||||
|
{ |
||||
|
using var scope = context.ServiceProvider.CreateScope(); |
||||
|
await scope.ServiceProvider.GetRequiredService<IDataSeeder>().SeedAsync(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,92 @@ |
|||||
|
{ |
||||
|
"App": { |
||||
|
"TrackingEntitiesChanged": true, |
||||
|
"Forwarded": { |
||||
|
"ForwardedHeaders": 5, |
||||
|
"KnownProxies": [ |
||||
|
"localhost" |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=localhost;Database=Platform;User Id=colin;Password=123456", |
||||
|
"AbpIdentity": "Server=localhost;Database=IdentityServer;User Id=colin;Password=123456", |
||||
|
"AbpIdentityServer": "Server=localhost;Database=IdentityServer;User Id=colin;Password=123456", |
||||
|
"AbpTenantManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456", |
||||
|
"AbpSettingManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456", |
||||
|
"AbpFeatureManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456", |
||||
|
"AbpLocalizationManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456" |
||||
|
}, |
||||
|
"CAP": { |
||||
|
"EventBus": { |
||||
|
"DefaultGroup": "BackendAdmin", |
||||
|
"Version": "v1", |
||||
|
"FailedRetryInterval": 300, |
||||
|
"FailedRetryCount": 10 |
||||
|
}, |
||||
|
"MySql": { |
||||
|
"TableNamePrefix": "admin", |
||||
|
"ConnectionString": "Server=localhost;Database=Platform;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"RabbitMQ": { |
||||
|
"HostName": "localhost", |
||||
|
"Port": 5672, |
||||
|
"UserName": "guest", |
||||
|
"Password": "guest", |
||||
|
"ExchangeName": "LINGYUN.Abp.Application", |
||||
|
"VirtualHost": "/" |
||||
|
} |
||||
|
}, |
||||
|
"Redis": { |
||||
|
"Configuration": "localhost,defaultDatabase=10", |
||||
|
"InstanceName": "LINGYUN.Abp.Application" |
||||
|
}, |
||||
|
"AuthServer": { |
||||
|
"Authority": "http://localhost:44385/", |
||||
|
"ApiName": "lingyun-abp-application" |
||||
|
}, |
||||
|
"Logging": { |
||||
|
"Serilog": { |
||||
|
"Elasticsearch": { |
||||
|
"IndexFormat": "lingyun.abp.logging-{0:yyyy.MM.dd}" |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"AuditLogging": { |
||||
|
"Elasticsearch": { |
||||
|
"IndexPrefix": "lingyun.abp.auditing" |
||||
|
} |
||||
|
}, |
||||
|
"Elasticsearch": { |
||||
|
"NodeUris": "http://localhost:9200" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Debug", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
|
} |
||||
|
}, |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "Elasticsearch", |
||||
|
"Args": { |
||||
|
"nodeUris": "http://localhost:9200", |
||||
|
"indexFormat": "lingyun.abp.logging-{0:yyyy.MM.dd}", |
||||
|
"autoRegisterTemplate": true, |
||||
|
"autoRegisterTemplateVersion": "ESv7" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
{ |
||||
|
"StringEncryption": { |
||||
|
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
|
"InitVectorBytes": "s83ng0abvd02js84", |
||||
|
"DefaultSalt": "sf&5)s3#" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Information", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName" ], |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Debug-.log", |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Info-.log", |
||||
|
"restrictedToMinimumLevel": "Information", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Warn-.log", |
||||
|
"restrictedToMinimumLevel": "Warning", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Error-.log", |
||||
|
"restrictedToMinimumLevel": "Error", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Fatal-.log", |
||||
|
"restrictedToMinimumLevel": "Fatal", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,79 @@ |
|||||
|
{ |
||||
|
"EnabledDynamicOcelot": true, |
||||
|
"ApiGateway": { |
||||
|
"AppId": "TEST-APP" //这里是用于Ocelot主机去API服务器获取参数的标识,指定需要获取什么类型的网关配置 |
||||
|
}, |
||||
|
"Redis": { |
||||
|
"Configuration": "localhost,defaultDatabase=10", |
||||
|
"InstanceName": "LINGYUN.Abp.Application" |
||||
|
}, |
||||
|
"RemoteServices": { |
||||
|
"ApiGateway": { |
||||
|
"BaseUrl": "http://localhost:30001/", |
||||
|
"IdentityClient": "ApigatewayHostClient" |
||||
|
} |
||||
|
}, |
||||
|
"IdentityClients": { |
||||
|
"ApigatewayHostClient": { |
||||
|
"Authority": "http://localhost:44385", |
||||
|
"RequireHttps": false, |
||||
|
"GrantType": "client_credentials", |
||||
|
"ClientId": "ApigatewayHostClient", |
||||
|
"ClientSecret": "1q2w3e*", |
||||
|
"Scope": "lingyun-abp-application" |
||||
|
} |
||||
|
}, |
||||
|
"CAP": { |
||||
|
"Abp": { |
||||
|
"NotifyFailedCallback": true, |
||||
|
"CleanUpExpiresMessageBatch": 1000, |
||||
|
"CleanUpExpiresMessageInterval": 3600000 |
||||
|
}, |
||||
|
"EventBus": { |
||||
|
"DefaultGroupName": "ApiGateway-Host", |
||||
|
"Version": "v1", |
||||
|
"FailedRetryInterval": 300, |
||||
|
"FailedRetryCount": 10 |
||||
|
}, |
||||
|
"RabbitMQ": { |
||||
|
"HostName": "localhost", |
||||
|
"Port": 5672, |
||||
|
"UserName": "guest", |
||||
|
"Password": "guest", |
||||
|
"ExchangeName": "LINGYUN.ApiGateway", |
||||
|
"VirtualHost": "/" |
||||
|
} |
||||
|
}, |
||||
|
"AuthServer": { |
||||
|
"Authority": "http://localhost:44385/", |
||||
|
"ApiName": "lingyun-abp-application" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Debug", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
|
} |
||||
|
}, |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "Elasticsearch", |
||||
|
"Args": { |
||||
|
"nodeUris": "http://localhost:9200", |
||||
|
"indexFormat": "lingyun.abp.logging-{0:yyyy.MM.dd}", |
||||
|
"autoRegisterTemplate": true, |
||||
|
"autoRegisterTemplateVersion": "ESv7" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,179 @@ |
|||||
|
using DotNetCore.CAP; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.Text.Encodings.Web; |
||||
|
using System.Text.Unicode; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Json.SystemTextJson; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace LINGYUN.ApiGateway |
||||
|
{ |
||||
|
public partial class ApiGatewayHttpApiHostModule |
||||
|
{ |
||||
|
private void PreConfigureCAP(IConfiguration configuration) |
||||
|
{ |
||||
|
PreConfigure<CapOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.UseMySql(configuration.GetConnectionString("Default")) |
||||
|
.UseRabbitMQ(rabbitMQOptions => |
||||
|
{ |
||||
|
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private void ConfigureAutoMapper() |
||||
|
{ |
||||
|
Configure<AbpAutoMapperOptions>(options => |
||||
|
{ |
||||
|
options.AddProfile<ApiGatewayHttpApiHostAutoMapperProfile>(validate: true); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureDbContext() |
||||
|
{ |
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureJsonSerializer() |
||||
|
{ |
||||
|
// 中文序列化的编码问题
|
||||
|
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
|
{ |
||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureCaching(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
|
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
|
// 滑动过期30天
|
||||
|
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
|
// 绝对过期60天
|
||||
|
options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(60); |
||||
|
}); |
||||
|
|
||||
|
Configure<RedisCacheOptions>(options => |
||||
|
{ |
||||
|
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
|
options.ConfigurationOptions = redisConfig; |
||||
|
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureVirtualFileSystem() |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<ApiGatewayHttpApiHostModule>(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureMultiTenancy(IConfiguration configuration) |
||||
|
{ |
||||
|
// 多租户
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = false; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAuditing(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpAuditingOptions>(options => |
||||
|
{ |
||||
|
options.ApplicationName = "ApiGateWay-Admin"; |
||||
|
// 是否启用实体变更记录
|
||||
|
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
||||
|
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
||||
|
{ |
||||
|
options |
||||
|
.EntityHistorySelectors |
||||
|
.AddAllEntities(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSwagger(IServiceCollection services) |
||||
|
{ |
||||
|
// Swagger
|
||||
|
services.AddSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "ApiGateway API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
options.CustomSchemaIds(type => type.FullName); |
||||
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
||||
|
Name = "Authorization", |
||||
|
In = ParameterLocation.Header, |
||||
|
Scheme = "bearer", |
||||
|
Type = SecuritySchemeType.Http, |
||||
|
BearerFormat = "JWT" |
||||
|
}); |
||||
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
||||
|
{ |
||||
|
{ |
||||
|
new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
||||
|
}, |
||||
|
new string[] { } |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
// 支持本地化语言类型
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
||||
|
{ |
||||
|
services |
||||
|
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
|
}); |
||||
|
|
||||
|
if (!isDevelopment) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
services |
||||
|
.AddDataProtection() |
||||
|
.PersistKeysToStackExchangeRedis(redis, "ApiGatewayAdmin-Protection-Keys"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace LINGYUN.ApiGateway |
||||
|
{ |
||||
|
public partial class ApiGatewayHttpApiHostModule |
||||
|
{ |
||||
|
private void SeedData(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
var configuration = context.GetConfiguration(); |
||||
|
if (configuration.GetSection("ApiGateway:SeedInitScript").Get<bool>()) |
||||
|
{ |
||||
|
AsyncHelper.RunSync(async () => |
||||
|
{ |
||||
|
using var scope = context.ServiceProvider.CreateScope(); |
||||
|
await scope.ServiceProvider.GetRequiredService<IDataSeeder>().SeedAsync(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
{ |
||||
|
"App": { |
||||
|
"TrackingEntitiesChanged": true, |
||||
|
"SelfUrl": "http://localhost:30001/" |
||||
|
}, |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=localhost;Database=ApiGateway;User Id=root;Password=123456", |
||||
|
"ApiGateway": "Server=localhost;Database=ApiGateway;User Id=root;Password=123456", |
||||
|
"AbpTenantManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpSettingManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"Redis": { |
||||
|
"Configuration": "localhost,defaultDatabase=10", |
||||
|
"InstanceName": "LINGYUN.Abp.Application" |
||||
|
}, |
||||
|
"CAP": { |
||||
|
"EventBus": { |
||||
|
"DefaultGroupName": "ApiGateway-Admin", |
||||
|
"Version": "v1", |
||||
|
"FailedRetryInterval": 300, |
||||
|
"FailedRetryCount": 10 |
||||
|
}, |
||||
|
"MySql": { |
||||
|
"TableNamePrefix": "apa", |
||||
|
"ConnectionString": "Server=localhost;Database=ApiGateway;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"RabbitMQ": { |
||||
|
"HostName": "localhost", |
||||
|
"Port": 5672, |
||||
|
"UserName": "guest", |
||||
|
"Password": "guest", |
||||
|
"ExchangeName": "LINGYUN.ApiGateway", |
||||
|
"VirtualHost": "/" |
||||
|
} |
||||
|
}, |
||||
|
"AuthServer": { |
||||
|
"Authority": "http://localhost:44385/", |
||||
|
"ApiName": "lingyun-abp-application" |
||||
|
}, |
||||
|
"Elasticsearch": { |
||||
|
"NodeUris": "http://localhost:9200" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Debug", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
|
} |
||||
|
}, |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "Elasticsearch", |
||||
|
"Args": { |
||||
|
"nodeUris": "http://localhost:9200", |
||||
|
"indexFormat": "lingyun.abp.logging-{0:yyyy.MM.dd}", |
||||
|
"autoRegisterTemplate": true, |
||||
|
"autoRegisterTemplateVersion": "ESv7" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -1,46 +1,27 @@ |
|||||
{ |
{ |
||||
"ConnectionStrings": { |
"StringEncryption": { |
||||
"Default": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
"InitVectorBytes": "s83ng0abvd02js84", |
||||
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
"DefaultSalt": "sf&5)s3#" |
||||
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" |
|
||||
}, |
|
||||
"CAP": { |
|
||||
"EventBus": { |
|
||||
"DefaultGroupName": "Platform", |
|
||||
"Version": "v1", |
|
||||
"FailedRetryInterval": 300, |
|
||||
"FailedRetryCount": 10 |
|
||||
}, |
|
||||
"RabbitMQ": { |
|
||||
"HostName": "Your RabbitMQ server connection address", |
|
||||
"Port": 5672, |
|
||||
"UserName": "Your RabbitMQ server connection user", |
|
||||
"Password": "Your RabbitMQ server connection user password", |
|
||||
"ExchangeName": "The name of your RabbitMQ server switch", |
|
||||
"VirtualHost": "Name of your RabbitMQ server VirtualHost" |
|
||||
} |
|
||||
}, |
|
||||
"Redis": { |
|
||||
"Configuration": "127.0.0.1,defaultDatabase=11", |
|
||||
"InstanceName": "LINGYUN.Abp.Application" |
|
||||
}, |
|
||||
"AuthServer": { |
|
||||
"Authority": "http://localhost:44385/", |
|
||||
"ApiName": "lingyun-abp-application" |
|
||||
}, |
}, |
||||
"Serilog": { |
"Serilog": { |
||||
"MinimumLevel": { |
"MinimumLevel": { |
||||
"Default": "Debug", |
"Default": "Debug", |
||||
"Override": { |
"Override": { |
||||
"Microsoft.EntityFrameworkCore": "Debug", |
|
||||
"System": "Warning", |
"System": "Warning", |
||||
"Microsoft": "Warning" |
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
} |
} |
||||
}, |
}, |
||||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId" ], |
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName" ], |
||||
"WriteTo": [ |
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
{ |
{ |
||||
"Name": "File", |
"Name": "File", |
||||
"Args": { |
"Args": { |
||||
@ -0,0 +1,247 @@ |
|||||
|
using DotNetCore.CAP; |
||||
|
using LINGYUN.Abp.ExceptionHandling; |
||||
|
using LINGYUN.Abp.ExceptionHandling.Emailing; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using Microsoft.AspNetCore.Identity; |
||||
|
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text.Encodings.Web; |
||||
|
using System.Text.Unicode; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.Domain.Entities.Events.Distributed; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Identity.Localization; |
||||
|
using Volo.Abp.Json.SystemTextJson; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer4 |
||||
|
{ |
||||
|
public partial class AbpIdentityServerAdminHttpApiHostModule |
||||
|
{ |
||||
|
private void PreConfigureCAP(IConfiguration configuration) |
||||
|
{ |
||||
|
PreConfigure<CapOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.UseMySql(configuration.GetConnectionString("Default")) |
||||
|
.UseRabbitMQ(rabbitMQOptions => |
||||
|
{ |
||||
|
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
||||
|
}) |
||||
|
.UseDashboard(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void PreConfigureIdentity() |
||||
|
{ |
||||
|
PreConfigure<IdentityBuilder>(builder => |
||||
|
{ |
||||
|
builder.AddDefaultTokenProviders(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureDbContext() |
||||
|
{ |
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureJsonSerializer() |
||||
|
{ |
||||
|
// 中文序列化的编码问题
|
||||
|
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
|
{ |
||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigurePermissionManagement() |
||||
|
{ |
||||
|
Configure<PermissionManagementOptions>(options => |
||||
|
{ |
||||
|
// Rename IdentityServer.Client.ManagePermissions
|
||||
|
// See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs
|
||||
|
options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = |
||||
|
LINGYUN.Abp.IdentityServer.AbpIdentityServerPermissions.Clients.ManagePermissions; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigreExceptionHandling() |
||||
|
{ |
||||
|
// 自定义需要处理的异常
|
||||
|
Configure<AbpExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 加入需要处理的异常类型
|
||||
|
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
||||
|
options.Handlers.Add<AbpInitializationException>(); |
||||
|
options.Handlers.Add<ObjectDisposedException>(); |
||||
|
options.Handlers.Add<StackOverflowException>(); |
||||
|
options.Handlers.Add<OutOfMemoryException>(); |
||||
|
options.Handlers.Add<System.Data.Common.DbException>(); |
||||
|
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
||||
|
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
||||
|
}); |
||||
|
// 自定义需要发送邮件通知的异常类型
|
||||
|
Configure<AbpEmailExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 是否发送堆栈信息
|
||||
|
options.SendStackTrace = true; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAuditing(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpAuditingOptions>(options => |
||||
|
{ |
||||
|
options.ApplicationName = "Identity-Server-Admin"; |
||||
|
// 是否启用实体变更记录
|
||||
|
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
||||
|
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
||||
|
{ |
||||
|
options |
||||
|
.EntityHistorySelectors |
||||
|
.AddAllEntities(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureCaching(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
|
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
|
// 滑动过期30天
|
||||
|
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
|
// 绝对过期60天
|
||||
|
options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpDistributedEntityEventOptions>(options => |
||||
|
{ |
||||
|
options.AutoEventSelectors.AddNamespace("Volo.Abp.Identity"); |
||||
|
options.AutoEventSelectors.AddNamespace("Volo.Abp.IdentityServer"); |
||||
|
}); |
||||
|
|
||||
|
Configure<RedisCacheOptions>(options => |
||||
|
{ |
||||
|
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
|
options.ConfigurationOptions = redisConfig; |
||||
|
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureVirtualFileSystem() |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AbpIdentityServerAdminHttpApiHostModule>("LINGYUN.Abp.IdentityServer4"); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureMultiTenancy(IConfiguration configuration) |
||||
|
{ |
||||
|
// 多租户
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = true; |
||||
|
}); |
||||
|
|
||||
|
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
||||
|
if (tenantResolveCfg.Exists()) |
||||
|
{ |
||||
|
Configure<AbpTenantResolveOptions>(options => |
||||
|
{ |
||||
|
var domains = tenantResolveCfg.Get<string[]>(); |
||||
|
foreach (var domain in domains) |
||||
|
{ |
||||
|
options.AddDomainTenantResolver(domain); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSwagger(IServiceCollection services) |
||||
|
{ |
||||
|
// Swagger
|
||||
|
services.AddSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "IdentityServer4 API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
options.CustomSchemaIds(type => type.FullName); |
||||
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
||||
|
Name = "Authorization", |
||||
|
In = ParameterLocation.Header, |
||||
|
Scheme = "bearer", |
||||
|
Type = SecuritySchemeType.Http, |
||||
|
BearerFormat = "JWT" |
||||
|
}); |
||||
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
||||
|
{ |
||||
|
{ |
||||
|
new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
||||
|
}, |
||||
|
new string[] { } |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
// 支持本地化语言类型
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
|
||||
|
options.Resources |
||||
|
.Get<IdentityResource>() |
||||
|
.AddVirtualJson("/LINGYUN/Abp/IdentityServer4/Localization"); |
||||
|
|
||||
|
options.Resources.AddDynamic(typeof(IdentityResource)); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
||||
|
{ |
||||
|
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
|
}); |
||||
|
|
||||
|
if (!isDevelopment) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
services |
||||
|
.AddDataProtection() |
||||
|
.PersistKeysToStackExchangeRedis(redis, "IDS-Admin-Protection-Keys"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer4 |
||||
|
{ |
||||
|
public partial class AbpIdentityServerAdminHttpApiHostModule |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,74 @@ |
|||||
|
{ |
||||
|
"App": { |
||||
|
"TrackingEntitiesChanged": true |
||||
|
}, |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456", |
||||
|
"AbpIdentity": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456", |
||||
|
"AbpIdentityServer": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456", |
||||
|
"AbpTenantManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpSettingManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpFeatureManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456", |
||||
|
"AbpLocalizationManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"CAP": { |
||||
|
"EventBus": { |
||||
|
"DefaultGroupName": "IdentityServer4Admin", |
||||
|
"Version": "v1", |
||||
|
"FailedRetryInterval": 300, |
||||
|
"FailedRetryCount": 10 |
||||
|
}, |
||||
|
"MySql": { |
||||
|
"TableNamePrefix": "ida", |
||||
|
"ConnectionString": "Server=localhost;Database=IdentityServer;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"RabbitMQ": { |
||||
|
"HostName": "localhost", |
||||
|
"Port": 5672, |
||||
|
"UserName": "guest", |
||||
|
"Password": "guest", |
||||
|
"ExchangeName": "LINGYUN.Abp.Application", |
||||
|
"VirtualHost": "/" |
||||
|
} |
||||
|
}, |
||||
|
"Redis": { |
||||
|
"Configuration": "localhost,defaultDatabase=10", |
||||
|
"InstanceName": "LINGYUN.Abp.Application" |
||||
|
}, |
||||
|
"AuthServer": { |
||||
|
"Authority": "http://localhost:44385/", |
||||
|
"ApiName": "lingyun-abp-application" |
||||
|
}, |
||||
|
"Elasticsearch": { |
||||
|
"NodeUris": "http://localhost:9200" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Debug", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
|
} |
||||
|
}, |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "Elasticsearch", |
||||
|
"Args": { |
||||
|
"nodeUris": "http://localhost:9200", |
||||
|
"indexFormat": "lingyun.abp.logging-{0:yyyy.MM.dd}", |
||||
|
"autoRegisterTemplate": true, |
||||
|
"autoRegisterTemplateVersion": "ESv7" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -1,52 +1,27 @@ |
|||||
{ |
{ |
||||
"App": { |
"StringEncryption": { |
||||
"TrackingEntitiesChanged": true |
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
}, |
"InitVectorBytes": "s83ng0abvd02js84", |
||||
"ConnectionStrings": { |
"DefaultSalt": "sf&5)s3#" |
||||
"Default": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpIdentity": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", |
|
||||
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", |
|
||||
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" |
|
||||
}, |
|
||||
"CAP": { |
|
||||
"EventBus": { |
|
||||
"DefaultGroupName": "IdentityServer4Admin", |
|
||||
"Version": "v1", |
|
||||
"FailedRetryInterval": 300, |
|
||||
"FailedRetryCount": 10 |
|
||||
}, |
|
||||
"RabbitMQ": { |
|
||||
"HostName": "127.0.0.1", |
|
||||
"Port": 5672, |
|
||||
"UserName": "admin", |
|
||||
"Password": "123456", |
|
||||
"ExchangeName": "LINGYUN.AbpApplication", |
|
||||
"VirtualHost": "multi.service.test" |
|
||||
} |
|
||||
}, |
|
||||
"Redis": { |
|
||||
"Configuration": "127.0.0.1,defaultDatabase=10", |
|
||||
"InstanceName": "LINGYUN.AbpApplication" |
|
||||
}, |
|
||||
"AuthServer": { |
|
||||
"Authority": "http://localhost:44385/", |
|
||||
"ApiName": "lingyun-abp-application" |
|
||||
}, |
}, |
||||
"Serilog": { |
"Serilog": { |
||||
"MinimumLevel": { |
"MinimumLevel": { |
||||
"Default": "Debug", |
"Default": "Debug", |
||||
"Override": { |
"Override": { |
||||
"Microsoft.EntityFrameworkCore": "Debug", |
|
||||
"System": "Warning", |
"System": "Warning", |
||||
"Microsoft": "Warning" |
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
} |
} |
||||
}, |
}, |
||||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId" ], |
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName" ], |
||||
"WriteTo": [ |
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
{ |
{ |
||||
"Name": "File", |
"Name": "File", |
||||
"Args": { |
"Args": { |
||||
@ -0,0 +1,198 @@ |
|||||
|
using DotNetCore.CAP; |
||||
|
using LINGYUN.Abp.ExceptionHandling; |
||||
|
using LINGYUN.Abp.ExceptionHandling.Emailing; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.Text.Encodings.Web; |
||||
|
using System.Text.Unicode; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Json.SystemTextJson; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
|
||||
|
namespace LINGYUN.Abp.LocalizationManagement |
||||
|
{ |
||||
|
public partial class AbpLocalizationManagementHttpApiHostModule |
||||
|
{ |
||||
|
private void PreConfigureCAP(IConfiguration configuration) |
||||
|
{ |
||||
|
PreConfigure<CapOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.UseMySql(configuration.GetConnectionString("Default")) |
||||
|
.UseRabbitMQ(rabbitMQOptions => |
||||
|
{ |
||||
|
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
||||
|
}) |
||||
|
.UseDashboard(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureDbContext() |
||||
|
{ |
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureJsonSerializer() |
||||
|
{ |
||||
|
// 中文序列化的编码问题
|
||||
|
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
|
{ |
||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigreExceptionHandling() |
||||
|
{ |
||||
|
// 自定义需要处理的异常
|
||||
|
Configure<AbpExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 加入需要处理的异常类型
|
||||
|
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
||||
|
options.Handlers.Add<AbpInitializationException>(); |
||||
|
options.Handlers.Add<ObjectDisposedException>(); |
||||
|
options.Handlers.Add<StackOverflowException>(); |
||||
|
options.Handlers.Add<OutOfMemoryException>(); |
||||
|
options.Handlers.Add<System.Data.Common.DbException>(); |
||||
|
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
||||
|
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
||||
|
}); |
||||
|
// 自定义需要发送邮件通知的异常类型
|
||||
|
Configure<AbpEmailExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 是否发送堆栈信息
|
||||
|
options.SendStackTrace = true; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAuditing(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpAuditingOptions>(options => |
||||
|
{ |
||||
|
options.ApplicationName = "Localization"; |
||||
|
// 是否启用实体变更记录
|
||||
|
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
||||
|
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
||||
|
{ |
||||
|
options |
||||
|
.EntityHistorySelectors |
||||
|
.AddAllEntities(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureCaching(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
|
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
|
// 滑动过期30天
|
||||
|
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
|
// 绝对过期60天
|
||||
|
options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); |
||||
|
}); |
||||
|
|
||||
|
Configure<RedisCacheOptions>(options => |
||||
|
{ |
||||
|
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
|
options.ConfigurationOptions = redisConfig; |
||||
|
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureVirtualFileSystem() |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AbpLocalizationManagementHttpApiHostModule>("LINGYUN.Abp.LocalizationManagement"); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureMultiTenancy(IConfiguration configuration) |
||||
|
{ |
||||
|
// 多租户
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = false; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSwagger(IServiceCollection services) |
||||
|
{ |
||||
|
// Swagger
|
||||
|
services.AddSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Localization Management API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
options.CustomSchemaIds(type => type.FullName); |
||||
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
||||
|
Name = "Authorization", |
||||
|
In = ParameterLocation.Header, |
||||
|
Scheme = "bearer", |
||||
|
Type = SecuritySchemeType.Http, |
||||
|
BearerFormat = "JWT" |
||||
|
}); |
||||
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
||||
|
{ |
||||
|
{ |
||||
|
new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
||||
|
}, |
||||
|
new string[] { } |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
// 默认支持的本地化语言类型
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
|
||||
|
options.Resources.AddDynamic(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
||||
|
{ |
||||
|
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
|
}); |
||||
|
|
||||
|
if (!isDevelopment) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
services |
||||
|
.AddDataProtection() |
||||
|
.PersistKeysToStackExchangeRedis(redis, "Localization-Protection-Keys"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace LINGYUN.Abp.LocalizationManagement |
||||
|
{ |
||||
|
public partial class AbpLocalizationManagementHttpApiHostModule |
||||
|
{ |
||||
|
private void SeedData(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
if (context.GetEnvironment().IsDevelopment()) |
||||
|
{ |
||||
|
AsyncHelper.RunSync(async () => |
||||
|
await context.ServiceProvider.GetRequiredService<IDataSeeder>() |
||||
|
.SeedAsync()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,239 @@ |
|||||
|
using DotNetCore.CAP; |
||||
|
using LINGYUN.Abp.ExceptionHandling; |
||||
|
using LINGYUN.Abp.MessageService.Localization; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.Cors; |
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text.Encodings.Web; |
||||
|
using System.Text.Unicode; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.AspNetCore.Auditing; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Json.SystemTextJson; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService |
||||
|
{ |
||||
|
public partial class AbpMessageServiceHttpApiHostModule |
||||
|
{ |
||||
|
private void PreConfigureCAP(IConfiguration configuration) |
||||
|
{ |
||||
|
PreConfigure<CapOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.UseMySql(configuration.GetConnectionString("Default")) |
||||
|
.UseRabbitMQ(rabbitMQOptions => |
||||
|
{ |
||||
|
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
||||
|
}) |
||||
|
.UseDashboard(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureDbContext() |
||||
|
{ |
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureJsonSerializer() |
||||
|
{ |
||||
|
// 中文序列化的编码问题
|
||||
|
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
|
{ |
||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigreExceptionHandling() |
||||
|
{ |
||||
|
// 自定义需要处理的异常
|
||||
|
Configure<AbpExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 加入需要处理的异常类型
|
||||
|
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
||||
|
options.Handlers.Add<AbpInitializationException>(); |
||||
|
options.Handlers.Add<ObjectDisposedException>(); |
||||
|
options.Handlers.Add<StackOverflowException>(); |
||||
|
options.Handlers.Add<OutOfMemoryException>(); |
||||
|
options.Handlers.Add<System.Data.Common.DbException>(); |
||||
|
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
||||
|
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAuditing(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpAspNetCoreAuditingOptions>(options => |
||||
|
{ |
||||
|
options.IgnoredUrls.AddIfNotContains("/hangfire"); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpAuditingOptions>(options => |
||||
|
{ |
||||
|
options.ApplicationName = "Localization"; |
||||
|
// 是否启用实体变更记录
|
||||
|
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
||||
|
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
||||
|
{ |
||||
|
options |
||||
|
.EntityHistorySelectors |
||||
|
.AddAllEntities(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureCaching(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
|
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
|
// 滑动过期30天
|
||||
|
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
|
// 绝对过期60天
|
||||
|
options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); |
||||
|
}); |
||||
|
|
||||
|
Configure<RedisCacheOptions>(options => |
||||
|
{ |
||||
|
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
|
options.ConfigurationOptions = redisConfig; |
||||
|
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureVirtualFileSystem() |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AbpMessageServiceHttpApiHostModule>("LINGYUN.Abp.MessageService"); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureMultiTenancy(IConfiguration configuration) |
||||
|
{ |
||||
|
// 多租户
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = true; |
||||
|
}); |
||||
|
|
||||
|
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
||||
|
if (tenantResolveCfg.Exists()) |
||||
|
{ |
||||
|
Configure<AbpTenantResolveOptions>(options => |
||||
|
{ |
||||
|
var domains = tenantResolveCfg.Get<string[]>(); |
||||
|
foreach (var domain in domains) |
||||
|
{ |
||||
|
options.AddDomainTenantResolver(domain); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSwagger(IServiceCollection services) |
||||
|
{ |
||||
|
// Swagger
|
||||
|
services.AddSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MessageService API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
options.CustomSchemaIds(type => type.FullName); |
||||
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
||||
|
Name = "Authorization", |
||||
|
In = ParameterLocation.Header, |
||||
|
Scheme = "bearer", |
||||
|
Type = SecuritySchemeType.Http, |
||||
|
BearerFormat = "JWT" |
||||
|
}); |
||||
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
||||
|
{ |
||||
|
{ |
||||
|
new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
||||
|
}, |
||||
|
new string[] { } |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureCors(IServiceCollection services, IConfiguration configuration) |
||||
|
{ |
||||
|
services.AddCors(options => |
||||
|
{ |
||||
|
options.AddPolicy(DefaultCorsPolicyName, builder => |
||||
|
{ |
||||
|
builder |
||||
|
.WithOrigins( |
||||
|
configuration["App:CorsOrigins"] |
||||
|
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
||||
|
.Select(o => o.RemovePostFix("/")) |
||||
|
.ToArray() |
||||
|
) |
||||
|
.WithAbpExposedHeaders() |
||||
|
.SetIsOriginAllowedToAllowWildcardSubdomains() |
||||
|
.AllowAnyHeader() |
||||
|
.AllowAnyMethod() |
||||
|
.AllowCredentials(); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
// 支持本地化语言类型
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
|
||||
|
options.Resources |
||||
|
.Get<MessageServiceResource>() |
||||
|
.AddVirtualJson("/Localization/HttpApiHost"); |
||||
|
|
||||
|
options.Resources.AddDynamic(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
||||
|
{ |
||||
|
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
|
}); |
||||
|
|
||||
|
if (!isDevelopment) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
services |
||||
|
.AddDataProtection() |
||||
|
.PersistKeysToStackExchangeRedis(redis, "MessageService-Protection-Keys"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService |
||||
|
{ |
||||
|
public partial class AbpMessageServiceHttpApiHostModule |
||||
|
{ |
||||
|
private void SeedData(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
if (context.GetEnvironment().IsDevelopment()) |
||||
|
{ |
||||
|
AsyncHelper.RunSync(async () => |
||||
|
await context.ServiceProvider.GetRequiredService<IDataSeeder>() |
||||
|
.SeedAsync()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,243 @@ |
|||||
|
using DotNetCore.CAP; |
||||
|
using LINGYUN.Abp.ExceptionHandling; |
||||
|
using LINGYUN.Abp.ExceptionHandling.Emailing; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using Microsoft.AspNetCore.Server.Kestrel.Core; |
||||
|
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.IO; |
||||
|
using System.Text.Encodings.Web; |
||||
|
using System.Text.Unicode; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.BlobStoring; |
||||
|
using Volo.Abp.BlobStoring.FileSystem; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Json.SystemTextJson; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace LINGYUN.Platform |
||||
|
{ |
||||
|
public partial class AppPlatformHttpApiHostModule |
||||
|
{ |
||||
|
private void PreConfigureCAP(IConfiguration configuration) |
||||
|
{ |
||||
|
PreConfigure<CapOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.UseMySql(configuration.GetConnectionString("Default")) |
||||
|
.UseRabbitMQ(rabbitMQOptions => |
||||
|
{ |
||||
|
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
||||
|
}) |
||||
|
.UseDashboard(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureDbContext() |
||||
|
{ |
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureJsonSerializer() |
||||
|
{ |
||||
|
// 中文序列化的编码问题
|
||||
|
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
|
{ |
||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureKestrelServer() |
||||
|
{ |
||||
|
Configure<KestrelServerOptions>(options => |
||||
|
{ |
||||
|
options.Limits.MaxRequestBodySize = null; |
||||
|
options.Limits.MaxRequestBufferSize = null; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureBlobStoring() |
||||
|
{ |
||||
|
Configure<AbpBlobStoringOptions>(options => |
||||
|
{ |
||||
|
options.Containers.ConfigureAll((containerName, containerConfiguration) => |
||||
|
{ |
||||
|
containerConfiguration.UseFileSystem(fileSystem => |
||||
|
{ |
||||
|
fileSystem.BasePath = Path.Combine(Directory.GetCurrentDirectory(), "file-blob-storing"); |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigreExceptionHandling() |
||||
|
{ |
||||
|
// 自定义需要处理的异常
|
||||
|
Configure<AbpExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 加入需要处理的异常类型
|
||||
|
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
||||
|
options.Handlers.Add<AbpInitializationException>(); |
||||
|
options.Handlers.Add<ObjectDisposedException>(); |
||||
|
options.Handlers.Add<StackOverflowException>(); |
||||
|
options.Handlers.Add<OutOfMemoryException>(); |
||||
|
options.Handlers.Add<System.Data.Common.DbException>(); |
||||
|
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
||||
|
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
||||
|
}); |
||||
|
// 自定义需要发送邮件通知的异常类型
|
||||
|
Configure<AbpEmailExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 是否发送堆栈信息
|
||||
|
options.SendStackTrace = true; |
||||
|
}); |
||||
|
|
||||
|
Configure<Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingOptions>(options => |
||||
|
{ |
||||
|
// 是否发送错误详情
|
||||
|
options.SendExceptionsDetailsToClients = false; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAuditing(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpAuditingOptions>(options => |
||||
|
{ |
||||
|
options.ApplicationName = "Platform"; |
||||
|
// 是否启用实体变更记录
|
||||
|
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
||||
|
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
||||
|
{ |
||||
|
options |
||||
|
.EntityHistorySelectors |
||||
|
.AddAllEntities(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureCaching(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
|
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
|
// 滑动过期30天
|
||||
|
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
|
// 绝对过期60天
|
||||
|
options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); |
||||
|
}); |
||||
|
|
||||
|
Configure<RedisCacheOptions>(options => |
||||
|
{ |
||||
|
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
|
options.ConfigurationOptions = redisConfig; |
||||
|
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureVirtualFileSystem() |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AppPlatformHttpApiHostModule>("LINGYUN.Platform"); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureMultiTenancy(IConfiguration configuration) |
||||
|
{ |
||||
|
// 多租户
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = true; |
||||
|
}); |
||||
|
|
||||
|
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
||||
|
if (tenantResolveCfg.Exists()) |
||||
|
{ |
||||
|
Configure<AbpTenantResolveOptions>(options => |
||||
|
{ |
||||
|
var domains = tenantResolveCfg.Get<string[]>(); |
||||
|
foreach (var domain in domains) |
||||
|
{ |
||||
|
options.AddDomainTenantResolver(domain); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSwagger(IServiceCollection services) |
||||
|
{ |
||||
|
// Swagger
|
||||
|
services.AddSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Platform API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
options.CustomSchemaIds(type => type.FullName); |
||||
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
||||
|
Name = "Authorization", |
||||
|
In = ParameterLocation.Header, |
||||
|
Scheme = "bearer", |
||||
|
Type = SecuritySchemeType.Http, |
||||
|
BearerFormat = "JWT" |
||||
|
}); |
||||
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
||||
|
{ |
||||
|
{ |
||||
|
new OpenApiSecurityScheme |
||||
|
{ |
||||
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
||||
|
}, |
||||
|
new string[] { } |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
// 支持本地化语言类型
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
|
||||
|
options.Resources.AddDynamic(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
||||
|
{ |
||||
|
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
|
}); |
||||
|
|
||||
|
if (!isDevelopment) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
services |
||||
|
.AddDataProtection() |
||||
|
.PersistKeysToStackExchangeRedis(redis, "Platform-Protection-Keys"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace LINGYUN.Platform |
||||
|
{ |
||||
|
public partial class AppPlatformHttpApiHostModule |
||||
|
{ |
||||
|
private void SeedData(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
if (context.GetEnvironment().IsDevelopment()) |
||||
|
{ |
||||
|
AsyncHelper.RunSync(async () => |
||||
|
await context.ServiceProvider.GetRequiredService<IDataSeeder>() |
||||
|
.SeedAsync()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue