5 changed files with 146 additions and 211 deletions
@ -0,0 +1,42 @@ |
|||
using Microsoft.AspNetCore.Identity; |
|||
using MyCompanyName.MyProjectName.MyModuleName; |
|||
|
|||
#pragma warning disable CS0618 // Type or member is obsolete
|
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection; |
|||
|
|||
public static class ServiceCollectionExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// 注册Redis缓存
|
|||
/// </summary>
|
|||
public static IServiceCollection AddAbpProRedis(this IServiceCollection service) |
|||
{ |
|||
service.Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "AbpPro:"; }); |
|||
var configuration = service.GetConfiguration(); |
|||
var redis = ConnectionMultiplexer.Connect(configuration.GetValue<string>("Redis:Configuration")); |
|||
service |
|||
.AddDataProtection() |
|||
.PersistKeysToStackExchangeRedis(redis, "AbpPro-Protection-Keys"); |
|||
return service; |
|||
} |
|||
/// <summary>
|
|||
/// 配置虚拟文件系统
|
|||
/// </summary>
|
|||
public static IServiceCollection AddAbpProVirtualFileSystem(this IServiceCollection service) |
|||
{ |
|||
service.Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<MyModuleNameHttpApiHostModule>(); |
|||
}); |
|||
return service; |
|||
} |
|||
|
|||
public static IServiceCollection AddAbpProDbContext(this IServiceCollection service) |
|||
{ |
|||
service.Configure<AbpDbContextOptions>(options => { options.UseMySQL(builder => { builder.TranslateParameterizedCollectionsToConstants(); }); }); |
|||
return service; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -1,13 +1,62 @@ |
|||
{ |
|||
"Serilog": { |
|||
"Using": [ |
|||
"Serilog.Sinks.Console", |
|||
"Serilog.Sinks.File" |
|||
], |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"Microsoft": "Information", |
|||
"Volo.Abp": "Information", |
|||
"Hangfire": "Information", |
|||
"DotNetCore.CAP": "Information", |
|||
"Serilog.AspNetCore": "Information", |
|||
"Microsoft.EntityFrameworkCore": "Warning", |
|||
"Microsoft.AspNetCore": "Information" |
|||
} |
|||
}, |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Console" |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "logs/logs-.txt", |
|||
"rollingInterval": "Day" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "Elastic", |
|||
"Args": { |
|||
"Enabled": false, |
|||
"Url": "http://es.cn", |
|||
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}", |
|||
"UserName": "elastic", |
|||
"Password": "aVVhjQ95RP7nbwNy", |
|||
"ApplicationName": "Lion.AbpPro.HttpApi.Host" |
|||
} |
|||
} |
|||
] |
|||
}, |
|||
"App": { |
|||
"CorsOrigins": "https://*.MyModuleName.com,http://localhost:4200,http://localhost:44307,https://localhost:44307" |
|||
"SelfUrl": "http://localhost:44315", |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=localhost;Database=MyCompanyNameMyProjectNameDB;uid=root;pwd=mypassword;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true", |
|||
"MyModuleName": "Data Source=localhost;Database=MyModuleName;uid=root;pwd=mypassword;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
"Default": "Data Source=localhost;Port=3306;Database=MyCompanyName.MyProjectName.MyModuleName;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "localhost,password=mypassword", |
|||
"DatabaseId": 1 |
|||
"Configuration": "localhost:6379,password=1q2w3E*,defaultdatabase=2" |
|||
}, |
|||
"Swagger": { |
|||
"Enabled": true |
|||
}, |
|||
"Cors": { |
|||
"Enabled": true, |
|||
"CorsOrigins": "http://localhost:4200,http://localhost:4201" |
|||
}, |
|||
"MultiTenancy": { |
|||
"Enabled": true |
|||
} |
|||
} |
|||
Loading…
Reference in new issue