修改swagger首页

This commit is contained in:
2023-03-16 09:17:36 +08:00
parent a4ed390e82
commit b03cd609ac
5 changed files with 164 additions and 44 deletions

View File

@@ -43,23 +43,22 @@ public class RequestActionFilter : IAsyncActionFilter
UserAgent userAgent = new UserAgent(httpContext);
var actionDes = (ControllerActionDescriptor)context.ActionDescriptor;
var actionName = $"{actionDes.ControllerTypeInfo.FullName}.{actionDes.MethodInfo.Name}";
var ignoreLog = actionDes.EndpointMetadata.Any(m => m.GetType() == typeof(IgnoreLogAttribute));
Stopwatch sw = new Stopwatch();
Log.Information("Action Starting: {0}({1})", actionName, context.ActionArguments.ToJsonString());
if (!ignoreLog) Log.Information("Action Starting: {0}({1})", actionName, context.ActionArguments.ToJsonString());
sw.Start();
var actionContext = await next();
sw.Stop();
Log.Information("Action Finished: {0}() - Elapsed: {1:F2}ms", actionName, sw.ElapsedMilliseconds);
// 判断是否请求成功(没有异常就是请求成功)
var isRequestSucceed = actionContext.Exception == null;
var headers = httpRequest.Headers;
if (!context.ActionDescriptor.EndpointMetadata.Any(m => m.GetType() == typeof(IgnoreLogAttribute)))
//var headers = httpRequest.Headers;
if (!ignoreLog && isRequestSucceed)
{
Log.Information("Action Finished: {0}() - Elapsed: {1:F2}ms", actionName, sw.ElapsedMilliseconds);
ConnectionConfigOptions options = userContext?.FindFirstValue(ClaimConst.CONNECTIONCONFIG)?.ToObject<ConnectionConfigOptions>();
var userId = userContext?.FindFirstValue(ClaimConst.CLAINMUSERID);
var userName = userContext?.FindFirstValue(ClaimConst.CLAINMREALNAME);
if (!App.HttpContext.Request.Headers.ContainsKey("Authorization"))
{
var bearer = App.HttpContext.Request.QueryString.Value.Matches(@"[?&]token=Bearer%20([\w\.-]+)($|&)");
@@ -87,12 +86,12 @@ public class RequestActionFilter : IAsyncActionFilter
CreatorTime = DateTime.Now
}));
if (context.ActionDescriptor.EndpointMetadata.Any(m => m.GetType() == typeof(OperateLogAttribute)))
var module = actionDes.EndpointMetadata.Where(x => x.GetType() == typeof(OperateLogAttribute)).FirstOrDefault() as OperateLogAttribute;
if (module != null)
{
// 操作参数
var args = context.ActionArguments.ToJsonString();
var result = (actionContext.Result as JsonResult)?.Value;
var module = context.ActionDescriptor.EndpointMetadata.Where(x => x.GetType() == typeof(OperateLogAttribute)).ToList().FirstOrDefault() as OperateLogAttribute;
await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", options, new SysLogEntity
{