mirror of
https://github.com/anjoy8/Blog.Core.git
synced 2024-09-20 23:48:27 +08:00
修改Appsettings 驼峰命名规范为AppSettings,增加sqlsugar model 定义表字段注释示例在Blog.Core.Model.Models.SysUserInfo
This commit is contained in:
parent
26d97687b1
commit
afd20399d4
|
@ -36,7 +36,7 @@ namespace Blog.Core.Controllers
|
|||
{
|
||||
var data = new MessageModel<string>() { success = true, msg = "" };
|
||||
data.response += @"file path is:C:\my-file\}";
|
||||
var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
if (Env.IsDevelopment())
|
||||
{
|
||||
data.response += $"Controller层生成:{FrameSeed.CreateControllers(_sqlSugarClient)} || ";
|
||||
|
@ -74,7 +74,7 @@ namespace Blog.Core.Controllers
|
|||
{
|
||||
ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID;
|
||||
|
||||
var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var data = new MessageModel<string>() { success = true, msg = "" };
|
||||
if (Env.IsDevelopment())
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ namespace Blog.Core.Controllers
|
|||
{
|
||||
ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID;
|
||||
|
||||
var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var data = new MessageModel<string>() { success = true, msg = "" };
|
||||
if (Env.IsDevelopment())
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ namespace Blog.Core.Controllers
|
|||
{
|
||||
ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID;
|
||||
|
||||
var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var data = new MessageModel<string>() { success = true, msg = "" };
|
||||
if (Env.IsDevelopment())
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ namespace Blog.Core.Controllers
|
|||
{
|
||||
ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID;
|
||||
|
||||
var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool();
|
||||
var data = new MessageModel<string>() { success = true, msg = "" };
|
||||
if (Env.IsDevelopment())
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Blog.Core.Controllers
|
|||
[HttpGet]
|
||||
public MessageModel<List<LogInfo>> Get()
|
||||
{
|
||||
if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
{
|
||||
_hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait();
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ namespace Blog.Core.Controllers
|
|||
{
|
||||
List<ApiDate> apiDates = new List<ApiDate>();
|
||||
|
||||
if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
{
|
||||
var users = await _applicationUserServices.Query(d => d.tdIsDelete == false);
|
||||
|
||||
|
|
|
@ -392,7 +392,7 @@ namespace Blog.Core.Controllers
|
|||
[AllowAnonymous]
|
||||
public async Task<string> GetConfigByAppllo(string key)
|
||||
{
|
||||
return await Task.FromResult(Appsettings.app(key));
|
||||
return await Task.FromResult(AppSettings.app(key));
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Blog.Core.Filter
|
|||
|
||||
//采用log4net 进行错误日志记录
|
||||
_loggerHelper.LogError(json.msg + WriteLog(json.msg, context.Exception));
|
||||
if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
{
|
||||
_hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait();
|
||||
}
|
||||
|
|
|
@ -51,12 +51,12 @@ builder.Host
|
|||
|
||||
|
||||
// 2、配置服务
|
||||
builder.Services.AddSingleton(new Appsettings(builder.Configuration));
|
||||
builder.Services.AddSingleton(new AppSettings(builder.Configuration));
|
||||
builder.Services.AddSingleton(new LogLock(builder.Environment.ContentRootPath));
|
||||
builder.Services.AddUiFilesZipSetup(builder.Environment);
|
||||
|
||||
Permissions.IsUseIds4 = Appsettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool();
|
||||
RoutePrefix.Name = Appsettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString();
|
||||
Permissions.IsUseIds4 = AppSettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool();
|
||||
RoutePrefix.Name = AppSettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString();
|
||||
|
||||
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
|
||||
|
||||
|
@ -151,7 +151,7 @@ app.UseSession();
|
|||
app.UseSwaggerAuthorized();
|
||||
app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("Blog.Core.Api.index.html"));
|
||||
|
||||
app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
|
||||
app.UseCors(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
|
||||
DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();
|
||||
defaultFilesOptions.DefaultFileNames.Clear();
|
||||
defaultFilesOptions.DefaultFileNames.Add("index.html");
|
||||
|
|
|
@ -44,12 +44,12 @@ namespace Blog.Core
|
|||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// 以下code可能与文章中不一样,对代码做了封装,具体查看右侧 Extensions 文件夹.
|
||||
services.AddSingleton(new Appsettings(Configuration));
|
||||
services.AddSingleton(new AppSettings(Configuration));
|
||||
services.AddSingleton(new LogLock(Env.ContentRootPath));
|
||||
services.AddUiFilesZipSetup(Env);
|
||||
|
||||
Permissions.IsUseIds4 = Appsettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool();
|
||||
RoutePrefix.Name = Appsettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString();
|
||||
Permissions.IsUseIds4 = AppSettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool();
|
||||
RoutePrefix.Name = AppSettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString();
|
||||
|
||||
// 确保从认证中心返回的ClaimType不被更改,不使用Map映射
|
||||
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
|
||||
|
@ -182,7 +182,7 @@ namespace Blog.Core
|
|||
// ↓↓↓↓↓↓ 注意下边这些中间件的顺序,很重要 ↓↓↓↓↓↓
|
||||
|
||||
// CORS跨域
|
||||
app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
|
||||
app.UseCors(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
|
||||
// 跳转https
|
||||
//app.UseHttpsRedirection();
|
||||
// 使用静态文件
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace Blog.Core.Common.AppConfig
|
|||
{
|
||||
public class AppSecretConfig
|
||||
{
|
||||
private static string Audience_Secret = Appsettings.app(new string[] { "Audience", "Secret" });
|
||||
private static string Audience_Secret_File = Appsettings.app(new string[] { "Audience", "SecretFile" });
|
||||
private static string Audience_Secret = AppSettings.app(new string[] { "Audience", "Secret" });
|
||||
private static string Audience_Secret_File = AppSettings.app(new string[] { "Audience", "SecretFile" });
|
||||
|
||||
|
||||
public static string Audience_Secret_String => InitAudience_Secret();
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Blog.Core.Common.DB
|
|||
|
||||
public static (List<MutiDBOperate>, List<MutiDBOperate>) MutiInitConn()
|
||||
{
|
||||
List<MutiDBOperate> listdatabase = Appsettings.app<MutiDBOperate>("DBS")
|
||||
List<MutiDBOperate> listdatabase = AppSettings.app<MutiDBOperate>("DBS")
|
||||
.Where(i => i.Enabled).ToList();
|
||||
foreach (var i in listdatabase)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ namespace Blog.Core.Common.DB
|
|||
List<MutiDBOperate> listdatabaseSlaveDB = new List<MutiDBOperate>();//从库
|
||||
|
||||
// 单库,且不开启读写分离,只保留一个
|
||||
if (!Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
{
|
||||
if (listdatabase.Count == 1)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ namespace Blog.Core.Common.DB
|
|||
}
|
||||
else
|
||||
{
|
||||
var dbFirst = listdatabase.FirstOrDefault(d => d.ConnId == Appsettings.app(new string[] { "MainDB" }).ObjToString());
|
||||
var dbFirst = listdatabase.FirstOrDefault(d => d.ConnId == AppSettings.app(new string[] { "MainDB" }).ObjToString());
|
||||
if (dbFirst == null)
|
||||
{
|
||||
dbFirst = listdatabase.FirstOrDefault();
|
||||
|
@ -61,11 +61,11 @@ namespace Blog.Core.Common.DB
|
|||
|
||||
|
||||
// 读写分离,且必须是单库模式,获取从库
|
||||
if (Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
{
|
||||
if (listdatabase.Count > 1)
|
||||
{
|
||||
listdatabaseSlaveDB = listdatabase.Where(d => d.ConnId != Appsettings.app(new string[] { "MainDB" }).ObjToString()).ToList();
|
||||
listdatabaseSlaveDB = listdatabase.Where(d => d.ConnId != AppSettings.app(new string[] { "MainDB" }).ObjToString()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ namespace Blog.Core.Common
|
|||
/// <summary>
|
||||
/// appsettings.json操作类
|
||||
/// </summary>
|
||||
public class Appsettings
|
||||
public class AppSettings
|
||||
{
|
||||
public static IConfiguration Configuration { get; set; }
|
||||
static string contentPath { get; set; }
|
||||
|
||||
public Appsettings(string contentPath)
|
||||
public AppSettings(string contentPath)
|
||||
{
|
||||
string Path = "appsettings.json";
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace Blog.Core.Common
|
|||
.Build();
|
||||
}
|
||||
|
||||
public Appsettings(IConfiguration configuration)
|
||||
public AppSettings(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Blog.Core.Hubs
|
|||
public async Task GetLatestCount(string random)
|
||||
{
|
||||
//2、服务端主动向客户端发送数据,名字千万不能错
|
||||
if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
{
|
||||
await Clients.All.ReceiveUpdate(LogLock.GetLogData());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Blog.Core.Common.LogHelper
|
|||
public static void OutSql2Log(string prefix, string[] dataParas, bool IsHeader = true, bool isWrt = false)
|
||||
{
|
||||
|
||||
if (Appsettings.app(new string[] { "AppSettings", "LogToDb", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "AppSettings", "LogToDb", "Enabled" }).ObjToBool())
|
||||
{
|
||||
OutSql2LogToDB(prefix, dataParas, IsHeader);
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ namespace Blog.Core.Common.Seed
|
|||
SeedDataFolder = Path.Combine(WebRootPath, SeedDataFolder);
|
||||
|
||||
Console.WriteLine("************ Blog.Core DataBase Set *****************");
|
||||
Console.WriteLine($"Is multi-DataBase: {Appsettings.app(new string[] { "MutiDBEnabled" })}");
|
||||
Console.WriteLine($"Is CQRS: {Appsettings.app(new string[] { "CQRSEnabled" })}");
|
||||
Console.WriteLine($"Is multi-DataBase: {AppSettings.app(new string[] { "MutiDBEnabled" })}");
|
||||
Console.WriteLine($"Is CQRS: {AppSettings.app(new string[] { "CQRSEnabled" })}");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"Master DB ConId: {MyContext.ConnId}");
|
||||
Console.WriteLine($"Master DB Type: {MyContext.DbType}");
|
||||
Console.WriteLine($"Master DB ConnectString: {MyContext.ConnectionString}");
|
||||
Console.WriteLine();
|
||||
if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
{
|
||||
var slaveIndex = 0;
|
||||
BaseDBConfig.MutiConnectionString.allDbs.Where(x => x.ConnId != MainDb.CurrentDbConnId).ToList().ForEach(m =>
|
||||
|
@ -55,7 +55,7 @@ namespace Blog.Core.Common.Seed
|
|||
Console.WriteLine($"--------------------------------------");
|
||||
});
|
||||
}
|
||||
else if (Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool())
|
||||
else if (AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool())
|
||||
{
|
||||
var slaveIndex = 0;
|
||||
BaseDBConfig.MutiConnectionString.slaveDbs.Where(x => x.ConnId != MainDb.CurrentDbConnId).ToList().ForEach(m =>
|
||||
|
@ -112,7 +112,7 @@ namespace Blog.Core.Common.Seed
|
|||
|
||||
|
||||
|
||||
if (Appsettings.app(new string[] { "AppSettings", "SeedDBDataEnabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "AppSettings", "SeedDBDataEnabled" }).ObjToBool())
|
||||
{
|
||||
JsonSerializerSettings setting = new JsonSerializerSettings();
|
||||
JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() =>
|
||||
|
|
|
@ -7,31 +7,31 @@ namespace Blog.Core.Common.Static
|
|||
/// <summary>
|
||||
/// 商户号
|
||||
/// </summary>
|
||||
public readonly static string MERCHANTID = Appsettings.app(new string[] { "PayInfo", "MERCHANTID" }).ObjToString();
|
||||
public readonly static string MERCHANTID = AppSettings.app(new string[] { "PayInfo", "MERCHANTID" }).ObjToString();
|
||||
/// <summary>
|
||||
/// 柜台号
|
||||
/// </summary>
|
||||
public readonly static string POSID = Appsettings.app(new string[] { "PayInfo", "POSID" }).ObjToString();
|
||||
public readonly static string POSID = AppSettings.app(new string[] { "PayInfo", "POSID" }).ObjToString();
|
||||
/// <summary>
|
||||
/// 分行号
|
||||
/// </summary>
|
||||
public readonly static string BRANCHID = Appsettings.app(new string[] { "PayInfo", "BRANCHID" }).ObjToString();
|
||||
public readonly static string BRANCHID = AppSettings.app(new string[] { "PayInfo", "BRANCHID" }).ObjToString();
|
||||
/// <summary>
|
||||
/// 公钥
|
||||
/// </summary>
|
||||
public readonly static string pubKey = Appsettings.app(new string[] { "PayInfo", "pubKey" }).ObjToString();
|
||||
public readonly static string pubKey = AppSettings.app(new string[] { "PayInfo", "pubKey" }).ObjToString();
|
||||
/// <summary>
|
||||
/// 操作员号
|
||||
/// </summary>
|
||||
public readonly static string USER_ID = Appsettings.app(new string[] { "PayInfo", "USER_ID" }).ObjToString();
|
||||
public readonly static string USER_ID = AppSettings.app(new string[] { "PayInfo", "USER_ID" }).ObjToString();
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public readonly static string PASSWORD = Appsettings.app(new string[] { "PayInfo", "PASSWORD" }).ObjToString();
|
||||
public readonly static string PASSWORD = AppSettings.app(new string[] { "PayInfo", "PASSWORD" }).ObjToString();
|
||||
/// <summary>
|
||||
/// 外联平台通讯地址
|
||||
/// </summary>
|
||||
public readonly static string OutAddress = Appsettings.app(new string[] { "PayInfo", "OutAddress" }).ObjToString();
|
||||
public readonly static string OutAddress = AppSettings.app(new string[] { "PayInfo", "OutAddress" }).ObjToString();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ namespace Blog.Core.AOP
|
|||
{
|
||||
LogEx(ex, apiLogAopInfo);
|
||||
}
|
||||
if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool())
|
||||
{
|
||||
_hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait();
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ namespace Blog.Core.AuthHelper.OverWrite
|
|||
/// <returns></returns>
|
||||
public static string IssueJwt(TokenModelJwt tokenModel)
|
||||
{
|
||||
string iss = Appsettings.app(new string[] { "Audience", "Issuer" });
|
||||
string aud = Appsettings.app(new string[] { "Audience", "Audience" });
|
||||
string iss = AppSettings.app(new string[] { "Audience", "Issuer" });
|
||||
string aud = AppSettings.app(new string[] { "Audience", "Audience" });
|
||||
string secret = AppSecretConfig.Audience_Secret_String;
|
||||
|
||||
//var claims = new Claim[] //old
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace Blog.Core.AuthHelper
|
|||
var result = await httpContext.AuthenticateAsync(defaultAuthenticate.Name);
|
||||
|
||||
// 是否开启测试环境
|
||||
var isTestCurrent = Appsettings.app(new string[] { "AppSettings", "UseLoadTest" }).ObjToBool();
|
||||
var isTestCurrent = AppSettings.app(new string[] { "AppSettings", "UseLoadTest" }).ObjToBool();
|
||||
|
||||
//result?.Principal不为空即登录成功
|
||||
if (result?.Principal != null || isTestCurrent)
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
try
|
||||
{
|
||||
if (Appsettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool())
|
||||
if (AppSettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool())
|
||||
{
|
||||
app.UseIpRateLimiting();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
if (Appsettings.app("Middleware", "IPLog", "Enabled").ObjToBool())
|
||||
if (AppSettings.app("Middleware", "IPLog", "Enabled").ObjToBool())
|
||||
{
|
||||
// 过滤,只有接口
|
||||
if (context.Request.Path.Value.Contains("api"))
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
try
|
||||
{
|
||||
if (Appsettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool())
|
||||
if (AppSettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool())
|
||||
{
|
||||
// 性能分析
|
||||
app.UseMiniProfiler();
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
try
|
||||
{
|
||||
if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool())
|
||||
if (AppSettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool())
|
||||
{
|
||||
|
||||
var allQzServices = tasksQzServices.Query().Result;
|
||||
|
|
|
@ -45,10 +45,10 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
if (Appsettings.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool())
|
||||
if (AppSettings.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool())
|
||||
{
|
||||
var api = context.Request.Path.ObjToString().TrimEnd('/').ToLower();
|
||||
var ignoreApis = Appsettings.app("Middleware", "RecordAccessLogs", "IgnoreApis");
|
||||
var ignoreApis = AppSettings.app("Middleware", "RecordAccessLogs", "IgnoreApis");
|
||||
|
||||
// 过滤,只有接口
|
||||
if (api.Contains("api") && !ignoreApis.Contains(api))
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
if (Appsettings.app("Middleware", "RequestResponseLog", "Enabled").ObjToBool())
|
||||
if (AppSettings.app("Middleware", "RequestResponseLog", "Enabled").ObjToBool())
|
||||
{
|
||||
// 过滤,只有接口
|
||||
if (context.Request.Path.Value.Contains("api"))
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
try
|
||||
{
|
||||
if (Appsettings.app("AppSettings", "SeedDBEnabled").ObjToBool() || Appsettings.app("AppSettings", "SeedDBDataEnabled").ObjToBool())
|
||||
if (AppSettings.app("AppSettings", "SeedDBEnabled").ObjToBool() || AppSettings.app("AppSettings", "SeedDBDataEnabled").ObjToBool())
|
||||
{
|
||||
DBSeed.SeedAsync(myContext, webRootPath).Wait();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
if (Appsettings.app("Middleware", "SignalR", "Enabled").ObjToBool())
|
||||
if (AppSettings.app("Middleware", "SignalR", "Enabled").ObjToBool())
|
||||
{
|
||||
await _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Blog.Core.Extensions.Middlewares
|
|||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
//根据版本名称倒序 遍历展示
|
||||
var apiName = Appsettings.app(new string[] { "Startup", "ApiName" });
|
||||
var apiName = AppSettings.app(new string[] { "Startup", "ApiName" });
|
||||
typeof(ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach(version =>
|
||||
{
|
||||
c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"{apiName} {version}");
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Blog.Core.Extensions
|
|||
|
||||
public RedisCacheManager()
|
||||
{
|
||||
string redisConfiguration = Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "ConnectionString" });//获取连接字符串
|
||||
string redisConfiguration = AppSettings.app(new string[] { "AppSettings", "RedisCachingAOP", "ConnectionString" });//获取连接字符串
|
||||
|
||||
if (string.IsNullOrWhiteSpace(redisConfiguration))
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
if (Appsettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool())
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// Redis缓存AOP
|
||||
if (!Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Redis Caching AOP: False");
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// 内存缓存AOP
|
||||
if (!Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Memory Caching AOP: False");
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// 服务日志AOP
|
||||
if (!Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Service Log AOP: False");
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// 开启的中间件日志
|
||||
var requestResponseLogOpen = Appsettings.app(new string[] { "Middleware", "RequestResponseLog", "Enabled" }).ObjToBool();
|
||||
var ipLogOpen = Appsettings.app(new string[] { "Middleware", "IPLog", "Enabled" }).ObjToBool();
|
||||
var recordAccessLogsOpen = Appsettings.app(new string[] { "Middleware", "RecordAccessLogs", "Enabled" }).ObjToBool();
|
||||
var requestResponseLogOpen = AppSettings.app(new string[] { "Middleware", "RequestResponseLog", "Enabled" }).ObjToBool();
|
||||
var ipLogOpen = AppSettings.app(new string[] { "Middleware", "IPLog", "Enabled" }).ObjToBool();
|
||||
var recordAccessLogsOpen = AppSettings.app(new string[] { "Middleware", "RecordAccessLogs", "Enabled" }).ObjToBool();
|
||||
ConsoleHelper.WriteSuccessLine($"OPEN Log: " +
|
||||
(requestResponseLogOpen ? "RequestResponseLog √," : "") +
|
||||
(ipLogOpen ? "IPLog √," : "") +
|
||||
|
@ -82,7 +82,7 @@ namespace Blog.Core.Extensions
|
|||
);
|
||||
|
||||
// 事务AOP
|
||||
if (!Appsettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Transaction AOP: False");
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// 数据库Sql执行AOP
|
||||
if (!Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"DB Sql AOP To LogFile: False");
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// Sql执行日志输出到控制台
|
||||
if (!Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"DB Sql AOP To Console: False");
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// SingnalR发送数据
|
||||
if (!Appsettings.app(new string[] { "Middleware", "SignalR", "Enabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "Middleware", "SignalR", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"SignalR send data: False");
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// IP限流
|
||||
if (!Appsettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool())
|
||||
if (!AppSettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"IpRateLimiting: False");
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// 性能分析
|
||||
if (!Appsettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool())
|
||||
if (!AppSettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"MiniProfiler: False");
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// CORS跨域
|
||||
if (!Appsettings.app("Startup", "Cors", "EnableAllIPs").ObjToBool())
|
||||
if (!AppSettings.app("Startup", "Cors", "EnableAllIPs").ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"EnableAllIPs For CORS: False");
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// redis消息队列
|
||||
if (!Appsettings.app("Startup", "RedisMq", "Enabled").ObjToBool())
|
||||
if (!AppSettings.app("Startup", "RedisMq", "Enabled").ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Redis MQ: False");
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// RabbitMQ 消息队列
|
||||
if (!Appsettings.app("RabbitMQ", "Enabled").ObjToBool())
|
||||
if (!AppSettings.app("RabbitMQ", "Enabled").ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"RabbitMQ: False");
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// Consul 注册服务
|
||||
if (!Appsettings.app("Middleware", "Consul", "Enabled").ObjToBool())
|
||||
if (!AppSettings.app("Middleware", "Consul", "Enabled").ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Consul service: False");
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// EventBus 事件总线
|
||||
if (!Appsettings.app("EventBus", "Enabled").ObjToBool())
|
||||
if (!AppSettings.app("EventBus", "Enabled").ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"EventBus: False");
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// 多库
|
||||
if (!Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Is multi-DataBase: False");
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ namespace Blog.Core.Extensions
|
|||
}
|
||||
|
||||
// 读写分离
|
||||
if (!Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool())
|
||||
{
|
||||
Console.WriteLine($"Is CQRS: False");
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
if (Appsettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool())
|
||||
{
|
||||
|
||||
if (env.IsDevelopment())
|
||||
|
@ -234,12 +234,12 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
new string[] { "当前环境", Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") },
|
||||
new string[] { "当前的授权方案", Permissions.IsUseIds4 ? "Ids4" : "JWT" },
|
||||
new string[] { "CORS跨域", Appsettings.app("Startup", "Cors", "EnableAllIPs") },
|
||||
new string[] { "RabbitMQ消息列队", Appsettings.app("RabbitMQ", "Enabled") },
|
||||
new string[] { "事件总线(必须开启消息列队)", Appsettings.app("EventBus", "Enabled") },
|
||||
new string[] { "redis消息队列", Appsettings.app("Startup", "RedisMq", "Enabled") },
|
||||
new string[] { "是否多库", Appsettings.app("MutiDBEnabled" ) },
|
||||
new string[] { "读写分离", Appsettings.app("CQRSEnabled") },
|
||||
new string[] { "CORS跨域", AppSettings.app("Startup", "Cors", "EnableAllIPs") },
|
||||
new string[] { "RabbitMQ消息列队", AppSettings.app("RabbitMQ", "Enabled") },
|
||||
new string[] { "事件总线(必须开启消息列队)", AppSettings.app("EventBus", "Enabled") },
|
||||
new string[] { "redis消息队列", AppSettings.app("Startup", "RedisMq", "Enabled") },
|
||||
new string[] { "是否多库", AppSettings.app("MutiDBEnabled" ) },
|
||||
new string[] { "读写分离", AppSettings.app("CQRSEnabled") },
|
||||
};
|
||||
|
||||
new ConsoleTable()
|
||||
|
@ -258,12 +258,12 @@ namespace Blog.Core.Extensions
|
|||
#region AOP
|
||||
List<string[]> aopInfos = new()
|
||||
{
|
||||
new string[] { "Redis缓存AOP", Appsettings.app("AppSettings", "RedisCachingAOP", "Enabled") },
|
||||
new string[] { "内存缓存AOP", Appsettings.app("AppSettings", "MemoryCachingAOP", "Enabled") },
|
||||
new string[] { "服务日志AOP", Appsettings.app("AppSettings", "LogAOP", "Enabled" ) },
|
||||
new string[] { "事务AOP", Appsettings.app("AppSettings", "TranAOP", "Enabled" ) },
|
||||
new string[] { "Sql执行AOP", Appsettings.app("AppSettings", "SqlAOP", "OutToLogFile", "Enabled" ) },
|
||||
new string[] { "Sql执行AOP控制台输出", Appsettings.app("AppSettings", "SqlAOP", "OutToConsole", "Enabled" ) },
|
||||
new string[] { "Redis缓存AOP", AppSettings.app("AppSettings", "RedisCachingAOP", "Enabled") },
|
||||
new string[] { "内存缓存AOP", AppSettings.app("AppSettings", "MemoryCachingAOP", "Enabled") },
|
||||
new string[] { "服务日志AOP", AppSettings.app("AppSettings", "LogAOP", "Enabled" ) },
|
||||
new string[] { "事务AOP", AppSettings.app("AppSettings", "TranAOP", "Enabled" ) },
|
||||
new string[] { "Sql执行AOP", AppSettings.app("AppSettings", "SqlAOP", "OutToLogFile", "Enabled" ) },
|
||||
new string[] { "Sql执行AOP控制台输出", AppSettings.app("AppSettings", "SqlAOP", "OutToConsole", "Enabled" ) },
|
||||
};
|
||||
|
||||
new ConsoleTable
|
||||
|
@ -282,13 +282,13 @@ namespace Blog.Core.Extensions
|
|||
#region 中间件
|
||||
List<string[]> MiddlewareInfos = new()
|
||||
{
|
||||
new string[] { "请求纪录中间件", Appsettings.app("Middleware", "RecordAccessLogs", "Enabled") },
|
||||
new string[] { "IP记录中间件", Appsettings.app("Middleware", "IPLog", "Enabled" ) },
|
||||
new string[] { "请求响应日志中间件", Appsettings.app("Middleware", "RequestResponseLog", "Enabled" ) },
|
||||
new string[] { "SingnalR实时发送请求数据中间件", Appsettings.app("Middleware", "SignalR", "Enabled" ) },
|
||||
new string[] { "IP限流中间件", Appsettings.app("Middleware", "IpRateLimit", "Enabled") },
|
||||
new string[] { "性能分析中间件", Appsettings.app("Startup", "MiniProfiler", "Enabled") },
|
||||
new string[] { "Consul注册服务", Appsettings.app("Middleware", "Consul", "Enabled") },
|
||||
new string[] { "请求纪录中间件", AppSettings.app("Middleware", "RecordAccessLogs", "Enabled") },
|
||||
new string[] { "IP记录中间件", AppSettings.app("Middleware", "IPLog", "Enabled" ) },
|
||||
new string[] { "请求响应日志中间件", AppSettings.app("Middleware", "RequestResponseLog", "Enabled" ) },
|
||||
new string[] { "SingnalR实时发送请求数据中间件", AppSettings.app("Middleware", "SignalR", "Enabled" ) },
|
||||
new string[] { "IP限流中间件", AppSettings.app("Middleware", "IpRateLimit", "Enabled") },
|
||||
new string[] { "性能分析中间件", AppSettings.app("Startup", "MiniProfiler", "Enabled") },
|
||||
new string[] { "Consul注册服务", AppSettings.app("Middleware", "Consul", "Enabled") },
|
||||
};
|
||||
|
||||
new ConsoleTable
|
||||
|
|
|
@ -26,9 +26,9 @@ namespace Blog.Core.Extensions
|
|||
})
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.Authority = Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" });
|
||||
options.Authority = AppSettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" });
|
||||
options.RequireHttpsMetadata = false;
|
||||
options.Audience = Appsettings.app(new string[] { "Startup", "IdentityServer4", "ApiName" });
|
||||
options.Audience = AppSettings.app(new string[] { "Startup", "IdentityServer4", "ApiName" });
|
||||
})
|
||||
.AddScheme<AuthenticationSchemeOptions, ApiResponseHandler>(nameof(ApiResponseHandler), o => { });
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace Blog.Core.Extensions
|
|||
var symmetricKeyAsBase64 = AppSecretConfig.Audience_Secret_String;
|
||||
var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64);
|
||||
var signingKey = new SymmetricSecurityKey(keyByteArray);
|
||||
var Issuer = Appsettings.app(new string[] { "Audience", "Issuer" });
|
||||
var Audience = Appsettings.app(new string[] { "Audience", "Audience" });
|
||||
var Issuer = AppSettings.app(new string[] { "Audience", "Issuer" });
|
||||
var Audience = AppSettings.app(new string[] { "Audience", "Audience" });
|
||||
|
||||
var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256);
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ namespace Blog.Core.Extensions
|
|||
var symmetricKeyAsBase64 = AppSecretConfig.Audience_Secret_String;
|
||||
var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64);
|
||||
var signingKey = new SymmetricSecurityKey(keyByteArray);
|
||||
var Issuer = Appsettings.app(new string[] { "Audience", "Issuer" });
|
||||
var Audience = Appsettings.app(new string[] { "Audience", "Audience" });
|
||||
var Issuer = AppSettings.app(new string[] { "Audience", "Issuer" });
|
||||
var Audience = AppSettings.app(new string[] { "Audience", "Audience" });
|
||||
|
||||
var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256);
|
||||
|
||||
|
|
|
@ -42,25 +42,25 @@ namespace Blog.Core.Extensions
|
|||
|
||||
// AOP 开关,如果想要打开指定的功能,只需要在 appsettigns.json 对应对应 true 就行。
|
||||
var cacheType = new List<Type>();
|
||||
if (Appsettings.app(new string[] {"AppSettings", "RedisCachingAOP", "Enabled"}).ObjToBool())
|
||||
if (AppSettings.app(new string[] {"AppSettings", "RedisCachingAOP", "Enabled"}).ObjToBool())
|
||||
{
|
||||
builder.RegisterType<BlogRedisCacheAOP>();
|
||||
cacheType.Add(typeof(BlogRedisCacheAOP));
|
||||
}
|
||||
|
||||
if (Appsettings.app(new string[] {"AppSettings", "MemoryCachingAOP", "Enabled"}).ObjToBool())
|
||||
if (AppSettings.app(new string[] {"AppSettings", "MemoryCachingAOP", "Enabled"}).ObjToBool())
|
||||
{
|
||||
builder.RegisterType<BlogCacheAOP>();
|
||||
cacheType.Add(typeof(BlogCacheAOP));
|
||||
}
|
||||
|
||||
if (Appsettings.app(new string[] {"AppSettings", "TranAOP", "Enabled"}).ObjToBool())
|
||||
if (AppSettings.app(new string[] {"AppSettings", "TranAOP", "Enabled"}).ObjToBool())
|
||||
{
|
||||
builder.RegisterType<BlogTranAOP>();
|
||||
cacheType.Add(typeof(BlogTranAOP));
|
||||
}
|
||||
|
||||
if (Appsettings.app(new string[] {"AppSettings", "LogAOP", "Enabled"}).ObjToBool())
|
||||
if (AppSettings.app(new string[] {"AppSettings", "LogAOP", "Enabled"}).ObjToBool())
|
||||
{
|
||||
builder.RegisterType<BlogLogAOP>();
|
||||
cacheType.Add(typeof(BlogLogAOP));
|
||||
|
|
|
@ -15,15 +15,15 @@ namespace Blog.Core.Extensions
|
|||
|
||||
services.AddCors(c =>
|
||||
{
|
||||
if (!Appsettings.app(new string[] { "Startup", "Cors", "EnableAllIPs" }).ObjToBool())
|
||||
if (!AppSettings.app(new string[] { "Startup", "Cors", "EnableAllIPs" }).ObjToBool())
|
||||
{
|
||||
c.AddPolicy(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }),
|
||||
c.AddPolicy(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" }),
|
||||
|
||||
policy =>
|
||||
{
|
||||
|
||||
policy
|
||||
.WithOrigins(Appsettings.app(new string[] { "Startup", "Cors", "IPs" }).Split(','))
|
||||
.WithOrigins(AppSettings.app(new string[] { "Startup", "Cors", "IPs" }).Split(','))
|
||||
.AllowAnyHeader()//Ensures that the policy allows any header.
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ namespace Blog.Core.Extensions
|
|||
else
|
||||
{
|
||||
//允许任意跨域请求
|
||||
c.AddPolicy(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }),
|
||||
c.AddPolicy(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" }),
|
||||
policy =>
|
||||
{
|
||||
policy
|
||||
|
|
|
@ -18,14 +18,14 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
if (Appsettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool())
|
||||
{
|
||||
var subscriptionClientName = Appsettings.app(new string[] { "EventBus", "SubscriptionClientName" });
|
||||
var subscriptionClientName = AppSettings.app(new string[] { "EventBus", "SubscriptionClientName" });
|
||||
|
||||
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
|
||||
services.AddTransient<BlogQueryIntegrationEventHandler>();
|
||||
|
||||
if (Appsettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool())
|
||||
{
|
||||
services.AddSingleton<IEventBus, EventBusRabbitMQ>(sp =>
|
||||
{
|
||||
|
@ -35,15 +35,15 @@ namespace Blog.Core.Extensions
|
|||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
var retryCount = 5;
|
||||
if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "RetryCount" })))
|
||||
if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "RetryCount" })))
|
||||
{
|
||||
retryCount = int.Parse(Appsettings.app(new string[] { "RabbitMQ", "RetryCount" }));
|
||||
retryCount = int.Parse(AppSettings.app(new string[] { "RabbitMQ", "RetryCount" }));
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
if(Appsettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool())
|
||||
if(AppSettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool())
|
||||
{
|
||||
services.AddHostedService<KafkaConsumerHostService>();
|
||||
services.AddSingleton<IEventBus, EventBusKafka>();
|
||||
|
@ -54,7 +54,7 @@ namespace Blog.Core.Extensions
|
|||
|
||||
public static void ConfigureEventBus(this IApplicationBuilder app)
|
||||
{
|
||||
if (Appsettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool())
|
||||
{
|
||||
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
if (Appsettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool())
|
||||
{
|
||||
services.Configure<KafkaOptions>(configuration.GetSection("kafka"));
|
||||
services.AddSingleton<IKafkaConnectionPool,KafkaConnectionPool>();
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Blog.Core.Extensions
|
|||
public static void AddMiniProfilerSetup(this IServiceCollection services)
|
||||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
if(Appsettings.app(new string[] { "Startup", "MiniProfiler", "Enabled" }).ObjToBool())
|
||||
if(AppSettings.app(new string[] { "Startup", "MiniProfiler", "Enabled" }).ObjToBool())
|
||||
{
|
||||
services.AddMiniProfiler();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Blog.Core.Extensions
|
|||
|
||||
// 在实际生产工作中 本地开发是不需要注册nacos的 所以根据环境变量去判断
|
||||
// 比如 开发环境 dev 测试环境 test 生产 prod 只有这几种环境变量的时候才需要去注册nacos
|
||||
if (Appsettings.app(new string[] { "Startup", "Nacos", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Startup", "Nacos", "Enabled" }).ObjToBool())
|
||||
{
|
||||
// 从当前配置取文件去注册naocs
|
||||
services.AddNacosV2Config(x =>
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
if (Appsettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool())
|
||||
{
|
||||
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
|
||||
{
|
||||
|
@ -24,29 +24,29 @@ namespace Blog.Core.Extensions
|
|||
|
||||
var factory = new ConnectionFactory()
|
||||
{
|
||||
HostName = Appsettings.app(new string[] { "RabbitMQ", "Connection" }),
|
||||
HostName = AppSettings.app(new string[] { "RabbitMQ", "Connection" }),
|
||||
DispatchConsumersAsync = true
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "UserName" })))
|
||||
if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "UserName" })))
|
||||
{
|
||||
factory.UserName = Appsettings.app(new string[] { "RabbitMQ", "UserName" });
|
||||
factory.UserName = AppSettings.app(new string[] { "RabbitMQ", "UserName" });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "Password" })))
|
||||
if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "Password" })))
|
||||
{
|
||||
factory.Password = Appsettings.app(new string[] { "RabbitMQ", "Password" });
|
||||
factory.Password = AppSettings.app(new string[] { "RabbitMQ", "Password" });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "Port" })))
|
||||
if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "Port" })))
|
||||
{
|
||||
factory.Port = Appsettings.app(new string[] { "RabbitMQ", "Port" }).ObjToInt();
|
||||
factory.Port = AppSettings.app(new string[] { "RabbitMQ", "Port" }).ObjToInt();
|
||||
}
|
||||
|
||||
var retryCount = 5;
|
||||
if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "RetryCount" })))
|
||||
if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "RetryCount" })))
|
||||
{
|
||||
retryCount = Appsettings.app(new string[] { "RabbitMQ", "RetryCount" }).ObjToInt();
|
||||
retryCount = AppSettings.app(new string[] { "RabbitMQ", "RetryCount" }).ObjToInt();
|
||||
}
|
||||
|
||||
return new RabbitMQPersistentConnection(factory, logger, retryCount);
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Blog.Core.Extensions
|
|||
services.AddSingleton<ConnectionMultiplexer>(sp =>
|
||||
{
|
||||
//获取连接字符串
|
||||
string redisConfiguration = Appsettings.app(new string[] { "Redis", "ConnectionString" });
|
||||
string redisConfiguration = AppSettings.app(new string[] { "Redis", "ConnectionString" });
|
||||
|
||||
var configuration = ConfigurationOptions.Parse(redisConfiguration, true);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
if (Appsettings.app(new string[] { "Startup", "RedisMq", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "Startup", "RedisMq", "Enabled" }).ObjToBool())
|
||||
{
|
||||
//
|
||||
services.AddInitQ(m =>
|
||||
|
@ -24,7 +24,7 @@ namespace Blog.Core.Extensions
|
|||
//时间间隔
|
||||
m.SuspendTime = 2000;
|
||||
//redis服务器地址
|
||||
m.ConnectionString = Appsettings.app(new string[] { "Redis", "ConnectionString" });
|
||||
m.ConnectionString = AppSettings.app(new string[] { "Redis", "ConnectionString" });
|
||||
//对应的订阅者类,需要new一个实例对象,当然你也可以传参,比如日志对象
|
||||
m.ListSubscribe = new List<Type>() {
|
||||
typeof(RedisSubscribe),
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Blog.Core.Extensions
|
|||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
// 默认添加主数据库连接
|
||||
MainDb.CurrentDbConnId = Appsettings.app(new string[] { "MainDB" });
|
||||
MainDb.CurrentDbConnId = AppSettings.app(new string[] { "MainDB" });
|
||||
|
||||
// SqlSugarScope是线程安全,可使用单例注入
|
||||
// 参考:https://www.donet5.com/Home/Doc?typeId=1181
|
||||
|
@ -59,9 +59,9 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
OnLogExecuting = (sql, p) =>
|
||||
{
|
||||
if (Appsettings.app(new string[] { "AppSettings", "SqlAOP", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "AppSettings", "SqlAOP", "Enabled" }).ObjToBool())
|
||||
{
|
||||
if (Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool())
|
||||
{
|
||||
Parallel.For(0, 1, e =>
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ namespace Blog.Core.Extensions
|
|||
|
||||
});
|
||||
}
|
||||
if (Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool())
|
||||
{
|
||||
ConsoleHelper.WriteColorLine(string.Join("\r\n", new string[] { "--------", "【SQL语句】:" + GetWholeSql(p, sql) }), ConsoleColor.DarkCyan);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Blog.Core.Extensions
|
|||
|
||||
var basePath = AppContext.BaseDirectory;
|
||||
//var basePath2 = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath;
|
||||
var ApiName = Appsettings.app(new string[] { "Startup", "ApiName" });
|
||||
var ApiName = AppSettings.app(new string[] { "Startup", "ApiName" });
|
||||
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ namespace Blog.Core.Extensions
|
|||
{
|
||||
Implicit = new OpenApiOAuthFlow
|
||||
{
|
||||
AuthorizationUrl = new Uri($"{Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" })}/connect/authorize"),
|
||||
AuthorizationUrl = new Uri($"{AppSettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" })}/connect/authorize"),
|
||||
Scopes = new Dictionary<string, string> {
|
||||
{
|
||||
"blog.core.api","ApiResource id"
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Blog.Core.AuthHelper
|
|||
private readonly RequestDelegate _next;
|
||||
|
||||
|
||||
public CustomJwtTokenAuthMiddleware(INacosNamingService serv, RequestDelegate next, IAuthenticationSchemeProvider schemes, Appsettings appset,ICaching cache)
|
||||
public CustomJwtTokenAuthMiddleware(INacosNamingService serv, RequestDelegate next, IAuthenticationSchemeProvider schemes, AppSettings appset,ICaching cache)
|
||||
{
|
||||
NacosServClient = serv;
|
||||
_cache = cache;
|
||||
|
@ -129,9 +129,9 @@ namespace Blog.Core.AuthHelper
|
|||
{
|
||||
try
|
||||
{
|
||||
string PermissionServName = Appsettings.GetValue("ApiGateWay:PermissionServName");
|
||||
string PermissionServGroup = Appsettings.GetValue("ApiGateWay:PermissionServGroup");
|
||||
string PermissionServUrl = Appsettings.GetValue("ApiGateWay:PermissionServUrl");
|
||||
string PermissionServName = AppSettings.GetValue("ApiGateWay:PermissionServName");
|
||||
string PermissionServGroup = AppSettings.GetValue("ApiGateWay:PermissionServGroup");
|
||||
string PermissionServUrl = AppSettings.GetValue("ApiGateWay:PermissionServUrl");
|
||||
|
||||
string requestdata = await NacosServClient.Cof_NaoceGet(PermissionServName, PermissionServGroup, PermissionServUrl);
|
||||
if (string.IsNullOrEmpty(requestdata)) return null;
|
||||
|
@ -168,7 +168,7 @@ namespace Blog.Core.AuthHelper
|
|||
/// <returns></returns>
|
||||
public bool CheckWhiteList(string url)
|
||||
{
|
||||
List<Urlobj> WhiteList = _cache.Cof_GetICaching<List<Urlobj>>("WhiteList", () => Appsettings.app<Urlobj>("WhiteList"), 10);
|
||||
List<Urlobj> WhiteList = _cache.Cof_GetICaching<List<Urlobj>>("WhiteList", () => AppSettings.app<Urlobj>("WhiteList"), 10);
|
||||
|
||||
if (!WhiteList.Cof_CheckAvailable()) return false;
|
||||
foreach (var Urlitem in WhiteList)
|
||||
|
@ -189,7 +189,7 @@ namespace Blog.Core.AuthHelper
|
|||
|
||||
public bool CheckBlackList(string url)
|
||||
{
|
||||
List<Urlobj> BlackList = _cache.Cof_GetICaching<List<Urlobj>>("BlackList", () => Appsettings.app<Urlobj>("BlackList"), 10);
|
||||
List<Urlobj> BlackList = _cache.Cof_GetICaching<List<Urlobj>>("BlackList", () => AppSettings.app<Urlobj>("BlackList"), 10);
|
||||
|
||||
if (!BlackList.Cof_CheckAvailable()) return false;
|
||||
foreach (var Urlitem in BlackList)
|
||||
|
|
|
@ -46,10 +46,10 @@ namespace ApiGateway.Helper
|
|||
_servClient = serv;
|
||||
nacosConfigListener.internalConfigurationRepo = _internalConfigurationRepo;
|
||||
nacosConfigListener.internalConfigurationCreator = _internalConfigurationCreator;
|
||||
OcelotConfig = Appsettings.GetValue("ApiGateWay:OcelotConfig");
|
||||
OcelotConfigGroup = Appsettings.GetValue("ApiGateWay:OcelotConfigGroup");
|
||||
AppConfig = Appsettings.GetValue("ApiGateWay:AppConfig");
|
||||
AppConfigGroup = Appsettings.GetValue("ApiGateWay:AppConfigGroup");
|
||||
OcelotConfig = AppSettings.GetValue("ApiGateWay:OcelotConfig");
|
||||
OcelotConfigGroup = AppSettings.GetValue("ApiGateWay:OcelotConfigGroup");
|
||||
AppConfig = AppSettings.GetValue("ApiGateWay:AppConfig");
|
||||
AppConfigGroup = AppSettings.GetValue("ApiGateWay:AppConfigGroup");
|
||||
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ namespace ApiGateway.Helper
|
|||
// 当前监听到配置配置 应该重新断开 重连 刷新等一些中间件操作
|
||||
// 比如 mq redis 等其他跟配置相关的中间件
|
||||
JsonConfigSettings.Configuration = configuration;
|
||||
Appsettings.Configuration = configuration;
|
||||
AppSettings.Configuration = configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Blog.Core.AdminMvc
|
|||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(new Appsettings(Configuration));
|
||||
services.AddSingleton(new AppSettings(Configuration));
|
||||
|
||||
services.AddAuthentication_JWTSetup();
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace Blog.Core.AdminMvc
|
|||
|
||||
app.UseCustomSwaggerMildd();
|
||||
|
||||
app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
|
||||
app.UseCors(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
|
|
|
@ -7,7 +7,8 @@ namespace Blog.Core.Model.Models
|
|||
/// <summary>
|
||||
/// 用户信息表
|
||||
/// </summary>
|
||||
[SugarTable("SysUserInfo")]
|
||||
//[SugarTable("SysUserInfo")]
|
||||
[SugarTable("SysUserInfo", "用户表")]//('数据库表名','数据库表备注')
|
||||
public class SysUserInfo : SysUserInfoRoot<int>
|
||||
{
|
||||
public SysUserInfo()
|
||||
|
@ -30,7 +31,11 @@ namespace Blog.Core.Model.Models
|
|||
/// <summary>
|
||||
/// 登录账号
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 200, IsNullable = true)]
|
||||
[SugarColumn(Length = 200, IsNullable = true, ColumnDescription = "登录账号")]
|
||||
//:eg model 根据sqlsugar的完整定义可以如下定义,ColumnDescription可定义表字段备注
|
||||
//[SugarColumn(IsNullable = false, ColumnDescription = "登录账号", IsPrimaryKey = false, IsIdentity = false, ColumnDataType = "nvarchar", Length = 50)]
|
||||
//ColumnDescription 表字段备注, 已在MSSQL测试,配合 [SugarTable("SysUserInfo", "用户表")]//('数据库表名','数据库表备注')
|
||||
//可以完整生成 表备注和各个字段的中文备注
|
||||
public string LoginName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Blog.Core.Repository.Base
|
|||
* 1、在appsettings.json 中开启MutiDBEnabled节点为true,必填
|
||||
* 2、设置一个主连接的数据库ID,节点MainDB,对应的连接字符串的Enabled也必须true,必填
|
||||
*/
|
||||
if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
if (AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool())
|
||||
{
|
||||
//if (typeof(TEntity).GetTypeInfo().GetCustomAttributes(typeof(SugarTable), true).FirstOrDefault((x => x.GetType() == typeof(SugarTable))) is SugarTable sugarTable && !string.IsNullOrEmpty(sugarTable.TableDescription))
|
||||
//{
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace Blog.Core.Repository.MongoRepository
|
|||
|
||||
public MongoDbContext()
|
||||
{
|
||||
var client = new MongoClient(Appsettings.app(new string[] { "Mongo", "ConnectionString" }));
|
||||
_database = client.GetDatabase(Appsettings.app(new string[] { "Mongo", "Database" }));
|
||||
var client = new MongoClient(AppSettings.app(new string[] { "Mongo", "ConnectionString" }));
|
||||
_database = client.GetDatabase(AppSettings.app(new string[] { "Mongo", "Database" }));
|
||||
}
|
||||
|
||||
public IMongoDatabase Db
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace Blog.Core.Tests
|
|||
IServiceCollection services = new ServiceCollection();
|
||||
services.AddAutoMapper(typeof(Startup));
|
||||
|
||||
services.AddSingleton(new Appsettings(basePath));
|
||||
services.AddSingleton(new AppSettings(basePath));
|
||||
services.AddSingleton(new LogLock(basePath));
|
||||
services.AddScoped<DBSeed>();
|
||||
services.AddScoped<MyContext>();
|
||||
|
@ -79,8 +79,8 @@ namespace Blog.Core.Tests
|
|||
"/api/denied",
|
||||
permission,
|
||||
ClaimTypes.Role,
|
||||
Appsettings.app(new string[] { "Audience", "Issuer" }),
|
||||
Appsettings.app(new string[] { "Audience", "Audience" }),
|
||||
AppSettings.app(new string[] { "Audience", "Issuer" }),
|
||||
AppSettings.app(new string[] { "Audience", "Audience" }),
|
||||
signingCredentials,//签名凭据
|
||||
expiration: TimeSpan.FromSeconds(60 * 60)//接口的过期时间
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user