jianghaiqing 9 months ago
commit 5406c55b47

@ -102,7 +102,7 @@ public class RequestActionFilter : IAsyncActionFilter
businessIdList = businessIdList.Distinct();
}
}
var option = new JsonSerializerOptions() { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
await _eventPublisher.PublishAsync(new ChannelEventSource("Create:OpLog", new SysLogOp
{
Name = httpContext.User?.FindFirstValue(ClaimConst.CLAINM_NAME),
@ -115,8 +115,8 @@ public class RequestActionFilter : IAsyncActionFilter
ClassName = context.Controller.ToString(),
MethodName = actionDescriptor?.ActionName,
ReqMethod = httpRequest.Method,
Param = JSON.Serialize(context.ActionArguments.Count < 1 ? "" : context.ActionArguments, option),
Result = actionContext.Result?.GetType() == typeof(JsonResult) ? JSON.Serialize(actionContext.Result, option) : "",
Param = context.ActionArguments.Count < 1 ? "" : context.ActionArguments.ToJsonString(),
Result = actionContext.Result?.GetType() == typeof(JsonResult) ? actionContext.Result.ToJsonString() : "",
ElapsedTime = sw.ElapsedMilliseconds,
OpTime = DateTime.Now,
Account = httpContext.User?.FindFirstValue(ClaimConst.CLAINM_ACCOUNT),

@ -20,7 +20,7 @@ public class OpLogInput : PageInputBase
/// <summary>
/// 是否执行成功Y-是N-否)
/// </summary>
public YesOrNot Success { get; set; }
public YesOrNot? Success { get; set; }
/// <summary>
/// ip

@ -39,15 +39,25 @@ public class SysOpLogService : ISysOpLogService, IDynamicApiController, ITransie
query.InnerJoin<SysLogOpBuss>((o, b) => o.Id == b.LogId)
.Where((o, b) => b.BusinessId == input.BusinessId);
}
var result = await query.Where(o => o.Success == input.Success)
if (!string.IsNullOrWhiteSpace(input.Url))
{
input.Url = input.Url.Trim();
if (!input.Url.StartsWith('/'))
{
input.Url = $"/{input.Url}";
}
}
var result = await query.Where(o => o.Id > 0) // 如果没有Id > 0这个条件SELECT Count(*) FROM `sys_log_op` 会执行很长时间,最后报错
.WhereIF(input.Success != null, o => o.Success == input.Success)
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), o => o.Name.Contains(input.Name.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Ip), o => o.Ip == input.Ip.Trim())
.WhereIF(!string.IsNullOrWhiteSpace(input.Url), o => o.Url == input.Url.Trim())
.WhereIF(!string.IsNullOrWhiteSpace(input.Url), o => o.Url == input.Url)
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchBeginTime), o => o.OpTime >= DateTime.Parse(input.SearchBeginTime.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchEndTime), o => o.OpTime <= DateTime.Parse(input.SearchEndTime.Trim()))
.OrderByIF(input.SortField == "opTime", o => o.Id, input.DescSort ? OrderByType.Desc : OrderByType.Asc)
.OrderByIF(input.SortField == "ip", o => o.Ip, input.DescSort ? OrderByType.Desc : OrderByType.Asc)
.OrderByIF(input.SortField == "name", o => o.Name, input.DescSort ? OrderByType.Desc : OrderByType.Asc)
.OrderByIF(string.IsNullOrWhiteSpace(input.SortField) || string.Equals(input.SortField, "opTime", StringComparison.OrdinalIgnoreCase), o => o.Id, input.DescSort ? OrderByType.Desc : OrderByType.Asc)
//.OrderByIF(input.SortField == "name", o => o.Name, input.DescSort ? OrderByType.Desc : OrderByType.Asc)
//.OrderByIF(input.SortField == "ip", o => o.Ip, input.DescSort ? OrderByType.Desc : OrderByType.Asc)
.Select(o => new OpLogPageListDto()
{
Id = o.Id,

Loading…
Cancel
Save