优化全局过滤器日志记录
This commit is contained in:
@@ -6,8 +6,10 @@ using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using UAParser;
|
||||
@@ -161,6 +163,32 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
});
|
||||
}).Wait();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置请求参数
|
||||
/// </summary>
|
||||
/// <param name="operLog"></param>
|
||||
/// <param name="context"></param>
|
||||
public static void GetRequestValue(this HttpContext context, SysOperLog operLog)
|
||||
{
|
||||
string reqMethod = operLog.requestMethod;
|
||||
string param;
|
||||
|
||||
if (HttpMethods.IsPost(reqMethod) || HttpMethods.IsPut(reqMethod))
|
||||
{
|
||||
context.Request.Body.Seek(0, SeekOrigin.Begin);
|
||||
using var reader = new StreamReader(context.Request.Body, Encoding.UTF8);
|
||||
//需要使用异步方式才能获取
|
||||
param = reader.ReadToEndAsync().Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
param = context.Request.QueryString.Value.ToString();
|
||||
}
|
||||
operLog.operParam = param;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user