日志记录新增加参数
This commit is contained in:
parent
4aaf73bad7
commit
c4bda3df7d
@ -9,6 +9,14 @@ namespace Infrastructure.Attribute
|
|||||||
{
|
{
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public BusinessType BusinessType { get; set; }
|
public BusinessType BusinessType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否保存请求数据
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSaveRequestData { get; set; } = true;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否保存返回数据
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSaveResponseData { get; set; } = true;
|
||||||
|
|
||||||
public LogAttribute() { }
|
public LogAttribute() { }
|
||||||
|
|
||||||
@ -16,10 +24,12 @@ namespace Infrastructure.Attribute
|
|||||||
{
|
{
|
||||||
Title = name;
|
Title = name;
|
||||||
}
|
}
|
||||||
public LogAttribute(string name, BusinessType businessType)
|
public LogAttribute(string name, BusinessType businessType, bool saveRequestData = true, bool saveResponseData = true)
|
||||||
{
|
{
|
||||||
Title = name;
|
Title = name;
|
||||||
BusinessType = businessType;
|
BusinessType = businessType;
|
||||||
|
IsSaveRequestData = saveRequestData;
|
||||||
|
IsSaveResponseData = saveResponseData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,13 +69,15 @@ namespace ZR.Admin.WebApi.Filters
|
|||||||
//Elapsed = _stopwatch.ElapsedMilliseconds,
|
//Elapsed = _stopwatch.ElapsedMilliseconds,
|
||||||
operTime = DateTime.Now
|
operTime = DateTime.Now
|
||||||
};
|
};
|
||||||
|
GetRequestValue(sysOperLog, context.HttpContext);
|
||||||
|
|
||||||
if (logAttribute != null)
|
if (logAttribute != null)
|
||||||
{
|
{
|
||||||
sysOperLog.title = logAttribute?.Title;
|
sysOperLog.title = logAttribute?.Title;
|
||||||
sysOperLog.businessType = (int)logAttribute?.BusinessType;
|
sysOperLog.businessType = (int)logAttribute?.BusinessType;
|
||||||
|
sysOperLog.operParam = logAttribute.IsSaveRequestData ? sysOperLog.operParam : "";
|
||||||
|
sysOperLog.jsonResult = logAttribute.IsSaveResponseData ? sysOperLog.jsonResult : "";
|
||||||
}
|
}
|
||||||
GetRequestValue(sysOperLog, context.HttpContext);
|
|
||||||
|
|
||||||
var sysOperLogService = (ISysOperLogService)App.GetRequiredService(typeof(ISysOperLogService));
|
var sysOperLogService = (ISysOperLogService)App.GetRequiredService(typeof(ISysOperLogService));
|
||||||
|
|
||||||
sysOperLogService.InsertOperlog(sysOperLog);
|
sysOperLogService.InsertOperlog(sysOperLog);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user