mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 20:03:26 +08:00
# 2022-04-10
### 1.4.4开源社区版: 无 ### 0.3.5 专业版: 【新增】增加用户操作日志,可记录接口也可记录后台,同时支持本地存储或数据库存储。支持配置文件开启。 【新增】数据库增加用户操作日志表。 【优化】优化反射获取所有Controller 和Action的全局方法,增加缓存设置。 【优化】优化记录IP请求数据的中间件。 【修复】修复ios下用户充值余额的功能不显示的情况。 【修复】修复我的余额面板列表中右侧三角无反应的问题。 【修复】修复代理中心下线人数和订单数量统计错误的问题。#I51OUC
This commit is contained in:
@@ -96,6 +96,15 @@ namespace CoreCms.Net.Configuration
|
|||||||
/// 用户访问记录-过滤ip
|
/// 用户访问记录-过滤ip
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string MiddlewareRecordAccessLogsIgnoreApis = AppSettingsHelper.GetContent("Middleware", "RecordAccessLogs", "IgnoreApis");
|
public static readonly string MiddlewareRecordAccessLogsIgnoreApis = AppSettingsHelper.GetContent("Middleware", "RecordAccessLogs", "IgnoreApis");
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启记录到文件模式
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool MiddlewareRecordAccessLogsEnabledFileMode = AppSettingsHelper.GetContent("Middleware", "RecordAccessLogs", "EnabledFileMode").ObjToBool();
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启记录到数据库模式
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool MiddlewareRecordAccessLogsEnabledDbMode = AppSettingsHelper.GetContent("Middleware", "RecordAccessLogs", "EnabledDbMode").ObjToBool();
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,22 @@ namespace CoreCms.Net.Configuration
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系统常用枚举类
|
/// 系统常用枚举类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GlobalEnumVars
|
public static class GlobalEnumVars
|
||||||
{
|
{
|
||||||
#region 系统相关===============================================================
|
#region 系统相关===============================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 多端划分
|
||||||
|
/// </summary>
|
||||||
|
public enum CoreShopSystemCategory
|
||||||
|
{
|
||||||
|
Admin = 0,
|
||||||
|
Api = 1,
|
||||||
|
Pc = 2,
|
||||||
|
H5 = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存优先级:低、普通、高、永不移除
|
/// 缓存优先级:低、普通、高、永不移除
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -15,46 +15,58 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using CoreCms.Net.Caching.Manual;
|
||||||
|
using CoreCms.Net.Caching.MemoryCache;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
|
||||||
namespace CoreCms.Net.Filter
|
namespace CoreCms.Net.Filter
|
||||||
{
|
{
|
||||||
public class AdminsControllerPermission
|
public static class AdminsControllerPermission
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存ActionPermission名称
|
||||||
|
/// </summary>
|
||||||
|
private const string CacheCoreCmsActionPermission = "CacheCoreCmsActionPermission";
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存ControllerPermission名称
|
||||||
|
/// </summary>
|
||||||
|
private const string CacheCoreCmsControllerPermission = "CacheCoreCmsControllerPermission";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 反射获取所有controller 和action
|
/// 反射获取所有controller 和action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static List<ControllerPermission> GetAllControllerAndActionByAssembly()
|
private static ControllerPermissionResult GetAllControllerAndActionByAssembly()
|
||||||
{
|
{
|
||||||
|
|
||||||
var result = new List<ControllerPermission>();
|
var result = new List<ControllerPermission>();
|
||||||
|
|
||||||
var types = Assembly.Load("CoreCms.Net.Web.Admin").GetTypes();
|
var types = Assembly.Load("CoreCms.Net.Web.Admin").GetTypes();
|
||||||
|
|
||||||
|
|
||||||
var noController = new[] { "ToolsController", "LoginController", "DemoController" };
|
var noController = new[] { "ToolsController", "LoginController", "DemoController" };
|
||||||
|
|
||||||
|
var acs = new List<ActionPermission>();
|
||||||
|
|
||||||
var controllers = types.Where(p => p.Name.Contains("Controller") && !noController.Contains(p.Name));
|
var controllers = types.Where(p => p.Name.Contains("Controller") && !noController.Contains(p.Name));
|
||||||
foreach (var type in controllers)
|
foreach (var type in controllers)
|
||||||
{
|
{
|
||||||
if (type.Name.Length > 10 && type.BaseType.Name == "ControllerBase" && type.Name.EndsWith("Controller")) //如果是Controller
|
if (type.BaseType != null && (type.Name.Length <= 10 || type.BaseType.Name != "ControllerBase" || !type.Name.EndsWith("Controller"))) continue;
|
||||||
{
|
|
||||||
var members = type.GetMethods();
|
var members = type.GetMethods();
|
||||||
var cp = new ControllerPermission
|
var cp = new ControllerPermission();
|
||||||
{
|
cp.name = type.Name.Substring(0, type.Name.Length - 10);
|
||||||
name = type.Name.Substring(0, type.Name.Length - 10),
|
cp.action = new List<ActionPermission>();
|
||||||
action = new List<ActionPermission>()
|
cp.controllerName = cp.name;
|
||||||
};
|
|
||||||
|
|
||||||
var objs = type.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
var objs = type.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
||||||
if (objs.Length > 0) cp.description = (objs[0] as DescriptionAttribute).Description;
|
if (objs.Length > 0) cp.description = (objs[0] as DescriptionAttribute)?.Description;
|
||||||
|
//附加此代码用于代码生成器显示选择
|
||||||
if (!string.IsNullOrEmpty(cp.description))
|
if (!string.IsNullOrEmpty(cp.description))
|
||||||
{
|
{
|
||||||
cp.name += "【" + cp.description + "】";
|
cp.name += "【" + cp.description + "】";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var newMembers = members.Where(p =>
|
var newMembers = members.Where(p =>
|
||||||
p.ReturnType.FullName != null && (p.ReturnType.Name == "ActionResult" ||
|
p.ReturnType.FullName != null && (p.ReturnType.Name == "ActionResult" ||
|
||||||
p.ReturnType.Name == "FileResult" ||
|
p.ReturnType.Name == "FileResult" ||
|
||||||
@@ -73,30 +85,38 @@ namespace CoreCms.Net.Filter
|
|||||||
//{
|
//{
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
var ap = new ActionPermission();
|
||||||
var ap = new ActionPermission
|
ap.name = member.Name;
|
||||||
|
ap.actionName = member.Name;
|
||||||
|
if (member.DeclaringType != null)
|
||||||
{
|
{
|
||||||
name = member.Name,
|
|
||||||
actionName = member.Name,
|
|
||||||
controllerName = member.DeclaringType.Name.Substring(0, member.DeclaringType.Name.Length - 10)
|
|
||||||
};
|
|
||||||
// 去掉“Controller”后缀
|
// 去掉“Controller”后缀
|
||||||
|
ap.controllerName = member.DeclaringType.Name.Substring(0, member.DeclaringType.Name.Length - 10);
|
||||||
|
}
|
||||||
|
ap.path = "/Api/" + ap.controllerName + "/" + member.Name;
|
||||||
|
|
||||||
var attrs = member.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
var attrs = member.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
||||||
if (attrs.Length > 0) ap.description = (attrs[0] as DescriptionAttribute).Description;
|
if (attrs.Length > 0) ap.description = (attrs[0] as DescriptionAttribute)?.Description;
|
||||||
|
//附加此代码用于代码生成器显示选择
|
||||||
if (!string.IsNullOrEmpty(ap.description))
|
if (!string.IsNullOrEmpty(ap.description))
|
||||||
{
|
{
|
||||||
ap.name += "【" + ap.description + "】";
|
ap.name += "【" + ap.description + "】";
|
||||||
}
|
}
|
||||||
cp.action.Add(ap);
|
ap.controllerDescription = cp.description;
|
||||||
|
|
||||||
|
cp.action.Add(ap);
|
||||||
|
acs.Add(ap);
|
||||||
}
|
}
|
||||||
cp.action = cp.action.Distinct(new ModelComparer()).ToList();
|
cp.action = cp.action.Distinct(new ModelComparer()).ToList();
|
||||||
result.Add(cp);
|
result.Add(cp);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
var resultObj = new ControllerPermissionResult
|
||||||
|
{
|
||||||
|
ControllersAndActions = result,
|
||||||
|
Actions = acs
|
||||||
|
};
|
||||||
|
return resultObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ModelComparer : IEqualityComparer<ActionPermission>
|
private class ModelComparer : IEqualityComparer<ActionPermission>
|
||||||
@@ -111,46 +131,132 @@ namespace CoreCms.Net.Filter
|
|||||||
return obj.name.ToUpper().GetHashCode();
|
return obj.name.ToUpper().GetHashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存ActionPermission
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<ActionPermission> GetCacheCoreCmsActionPermission()
|
||||||
|
{
|
||||||
|
var memoryCacheManager = new MemoryCacheManager();
|
||||||
|
var cache = memoryCacheManager.Get<List<ActionPermission>>(CacheCoreCmsActionPermission);
|
||||||
|
return cache ?? UpdateCacheCoreCmsActionPermission().Actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存ControllerPermission名称
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<ControllerPermission> GetCacheCoreCmsControllerPermission()
|
||||||
|
{
|
||||||
|
var memoryCacheManager = new MemoryCacheManager();
|
||||||
|
var cache = memoryCacheManager.Get<List<ControllerPermission>>(CacheCoreCmsControllerPermission);
|
||||||
|
return cache ?? UpdateCacheCoreCmsActionPermission().ControllersAndActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
private static ControllerPermissionResult UpdateCacheCoreCmsActionPermission()
|
||||||
|
{
|
||||||
|
var list = GetAllControllerAndActionByAssembly();
|
||||||
|
var memoryCacheManager = new MemoryCacheManager();
|
||||||
|
//缓存24小时
|
||||||
|
memoryCacheManager.Set(CacheCoreCmsControllerPermission, list.ControllersAndActions, 1440);
|
||||||
|
memoryCacheManager.Set(CacheCoreCmsActionPermission, list.Actions, 1440);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
public class ActionPermission
|
/// 外部包一圈
|
||||||
|
/// </summary>
|
||||||
|
public class ControllerPermissionResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求地址
|
/// 实际结果集
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string name { get; set; }
|
public List<ControllerPermission> ControllersAndActions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求地址
|
/// 只获取的action集合,用于缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string controllerName { get; set; }
|
public List<ActionPermission> Actions { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求地址
|
/// action数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string actionName { get; set; }
|
public sealed class ActionPermission
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 地址
|
||||||
|
/// </summary>
|
||||||
|
public string path { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 地址及描述
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制器
|
||||||
|
/// </summary>
|
||||||
|
public string controllerName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制器描述
|
||||||
|
/// </summary>
|
||||||
|
public string controllerDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 方法
|
||||||
|
/// </summary>
|
||||||
|
public string actionName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述
|
/// 描述
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string description { get; set; }
|
public string description { get; set; }
|
||||||
|
|
||||||
public virtual string type { get; set; } = "action";
|
/// <summary>
|
||||||
|
/// 类型
|
||||||
|
/// </summary>
|
||||||
|
public string type { get; set; } = "action";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ControllerPermission
|
/// <summary>
|
||||||
|
/// Controller数据
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ControllerPermission
|
||||||
{
|
{
|
||||||
public virtual string name { get; set; }
|
/// <summary>
|
||||||
|
/// 控制器
|
||||||
|
/// </summary>
|
||||||
|
public string controllerName { get; set; }
|
||||||
|
|
||||||
public virtual string description { get; set; }
|
/// <summary>
|
||||||
|
/// 控制器和描述
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
public virtual IList<ActionPermission> action { get; set; }
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
public string description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 方法列表
|
||||||
|
/// </summary>
|
||||||
|
public IList<ActionPermission> action { get; set; }
|
||||||
|
|
||||||
public virtual string type { get; set; } = "controller";
|
/// <summary>
|
||||||
|
/// 类型
|
||||||
|
/// </summary>
|
||||||
|
public string type { get; set; } = "controller";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Caching\CoreCms.Net.Caching.csproj" />
|
||||||
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
||||||
<ProjectReference Include="..\CoreCms.Net.Model\CoreCms.Net.Model.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.Model\CoreCms.Net.Model.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2022/4/10 0:27:47
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户操作日志 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ISysUserOperationLogRepository : IBaseRepository<SysUserOperationLog>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<SysUserOperationLog>> QueryPageAsync(
|
||||||
|
Expression<Func<SysUserOperationLog, bool>> predicate,
|
||||||
|
Expression<Func<SysUserOperationLog, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
44
CoreCms.Net.IServices/System/ISysUserOperationLogServices.cs
Normal file
44
CoreCms.Net.IServices/System/ISysUserOperationLogServices.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2022/4/10 0:27:47
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户操作日志 服务工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ISysUserOperationLogServices : IBaseServices<SysUserOperationLog>
|
||||||
|
{
|
||||||
|
#region 重写根据条件查询分页数据
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<SysUserOperationLog>> QueryPageAsync(
|
||||||
|
Expression<Func<SysUserOperationLog, bool>> predicate,
|
||||||
|
Expression<Func<SysUserOperationLog, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
<ProjectReference Include="..\CoreCms.Net.Auth\CoreCms.Net.Auth.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.Auth\CoreCms.Net.Auth.csproj" />
|
||||||
<ProjectReference Include="..\CoreCms.Net.Configuration\CoreCms.Net.Configuration.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.Configuration\CoreCms.Net.Configuration.csproj" />
|
||||||
<ProjectReference Include="..\CoreCms.Net.Core\CoreCms.Net.Core.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.Core\CoreCms.Net.Core.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Filter\CoreCms.Net.Filter.csproj" />
|
||||||
<ProjectReference Include="..\CoreCms.Net.IServices\CoreCms.Net.IServices.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.IServices\CoreCms.Net.IServices.csproj" />
|
||||||
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
||||||
<ProjectReference Include="..\CoreCms.Net.Utility\CoreCms.Net.Utility.csproj" />
|
<ProjectReference Include="..\CoreCms.Net.Utility\CoreCms.Net.Utility.csproj" />
|
||||||
|
|||||||
@@ -13,18 +13,16 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CoreCms.Net.Loging;
|
using CoreCms.Net.Loging;
|
||||||
using CoreCms.Net.Model.ViewModels.UI;
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Middlewares;
|
||||||
|
|
||||||
namespace CoreCms.Net.Middlewares
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异常错误统一返回记录
|
/// 异常错误统一返回记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -52,14 +50,14 @@ namespace CoreCms.Net.Middlewares
|
|||||||
private async Task HandleExceptionAsync(HttpContext context, Exception ex)
|
private async Task HandleExceptionAsync(HttpContext context, Exception ex)
|
||||||
{
|
{
|
||||||
if (ex == null) return;
|
if (ex == null) return;
|
||||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex));
|
NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex));
|
||||||
await WriteExceptionAsync(context, ex).ConfigureAwait(false);
|
await WriteExceptionAsync(context, ex).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task WriteExceptionAsync(HttpContext context, Exception e)
|
private static async Task WriteExceptionAsync(HttpContext context, Exception e)
|
||||||
{
|
{
|
||||||
if (e is UnauthorizedAccessException) context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
if (e is UnauthorizedAccessException) context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||||
else if (e is Exception) context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
else if (e != null) context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
|
||||||
context.Response.ContentType = "application/json";
|
context.Response.ContentType = "application/json";
|
||||||
var jm = new AdminUiCallBack();
|
var jm = new AdminUiCallBack();
|
||||||
@@ -69,4 +67,3 @@ namespace CoreCms.Net.Middlewares
|
|||||||
await context.Response.WriteAsync(JsonConvert.SerializeObject(jm)).ConfigureAwait(false);
|
await context.Response.WriteAsync(JsonConvert.SerializeObject(jm)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,21 +13,16 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CoreCms.Net.IServices;
|
|
||||||
using CoreCms.Net.Loging;
|
using CoreCms.Net.Loging;
|
||||||
using CoreCms.Net.Model.Entities;
|
|
||||||
using CoreCms.Net.Model.ViewModels.UI;
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Net.Http.Headers;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Middlewares;
|
||||||
|
|
||||||
namespace CoreCms.Net.Middlewares
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异常错误统一返回记录
|
/// 异常错误统一返回记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -57,7 +52,7 @@ namespace CoreCms.Net.Middlewares
|
|||||||
{
|
{
|
||||||
if (ex == null) return;
|
if (ex == null) return;
|
||||||
|
|
||||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.ApiRequest, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex));
|
NLogUtil.WriteAll(LogLevel.Error, LogType.ApiRequest, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex));
|
||||||
|
|
||||||
await WriteExceptionAsync(context, ex).ConfigureAwait(false);
|
await WriteExceptionAsync(context, ex).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -66,7 +61,7 @@ namespace CoreCms.Net.Middlewares
|
|||||||
{
|
{
|
||||||
if (e is UnauthorizedAccessException)
|
if (e is UnauthorizedAccessException)
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||||
else if (e is Exception)
|
else if (e != null)
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
|
||||||
context.Response.ContentType = "application/json";
|
context.Response.ContentType = "application/json";
|
||||||
@@ -78,4 +73,3 @@ namespace CoreCms.Net.Middlewares
|
|||||||
await context.Response.WriteAsync(JsonConvert.SerializeObject(jm)).ConfigureAwait(false);
|
await context.Response.WriteAsync(JsonConvert.SerializeObject(jm)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ namespace CoreCms.Net.Middlewares
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(requestInfo))
|
if (!string.IsNullOrEmpty(requestInfo))
|
||||||
{
|
{
|
||||||
Parallel.For(0, 1, e =>
|
Parallel.For(0, 1, _ =>
|
||||||
{
|
{
|
||||||
LogLockHelper.OutSql2Log("RequestIpInfoLog", "RequestIpInfoLog" + dt.ToString("yyyy-MM-dd-HH"), new string[] { requestInfo + "," }, false);
|
LogLockHelper.OutSql2Log("RequestIpInfoLog", "RequestIpInfoLog" + dt.ToString("yyyy-MM-dd-HH"), new[] { requestInfo + "," }, false);
|
||||||
});
|
});
|
||||||
request.Body.Position = 0;
|
request.Body.Position = 0;
|
||||||
}
|
}
|
||||||
@@ -77,6 +77,7 @@ namespace CoreCms.Net.Middlewares
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
// ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -95,10 +96,7 @@ namespace CoreCms.Net.Middlewares
|
|||||||
var ip = context.Request.Headers["X-Forwarded-For"].ObjectToString();
|
var ip = context.Request.Headers["X-Forwarded-For"].ObjectToString();
|
||||||
if (string.IsNullOrEmpty(ip))
|
if (string.IsNullOrEmpty(ip))
|
||||||
{
|
{
|
||||||
if (context.Connection.RemoteIpAddress != null)
|
ip = context.Connection.RemoteIpAddress.ObjectToString();
|
||||||
{
|
|
||||||
ip = context.Connection.RemoteIpAddress.MapToIPv4().ObjectToString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,10 +78,11 @@ namespace CoreCms.Net.Middlewares
|
|||||||
/// 用户访问接口日志中间件
|
/// 用户访问接口日志中间件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="app"></param>
|
/// <param name="app"></param>
|
||||||
|
/// <param name="dataSources"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IApplicationBuilder UseRecordAccessLogsMildd(this IApplicationBuilder app)
|
public static IApplicationBuilder UseRecordAccessLogsMildd(this IApplicationBuilder app,string dataSources)
|
||||||
{
|
{
|
||||||
return app.UseMiddleware<RecordAccessLogsMildd>();
|
return app.UseMiddleware<RecordAccessLogsMildd>(dataSources);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,24 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using CoreCms.Net.Auth.HttpContextUser;
|
|
||||||
using CoreCms.Net.Configuration;
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Filter;
|
||||||
|
using CoreCms.Net.IServices;
|
||||||
using CoreCms.Net.Loging;
|
using CoreCms.Net.Loging;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
using CoreCms.Net.Utility.Extensions;
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
|
||||||
namespace CoreCms.Net.Middlewares
|
namespace CoreCms.Net.Middlewares
|
||||||
{
|
{
|
||||||
@@ -21,103 +30,143 @@ namespace CoreCms.Net.Middlewares
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RecordAccessLogsMildd
|
public class RecordAccessLogsMildd
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
private readonly RequestDelegate _next;
|
private readonly RequestDelegate _next;
|
||||||
private readonly IHttpContextUser _user;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
private readonly ISysUserOperationLogServices _sysUserOperationLogServices;
|
||||||
|
|
||||||
private readonly ILogger<RecordAccessLogsMildd> _logger;
|
|
||||||
private readonly Stopwatch _stopwatch;
|
private readonly Stopwatch _stopwatch;
|
||||||
|
|
||||||
|
private readonly string _dataSources;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造
|
/// 构造
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="next"></param>
|
public RecordAccessLogsMildd(RequestDelegate next, IHttpContextAccessor httpContextAccessor, ISysUserOperationLogServices sysUserOperationLogServices, string dataSources)
|
||||||
/// <param name="user"></param>
|
|
||||||
/// <param name="logger"></param>
|
|
||||||
public RecordAccessLogsMildd(RequestDelegate next, IHttpContextUser user, ILogger<RecordAccessLogsMildd> logger)
|
|
||||||
{
|
{
|
||||||
_next = next;
|
_next = next;
|
||||||
_user = user;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
_logger = logger;
|
_dataSources = dataSources;
|
||||||
|
_sysUserOperationLogServices = sysUserOperationLogServices;
|
||||||
_stopwatch = new Stopwatch();
|
_stopwatch = new Stopwatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InvokeAsync(HttpContext context)
|
public async Task InvokeAsync(HttpContext context)
|
||||||
{
|
{
|
||||||
if (AppSettingsConstVars.MiddlewareRecordAccessLogsEnabled)
|
//用户访问记录-是否开启
|
||||||
|
var middlewareRecordAccessLogsEnabled = AppSettingsConstVars.MiddlewareRecordAccessLogsEnabled;
|
||||||
|
//是否开启记录到文件模式
|
||||||
|
var middlewareRecordAccessLogsEnabledFileMode = AppSettingsConstVars.MiddlewareRecordAccessLogsEnabledFileMode;
|
||||||
|
//是否开启记录到数据库模式
|
||||||
|
var middlewareRecordAccessLogsEnabledDbMode = AppSettingsConstVars.MiddlewareRecordAccessLogsEnabledDbMode;
|
||||||
|
|
||||||
|
if (middlewareRecordAccessLogsEnabled && (middlewareRecordAccessLogsEnabledFileMode || middlewareRecordAccessLogsEnabledDbMode))
|
||||||
{
|
{
|
||||||
var api = context.Request.Path.ObjectToString().TrimEnd('/').ToLower();
|
var request = context.Request;
|
||||||
|
var api = request.Path.ObjectToString().TrimEnd('/').ToLower();
|
||||||
var ignoreApis = AppSettingsConstVars.MiddlewareRecordAccessLogsIgnoreApis;
|
var ignoreApis = AppSettingsConstVars.MiddlewareRecordAccessLogsIgnoreApis;
|
||||||
|
|
||||||
// 过滤,只有接口
|
// 过滤,只有接口
|
||||||
if (api.Contains("api") && !ignoreApis.Contains(api))
|
if (api.Contains("api") && !ignoreApis.ToLower().Contains(api))
|
||||||
{
|
{
|
||||||
_stopwatch.Restart();
|
_stopwatch.Restart();
|
||||||
var userAccessModel = new UserAccessModel();
|
var uLog = new SysUserOperationLog();
|
||||||
|
|
||||||
HttpRequest request = context.Request;
|
if (_httpContextAccessor.HttpContext != null)
|
||||||
|
{
|
||||||
|
var authenticate = await _httpContextAccessor.HttpContext.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme);
|
||||||
|
if (authenticate.Succeeded && authenticate.Principal != null)
|
||||||
|
{
|
||||||
|
//账号
|
||||||
|
uLog.userName = authenticate.Principal.Identities.First().FindFirst(ClaimTypes.Name)?.Value;
|
||||||
|
//昵称
|
||||||
|
uLog.userNickName = authenticate.Principal.Identities.First().FindFirst(ClaimTypes.GivenName)?.Value;
|
||||||
|
//用户序列
|
||||||
|
uLog.userId = authenticate.Principal.Identities.First().FindFirst(JwtRegisteredClaimNames.Jti)!.Value.ObjectToInt(0);
|
||||||
|
}
|
||||||
|
|
||||||
userAccessModel.API = api;
|
var adminLog = AdminsControllerPermission.GetCacheCoreCmsActionPermission();
|
||||||
userAccessModel.User = _user.Name;
|
|
||||||
userAccessModel.IP = IPLogMildd.GetClientIp(context);
|
|
||||||
userAccessModel.BeginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
||||||
userAccessModel.RequestMethod = request.Method;
|
|
||||||
userAccessModel.Agent = request.Headers["User-Agent"].ObjectToString();
|
|
||||||
|
|
||||||
|
var curLog = adminLog.FirstOrDefault(p => p.path.ToLower() == _httpContextAccessor.HttpContext.Request.Path.Value.ToLower());
|
||||||
|
if (curLog != null)
|
||||||
|
{
|
||||||
|
uLog.actionName = curLog.actionName;
|
||||||
|
uLog.actionDescription = curLog.description;
|
||||||
|
uLog.controllerName = curLog.controllerName;
|
||||||
|
uLog.controllerDescription = curLog.controllerDescription;
|
||||||
|
}
|
||||||
|
uLog.apiPath = _httpContextAccessor.HttpContext.Request.Path.Value;
|
||||||
|
uLog.statusCode = _httpContextAccessor.HttpContext.Response.StatusCode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uLog.apiPath = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
uLog.ip = IPLogMildd.GetClientIp(context);
|
||||||
|
uLog.beginTime = DateTime.Now;
|
||||||
|
uLog.requestMethod = request.Method;
|
||||||
|
uLog.agent = request.Headers["User-Agent"].ObjectToString();
|
||||||
|
uLog.dataSources = _dataSources;
|
||||||
|
|
||||||
|
switch (request.Method.ToLower())
|
||||||
|
{
|
||||||
// 获取请求body内容
|
// 获取请求body内容
|
||||||
if (request.Method.ToLower().Equals("post") || request.Method.ToLower().Equals("put"))
|
case "post":
|
||||||
|
case "put":
|
||||||
{
|
{
|
||||||
// 启用倒带功能,就可以让 Request.Body 可以再次读取
|
// 启用倒带功能,就可以让 Request.Body 可以再次读取
|
||||||
request.EnableBuffering();
|
request.EnableBuffering();
|
||||||
|
var stream = request.Body;
|
||||||
Stream stream = request.Body;
|
if (request.ContentLength != null)
|
||||||
byte[] buffer = new byte[request.ContentLength.Value];
|
|
||||||
stream.Read(buffer, 0, buffer.Length);
|
|
||||||
userAccessModel.RequestData = Encoding.UTF8.GetString(buffer);
|
|
||||||
|
|
||||||
request.Body.Position = 0;
|
|
||||||
}
|
|
||||||
else if (request.Method.ToLower().Equals("get") || request.Method.ToLower().Equals("delete"))
|
|
||||||
{
|
{
|
||||||
userAccessModel.RequestData = HttpUtility.UrlDecode(request.QueryString.ObjectToString(), Encoding.UTF8);
|
byte[] buffer = new byte[request.ContentLength.Value];
|
||||||
|
var read = await stream.ReadAsync(buffer);
|
||||||
|
uLog.requestData = Encoding.UTF8.GetString(buffer);
|
||||||
|
}
|
||||||
|
request.Body.Position = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "get":
|
||||||
|
case "delete":
|
||||||
|
uLog.requestData = HttpUtility.UrlDecode(request.QueryString.ObjectToString(), Encoding.UTF8);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取Response.Body内容
|
// 获取Response.Body内容
|
||||||
var originalBodyStream = context.Response.Body;
|
var originalBodyStream = context.Response.Body;
|
||||||
using (var responseBody = new MemoryStream())
|
await using (var responseBody = new MemoryStream())
|
||||||
{
|
{
|
||||||
context.Response.Body = responseBody;
|
context.Response.Body = responseBody;
|
||||||
|
|
||||||
await _next(context);
|
await _next(context);
|
||||||
|
uLog.responseBodyData = await GetResponse(context.Response);
|
||||||
var responseBodyData = await GetResponse(context.Response);
|
|
||||||
|
|
||||||
await responseBody.CopyToAsync(originalBodyStream);
|
await responseBody.CopyToAsync(originalBodyStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var dt = DateTime.Now;
|
|
||||||
|
|
||||||
// 响应完成记录时间和存入日志
|
// 响应完成记录时间和存入日志
|
||||||
context.Response.OnCompleted(() =>
|
context.Response.OnCompleted(async () =>
|
||||||
{
|
{
|
||||||
_stopwatch.Stop();
|
_stopwatch.Stop();
|
||||||
|
|
||||||
userAccessModel.OPTime = _stopwatch.ElapsedMilliseconds + "ms";
|
uLog.opTime = _stopwatch.ElapsedMilliseconds + "ms";
|
||||||
|
uLog.endTime = DateTime.Now;
|
||||||
|
uLog.createTime = DateTime.Now;
|
||||||
|
//写入文件
|
||||||
|
if (middlewareRecordAccessLogsEnabledFileMode)
|
||||||
|
{
|
||||||
// 自定义log输出
|
// 自定义log输出
|
||||||
var requestInfo = JsonConvert.SerializeObject(userAccessModel);
|
var requestInfo = JsonConvert.SerializeObject(uLog);
|
||||||
Parallel.For(0, 1, e =>
|
Parallel.For(0, 1, e =>
|
||||||
{
|
{
|
||||||
LogLockHelper.OutSql2Log("RecordAccessLogs", "RecordAccessLogs" + dt.ToString("yyyy-MM-dd-HH"), new string[] { requestInfo + "," }, false);
|
LogLockHelper.OutSql2Log("RecordAccessLogs", "RecordAccessLogs" + DateTime.Now.ToString("yyyy-MM-dd-HH"), new[] { requestInfo + "," }, false);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return Task.CompletedTask;
|
//写入数据库
|
||||||
|
if (middlewareRecordAccessLogsEnabledDbMode)
|
||||||
|
{
|
||||||
|
await _sysUserOperationLogServices.InsertAsync(uLog);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -145,18 +194,5 @@ namespace CoreCms.Net.Middlewares
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserAccessModel
|
|
||||||
{
|
|
||||||
public string User { get; set; }
|
|
||||||
public string IP { get; set; }
|
|
||||||
public string API { get; set; }
|
|
||||||
public string BeginTime { get; set; }
|
|
||||||
public string OPTime { get; set; }
|
|
||||||
public string RequestMethod { get; set; }
|
|
||||||
public string RequestData { get; set; }
|
|
||||||
public string Agent { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace CoreCms.Net.Middlewares
|
|||||||
if (AppSettingsConstVars.MiddlewareRequestResponseLogEnabled)
|
if (AppSettingsConstVars.MiddlewareRequestResponseLogEnabled)
|
||||||
{
|
{
|
||||||
// 过滤,只有接口
|
// 过滤,只有接口
|
||||||
if (context.Request.Path.Value.Contains("api") || context.Request.Path.Value.Contains("Api"))
|
if (context.Request.Path.Value != null && (context.Request.Path.Value.Contains("api") || context.Request.Path.Value.Contains("Api")))
|
||||||
{
|
{
|
||||||
context.Request.EnableBuffering();
|
context.Request.EnableBuffering();
|
||||||
Stream originalBody = context.Response.Body;
|
Stream originalBody = context.Response.Body;
|
||||||
@@ -57,19 +57,17 @@ namespace CoreCms.Net.Middlewares
|
|||||||
// 存储请求数据
|
// 存储请求数据
|
||||||
await RequestDataLog(context);
|
await RequestDataLog(context);
|
||||||
|
|
||||||
using (var ms = new MemoryStream())
|
await using var ms = new MemoryStream();
|
||||||
{
|
|
||||||
context.Response.Body = ms;
|
context.Response.Body = ms;
|
||||||
|
|
||||||
await _next(context);
|
await _next(context);
|
||||||
|
|
||||||
// 存储响应数据
|
// 存储响应数据
|
||||||
ResponseDataLog(context.Response, ms);
|
ResponseDataLog(ms);
|
||||||
|
|
||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
await ms.CopyToAsync(originalBody);
|
await ms.CopyToAsync(originalBody);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// 记录异常
|
// 记录异常
|
||||||
@@ -91,7 +89,7 @@ namespace CoreCms.Net.Middlewares
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RequestDataLog(HttpContext context)
|
private static async Task RequestDataLog(HttpContext context)
|
||||||
{
|
{
|
||||||
var request = context.Request;
|
var request = context.Request;
|
||||||
var sr = new StreamReader(request.Body);
|
var sr = new StreamReader(request.Body);
|
||||||
@@ -100,9 +98,9 @@ namespace CoreCms.Net.Middlewares
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(content))
|
if (!string.IsNullOrEmpty(content))
|
||||||
{
|
{
|
||||||
Parallel.For(0, 1, e =>
|
Parallel.For(0, 1, _ =>
|
||||||
{
|
{
|
||||||
LogLockHelper.OutSql2Log("RequestResponseLog", "RequestResponseLog" + DateTime.Now.ToString("yyyy-MM-dd-HH"), new string[] { "Request Data:", content });
|
LogLockHelper.OutSql2Log("RequestResponseLog", "RequestResponseLog" + DateTime.Now.ToString("yyyy-MM-dd-HH"), new[] { "Request Data:", content });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -110,18 +108,15 @@ namespace CoreCms.Net.Middlewares
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResponseDataLog(HttpResponse response, MemoryStream ms)
|
private static void ResponseDataLog(Stream ms)
|
||||||
{
|
{
|
||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
var ResponseBody = new StreamReader(ms).ReadToEnd();
|
var responseBody = new StreamReader(ms).ReadToEnd();
|
||||||
// 去除 Html
|
if (!string.IsNullOrEmpty(responseBody))
|
||||||
var reg = "<[^>]+>";
|
|
||||||
var isHtml = Regex.IsMatch(ResponseBody, reg);
|
|
||||||
if (!string.IsNullOrEmpty(ResponseBody))
|
|
||||||
{
|
{
|
||||||
Parallel.For(0, 1, e =>
|
Parallel.For(0, 1, _ =>
|
||||||
{
|
{
|
||||||
LogLockHelper.OutSql2Log("RequestResponseLog", "RequestResponseLog" + DateTime.Now.ToString("yyyy-MM-dd-HH"), new string[] { "Response Data:", ResponseBody });
|
LogLockHelper.OutSql2Log("RequestResponseLog", "RequestResponseLog" + DateTime.Now.ToString("yyyy-MM-dd-HH"), new[] { "Response Data:", responseBody });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
272
CoreCms.Net.Model/Entities/System/SysUserOperationLog.cs
Normal file
272
CoreCms.Net.Model/Entities/System/SysUserOperationLog.cs
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2022/4/10 0:52:14
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using SqlSugar;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Model.Entities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户操作日志
|
||||||
|
/// </summary>
|
||||||
|
public partial class SysUserOperationLog
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数
|
||||||
|
/// </summary>
|
||||||
|
public SysUserOperationLog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 序列
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "序列")]
|
||||||
|
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "请输入{0}")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.Int32 id { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户登录账号
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "用户登录账号")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String userName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户登录昵称
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "用户登录昵称")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String userNickName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户序列
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "用户序列")]
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "请输入{0}")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.Int32 userId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IP地址
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "IP地址")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:150,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String ip { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求地址
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "请求地址")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:150,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String apiPath { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始时间
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "开始时间")]
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "请输入{0}")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.DateTime beginTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 结束时间
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "结束时间")]
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "请输入{0}")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.DateTime endTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 耗时
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "耗时")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String opTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求方式
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "请求方式")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String requestMethod { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求数据
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "请求数据")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.String requestData { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回数据
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "返回数据")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.String responseBodyData { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 代理渠道
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "代理渠道")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:1000,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String agent { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 动作方法名称
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "动作方法名称")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String actionName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 动作方法描述
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "动作方法描述")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String actionDescription { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制器名称
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "控制器名称")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String controllerName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制器名称
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "控制器名称")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String controllerDescription { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 状态码
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "状态码")]
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "请输入{0}")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.Int32 statusCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "创建时间")]
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "请输入{0}")]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public System.DateTime createTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据来源
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "数据来源")]
|
||||||
|
|
||||||
|
|
||||||
|
[StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")]
|
||||||
|
|
||||||
|
|
||||||
|
public System.String dataSources { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
119
CoreCms.Net.Repository/System/SysUserOperationLogRepository.cs
Normal file
119
CoreCms.Net.Repository/System/SysUserOperationLogRepository.cs
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2022/4/10 0:27:47
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Caching.Manual;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.IRepository;
|
||||||
|
using CoreCms.Net.IRepository.UnitOfWork;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Repository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户操作日志 接口实现
|
||||||
|
/// </summary>
|
||||||
|
public class SysUserOperationLogRepository : BaseRepository<SysUserOperationLog>, ISysUserOperationLogRepository
|
||||||
|
{
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
public SysUserOperationLogRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||||
|
{
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 重写根据条件查询分页数据
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<IPageList<SysUserOperationLog>> QueryPageAsync(Expression<Func<SysUserOperationLog, bool>> predicate,
|
||||||
|
Expression<Func<SysUserOperationLog, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false)
|
||||||
|
{
|
||||||
|
RefAsync<int> totalCount = 0;
|
||||||
|
List<SysUserOperationLog> page;
|
||||||
|
if (blUseNoLock)
|
||||||
|
{
|
||||||
|
page = await DbClient.Queryable<SysUserOperationLog>()
|
||||||
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||||
|
.WhereIF(predicate != null, predicate).Select(p => new SysUserOperationLog
|
||||||
|
{
|
||||||
|
id = p.id,
|
||||||
|
userName = p.userName,
|
||||||
|
userNickName = p.userNickName,
|
||||||
|
userId = p.userId,
|
||||||
|
ip = p.ip,
|
||||||
|
apiPath = p.apiPath,
|
||||||
|
beginTime = p.beginTime,
|
||||||
|
endTime = p.endTime,
|
||||||
|
opTime = p.opTime,
|
||||||
|
requestMethod = p.requestMethod,
|
||||||
|
//requestData = p.requestData,
|
||||||
|
//responseBodyData = p.responseBodyData,
|
||||||
|
agent = p.agent,
|
||||||
|
actionName = p.actionName,
|
||||||
|
actionDescription = p.actionDescription,
|
||||||
|
controllerName = p.controllerName,
|
||||||
|
controllerDescription = p.controllerDescription,
|
||||||
|
statusCode = p.statusCode,
|
||||||
|
createTime = p.createTime,
|
||||||
|
dataSources = p.dataSources,
|
||||||
|
|
||||||
|
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
page = await DbClient.Queryable<SysUserOperationLog>()
|
||||||
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||||
|
.WhereIF(predicate != null, predicate).Select(p => new SysUserOperationLog
|
||||||
|
{
|
||||||
|
id = p.id,
|
||||||
|
userName = p.userName,
|
||||||
|
userNickName = p.userNickName,
|
||||||
|
userId = p.userId,
|
||||||
|
ip = p.ip,
|
||||||
|
apiPath = p.apiPath,
|
||||||
|
beginTime = p.beginTime,
|
||||||
|
endTime = p.endTime,
|
||||||
|
opTime = p.opTime,
|
||||||
|
requestMethod = p.requestMethod,
|
||||||
|
//requestData = p.requestData,
|
||||||
|
//responseBodyData = p.responseBodyData,
|
||||||
|
agent = p.agent,
|
||||||
|
actionName = p.actionName,
|
||||||
|
actionDescription = p.actionDescription,
|
||||||
|
controllerName = p.controllerName,
|
||||||
|
controllerDescription = p.controllerDescription,
|
||||||
|
statusCode = p.statusCode,
|
||||||
|
createTime = p.createTime,
|
||||||
|
dataSources = p.dataSources,
|
||||||
|
|
||||||
|
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||||
|
}
|
||||||
|
var list = new PageList<SysUserOperationLog>(page, pageIndex, pageSize, totalCount);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
62
CoreCms.Net.Services/System/SysUserOperationLogServices.cs
Normal file
62
CoreCms.Net.Services/System/SysUserOperationLogServices.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2022/4/10 0:27:47
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.IRepository;
|
||||||
|
using CoreCms.Net.IRepository.UnitOfWork;
|
||||||
|
using CoreCms.Net.IServices;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户操作日志 接口实现
|
||||||
|
/// </summary>
|
||||||
|
public class SysUserOperationLogServices : BaseServices<SysUserOperationLog>, ISysUserOperationLogServices
|
||||||
|
{
|
||||||
|
private readonly ISysUserOperationLogRepository _dal;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
public SysUserOperationLogServices(IUnitOfWork unitOfWork, ISysUserOperationLogRepository dal)
|
||||||
|
{
|
||||||
|
this._dal = dal;
|
||||||
|
base.BaseDal = dal;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 重写根据条件查询分页数据
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<IPageList<SysUserOperationLog>> QueryPageAsync(Expression<Func<SysUserOperationLog, bool>> predicate,
|
||||||
|
Expression<Func<SysUserOperationLog, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false)
|
||||||
|
{
|
||||||
|
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -345,7 +345,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
|||||||
public AdminUiCallBack GetAllControllerAndActionByAssembly()
|
public AdminUiCallBack GetAllControllerAndActionByAssembly()
|
||||||
{
|
{
|
||||||
var jm = new AdminUiCallBack();
|
var jm = new AdminUiCallBack();
|
||||||
var data = AdminsControllerPermission.GetAllControllerAndActionByAssembly();
|
var data = AdminsControllerPermission.GetCacheCoreCmsControllerPermission();
|
||||||
jm.data = data.OrderBy(u => u.name).ToList();
|
jm.data = data.OrderBy(u => u.name).ToList();
|
||||||
jm.code = 0;
|
jm.code = 0;
|
||||||
jm.msg = "获取成功";
|
jm.msg = "获取成功";
|
||||||
|
|||||||
@@ -0,0 +1,350 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2022/4/10 0:27:47
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.Entities.Expression;
|
||||||
|
using CoreCms.Net.Model.FromBody;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using CoreCms.Net.Filter;
|
||||||
|
using CoreCms.Net.Loging;
|
||||||
|
using CoreCms.Net.IServices;
|
||||||
|
using CoreCms.Net.Utility.Helper;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.HSSF.UserModel;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户操作日志
|
||||||
|
///</summary>
|
||||||
|
[Description("用户操作日志")]
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
[RequiredErrorForAdmin]
|
||||||
|
[Authorize]
|
||||||
|
public class SysUserOperationLogController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
|
private readonly ISysUserOperationLogServices _sysUserOperationLogServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数
|
||||||
|
///</summary>
|
||||||
|
public SysUserOperationLogController(IWebHostEnvironment webHostEnvironment
|
||||||
|
,ISysUserOperationLogServices sysUserOperationLogServices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_webHostEnvironment = webHostEnvironment;
|
||||||
|
_sysUserOperationLogServices = sysUserOperationLogServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 获取列表============================================================
|
||||||
|
// POST: Api/SysUserOperationLog/GetPageList
|
||||||
|
/// <summary>
|
||||||
|
/// 获取列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("获取列表")]
|
||||||
|
public async Task<AdminUiCallBack> GetPageList()
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||||
|
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||||
|
var where = PredicateBuilder.True<SysUserOperationLog>();
|
||||||
|
//获取排序字段
|
||||||
|
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||||
|
|
||||||
|
Expression<Func<SysUserOperationLog, object>> orderEx = orderField switch
|
||||||
|
{
|
||||||
|
"id" => p => p.id,"userName" => p => p.userName,"userNickName" => p => p.userNickName,"userId" => p => p.userId,"ip" => p => p.ip,"apiPath" => p => p.apiPath,"beginTime" => p => p.beginTime,"endTime" => p => p.endTime,"opTime" => p => p.opTime,"requestMethod" => p => p.requestMethod,"requestData" => p => p.requestData,"responseBodyData" => p => p.responseBodyData,"agent" => p => p.agent,"actionName" => p => p.actionName,"actionDescription" => p => p.actionDescription,"controllerName" => p => p.controllerName,"controllerDescription" => p => p.controllerDescription,"statusCode" => p => p.statusCode,"createTime" => p => p.createTime,"dataSources" => p => p.dataSources,
|
||||||
|
_ => p => p.id
|
||||||
|
};
|
||||||
|
|
||||||
|
//设置排序方式
|
||||||
|
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||||
|
var orderBy = orderDirection switch
|
||||||
|
{
|
||||||
|
"asc" => OrderByType.Asc,
|
||||||
|
"desc" => OrderByType.Desc,
|
||||||
|
_ => OrderByType.Desc
|
||||||
|
};
|
||||||
|
//查询筛选
|
||||||
|
|
||||||
|
// int
|
||||||
|
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||||
|
if (id > 0)
|
||||||
|
{
|
||||||
|
where = where.And(p => p.id == id);
|
||||||
|
}
|
||||||
|
//用户登录账号 nvarchar
|
||||||
|
var userName = Request.Form["userName"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(userName))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.userName.Contains(userName));
|
||||||
|
}
|
||||||
|
//用户登录昵称 nvarchar
|
||||||
|
var userNickName = Request.Form["userNickName"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(userNickName))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.userNickName.Contains(userNickName));
|
||||||
|
}
|
||||||
|
//用户序列 nvarchar
|
||||||
|
var userId = Request.Form["userId"].FirstOrDefault().ObjectToInt(0);
|
||||||
|
if (userId > 0)
|
||||||
|
{
|
||||||
|
where = where.And(p => p.id == id);
|
||||||
|
}
|
||||||
|
//IP地址 nvarchar
|
||||||
|
var ip = Request.Form["ip"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(ip))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.ip.Contains(ip));
|
||||||
|
}
|
||||||
|
//请求地址 nvarchar
|
||||||
|
var apiPath = Request.Form["apiPath"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(apiPath))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.apiPath.Contains(apiPath));
|
||||||
|
}
|
||||||
|
//开始时间 datetime
|
||||||
|
var beginTime = Request.Form["beginTime"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(beginTime))
|
||||||
|
{
|
||||||
|
if (beginTime.Contains("到"))
|
||||||
|
{
|
||||||
|
var dts = beginTime.Split("到");
|
||||||
|
var dtStart = dts[0].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.beginTime > dtStart);
|
||||||
|
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.beginTime < dtEnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dt = beginTime.ObjectToDate();
|
||||||
|
where = where.And(p => p.beginTime > dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//结束时间 datetime
|
||||||
|
var endTime = Request.Form["endTime"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(endTime))
|
||||||
|
{
|
||||||
|
if (endTime.Contains("到"))
|
||||||
|
{
|
||||||
|
var dts = endTime.Split("到");
|
||||||
|
var dtStart = dts[0].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.endTime > dtStart);
|
||||||
|
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.endTime < dtEnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dt = endTime.ObjectToDate();
|
||||||
|
where = where.And(p => p.endTime > dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//耗时 nvarchar
|
||||||
|
var opTime = Request.Form["opTime"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(opTime))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.opTime.Contains(opTime));
|
||||||
|
}
|
||||||
|
//请求方式 nvarchar
|
||||||
|
var requestMethod = Request.Form["requestMethod"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(requestMethod))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.requestMethod.Contains(requestMethod));
|
||||||
|
}
|
||||||
|
//请求数据 nvarchar
|
||||||
|
var requestData = Request.Form["requestData"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(requestData))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.requestData.Contains(requestData));
|
||||||
|
}
|
||||||
|
//返回数据 nvarchar
|
||||||
|
var responseBodyData = Request.Form["responseBodyData"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(responseBodyData))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.responseBodyData.Contains(responseBodyData));
|
||||||
|
}
|
||||||
|
//代理渠道 nvarchar
|
||||||
|
var agent = Request.Form["agent"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(agent))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.agent.Contains(agent));
|
||||||
|
}
|
||||||
|
//动作方法名称 nvarchar
|
||||||
|
var actionName = Request.Form["actionName"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(actionName))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.actionName.Contains(actionName));
|
||||||
|
}
|
||||||
|
//动作方法描述 nvarchar
|
||||||
|
var actionDescription = Request.Form["actionDescription"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(actionDescription))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.actionDescription.Contains(actionDescription));
|
||||||
|
}
|
||||||
|
//控制器名称 nvarchar
|
||||||
|
var controllerName = Request.Form["controllerName"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(controllerName))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.controllerName.Contains(controllerName));
|
||||||
|
}
|
||||||
|
//控制器名称 nvarchar
|
||||||
|
var controllerDescription = Request.Form["controllerDescription"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(controllerDescription))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.controllerDescription.Contains(controllerDescription));
|
||||||
|
}
|
||||||
|
//状态码 int
|
||||||
|
var statusCode = Request.Form["statusCode"].FirstOrDefault().ObjectToInt(0);
|
||||||
|
if (statusCode > 0)
|
||||||
|
{
|
||||||
|
where = where.And(p => p.statusCode == statusCode);
|
||||||
|
}
|
||||||
|
//创建时间 datetime
|
||||||
|
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(createTime))
|
||||||
|
{
|
||||||
|
if (createTime.Contains("到"))
|
||||||
|
{
|
||||||
|
var dts = createTime.Split("到");
|
||||||
|
var dtStart = dts[0].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.createTime > dtStart);
|
||||||
|
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.createTime < dtEnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dt = createTime.ObjectToDate();
|
||||||
|
where = where.And(p => p.createTime > dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//数据来源 nvarchar
|
||||||
|
var dataSources = Request.Form["dataSources"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(dataSources))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.dataSources.Contains(dataSources));
|
||||||
|
}
|
||||||
|
//获取数据
|
||||||
|
var list = await _sysUserOperationLogServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||||
|
//返回数据
|
||||||
|
jm.data = list;
|
||||||
|
jm.code = 0;
|
||||||
|
jm.count = list.TotalCount;
|
||||||
|
jm.msg = "数据调用成功!";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 首页数据============================================================
|
||||||
|
// POST: Api/SysUserOperationLog/GetIndex
|
||||||
|
/// <summary>
|
||||||
|
/// 首页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("首页数据")]
|
||||||
|
public AdminUiCallBack GetIndex()
|
||||||
|
{
|
||||||
|
//返回数据
|
||||||
|
var jm = new AdminUiCallBack { code = 0 };
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 删除数据============================================================
|
||||||
|
// POST: Api/SysUserOperationLog/DoDelete/10
|
||||||
|
/// <summary>
|
||||||
|
/// 单选删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("单选删除")]
|
||||||
|
public async Task<AdminUiCallBack> DoDelete([FromBody]FMIntId entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var model = await _sysUserOperationLogServices.ExistsAsync(p => p.id == entity.id, true);
|
||||||
|
if (!model)
|
||||||
|
{
|
||||||
|
jm.msg = GlobalConstVars.DataisNo;
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
var bl = await _sysUserOperationLogServices.DeleteByIdAsync(entity.id);
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 批量删除============================================================
|
||||||
|
// POST: Api/SysUserOperationLog/DoBatchDelete/10,11,20
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("批量删除")]
|
||||||
|
public async Task<AdminUiCallBack> DoBatchDelete([FromBody]FMArrayIntIds entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var bl = await _sysUserOperationLogServices.DeleteByIdsAsync(entity.id);
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 预览数据============================================================
|
||||||
|
// POST: Api/SysUserOperationLog/GetDetails/10
|
||||||
|
/// <summary>
|
||||||
|
/// 预览数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("预览数据")]
|
||||||
|
public async Task<AdminUiCallBack> GetDetails([FromBody]FMIntId entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var model = await _sysUserOperationLogServices.QueryByIdAsync(entity.id, false);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
jm.msg = "不存在此信息";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
jm.code = 0;
|
||||||
|
jm.data = model;
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -174,7 +174,7 @@ namespace CoreCms.Net.Web.Admin
|
|||||||
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
||||||
app.UseRequestResponseLog();
|
app.UseRequestResponseLog();
|
||||||
// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ʼ<EFBFBD>¼(<28><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD>㣬<EFBFBD><E3A3AC>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD>ᱨ<EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>)(ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ʼ<EFBFBD>¼(<28><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD>㣬<EFBFBD><E3A3AC>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD>ᱨ<EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>)(ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
||||||
app.UseRecordAccessLogsMildd();
|
app.UseRecordAccessLogsMildd(GlobalEnumVars.CoreShopSystemCategory.Admin.ToString());
|
||||||
// <20><>¼ip<69><70><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
// <20><>¼ip<69><70><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
||||||
app.UseIpLogMildd();
|
app.UseIpLogMildd();
|
||||||
// signalr
|
// signalr
|
||||||
|
|||||||
@@ -46,8 +46,10 @@
|
|||||||
},
|
},
|
||||||
//记录用户方访问数据
|
//记录用户方访问数据
|
||||||
"RecordAccessLogs": {
|
"RecordAccessLogs": {
|
||||||
"Enabled": false,
|
"Enabled": true, //是否开启记录操作日志功能。
|
||||||
"IgnoreApis": "/api/Home/GetNav,/api/Home/GetIds4Users"
|
"EnabledFileMode": false, //是否开启记录到文件功能。(影响效率,接口不建议开启)
|
||||||
|
"EnabledDbMode": true, //是否开启记录到数据库模式。(影响效率,接口不建议开启)
|
||||||
|
"IgnoreApis": "/api/tools/getuserinfo,/api/tools/getNavs,/api/CodeGenerator/CodeGenDown" //使用小写逗号分隔
|
||||||
},
|
},
|
||||||
//记录IP请求数据
|
//记录IP请求数据
|
||||||
"IPLog": {
|
"IPLog": {
|
||||||
|
|||||||
@@ -0,0 +1,207 @@
|
|||||||
|
<script type="text/html" template lay-done="layui.data.done(d);">
|
||||||
|
<table class="layui-table layui-form" lay-filter="LAY-app-SysUserOperationLog-detailsForm" id="LAY-app-SysUserOperationLog-detailsForm">
|
||||||
|
<colgroup>
|
||||||
|
<col width="150">
|
||||||
|
<col>
|
||||||
|
</colgroup>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="id">序列</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.id || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="userName">用户登录账号</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.userName || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="userNickName">用户登录昵称</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.userNickName || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="userId">用户序列</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.userId || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="ip">IP地址</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.ip || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="apiPath">请求地址</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.apiPath || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="beginTime">开始时间</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.beginTime || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="endTime">结束时间</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.endTime || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="opTime">耗时</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.opTime || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="requestMethod">请求方式</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.requestMethod || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="requestData">请求数据</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.requestData || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="responseBodyData">返回数据</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.responseBodyData || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="agent">代理渠道</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.agent || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="actionName">动作方法名称</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.actionName || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="actionDescription">动作方法描述</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.actionDescription || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="controllerName">控制器名称</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.controllerName || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="controllerDescription">控制器名称</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.controllerDescription || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="statusCode">状态码</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.statusCode || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="createTime">创建时间</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.createTime || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="dataSources">数据来源</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ d.params.data.dataSources || '' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
var debug = layui.setter.debug;
|
||||||
|
layui.data.done = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d.params.data); }
|
||||||
|
|
||||||
|
layui.use(['admin', 'form', 'coreHelper'], function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, setter = layui.setter
|
||||||
|
, admin = layui.admin
|
||||||
|
, coreHelper = layui.coreHelper
|
||||||
|
, form = layui.form;
|
||||||
|
form.render(null, 'LAY-app-SysUserOperationLog-detailsForm');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
<title>用户操作日志</title>
|
||||||
|
<!--当前位置开始-->
|
||||||
|
<div class="layui-card layadmin-header">
|
||||||
|
<div class="layui-breadcrumb" lay-filter="breadcrumb">
|
||||||
|
<script type="text/html" template lay-done="layui.data.updateMainBreadcrumb();">
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--当前位置结束-->
|
||||||
|
<style>
|
||||||
|
/* 重写样式 */
|
||||||
|
</style>
|
||||||
|
<script type="text/html" template lay-type="Post" lay-url="Api/SysUserOperationLog/GetIndex" lay-done="layui.data.done(d);">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<div class="table-body">
|
||||||
|
<table id="LAY-app-SysUserOperationLog-tableBox" lay-filter="LAY-app-SysUserOperationLog-tableBox"></table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/html" id="LAY-app-SysUserOperationLog-toolbar">
|
||||||
|
<div class="layui-form coreshop-toolbar-search-form">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="userName">用户登录账号</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="userName" placeholder="请输入用户登录账号" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="ip">IP地址</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="ip" placeholder="请输入IP地址" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="beginTime">开始时间</label>
|
||||||
|
<div class="layui-input-inline" style="width: 260px;">
|
||||||
|
<input type="text" name="beginTime" id="searchTime-SysUserOperationLog-beginTime" placeholder="请输入开始时间" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="requestMethod">请求方式</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="requestMethod" placeholder="请输入请求方式" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="statusCode">状态码</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="statusCode" placeholder="请输入状态码" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-SysUserOperationLog-search"><i class="layui-icon layui-icon-search"></i>筛选</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="LAY-app-SysUserOperationLog-pagebar">
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="batchDelete"><i class="layui-icon layui-icon-delete"></i>批量删除</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="LAY-app-SysUserOperationLog-tableBox-bar">
|
||||||
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var indexData;
|
||||||
|
var debug = layui.setter.debug;
|
||||||
|
layui.data.done = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d); }
|
||||||
|
|
||||||
|
indexData = d.data;
|
||||||
|
layui.use(['index', 'table', 'laydate', 'util', 'coredropdown', 'coreHelper'],
|
||||||
|
function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, admin = layui.admin
|
||||||
|
, table = layui.table
|
||||||
|
, form = layui.form
|
||||||
|
, laydate = layui.laydate
|
||||||
|
, setter = layui.setter
|
||||||
|
, coreHelper = layui.coreHelper
|
||||||
|
, util = layui.util
|
||||||
|
, view = layui.view;
|
||||||
|
|
||||||
|
var searchwhere;
|
||||||
|
//监听搜索
|
||||||
|
form.on('submit(LAY-app-SysUserOperationLog-search)',
|
||||||
|
function (data) {
|
||||||
|
var field = data.field;
|
||||||
|
searchwhere = field;
|
||||||
|
//执行重载
|
||||||
|
table.reloadData('LAY-app-SysUserOperationLog-tableBox', { where: field });
|
||||||
|
});
|
||||||
|
//数据绑定
|
||||||
|
table.render({
|
||||||
|
elem: '#LAY-app-SysUserOperationLog-tableBox',
|
||||||
|
url: layui.setter.apiUrl + 'Api/SysUserOperationLog/GetPageList',
|
||||||
|
method: 'POST',
|
||||||
|
toolbar: '#LAY-app-SysUserOperationLog-toolbar',
|
||||||
|
pagebar: '#LAY-app-SysUserOperationLog-pagebar',
|
||||||
|
className: 'pagebarbox',
|
||||||
|
defaultToolbar: ['filter', 'print', 'exports'],
|
||||||
|
height: 'full-127',//面包屑142px,搜索框4行172,3行137,2行102,1行67
|
||||||
|
page: true,
|
||||||
|
limit: 30,
|
||||||
|
limits: [10, 15, 20, 25, 30, 50, 100, 200],
|
||||||
|
text: { none: '暂无相关数据' },
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{ type: "checkbox", fixed: "left" },
|
||||||
|
{ field: 'id', title: '序列', sort: false, width: 60 },
|
||||||
|
{ field: 'userName', title: '登录账号', sort: false, width: 80 },
|
||||||
|
//{ field: 'userNickName', title: '用户登录昵称', sort: false,width: 105 },
|
||||||
|
//{ field: 'userId', title: '用户序列', sort: false,width: 105 },
|
||||||
|
{ field: 'ip', title: 'IP地址', sort: false, width: 105 },
|
||||||
|
{ field: 'apiPath', title: '请求地址', sort: false, width: 205 },
|
||||||
|
{ field: 'beginTime', title: '开始时间', width: 130, sort: false },
|
||||||
|
{ field: 'endTime', title: '结束时间', width: 130, sort: false },
|
||||||
|
{ field: 'opTime', title: '耗时', sort: false, width: 80 },
|
||||||
|
{ field: 'requestMethod', title: '方式', sort: false, width: 60 },
|
||||||
|
//{ field: 'requestData', title: '请求数据', sort: false,width: 105 },
|
||||||
|
//{ field: 'responseBodyData', title: '返回数据', sort: false,width: 105 },
|
||||||
|
{ field: 'agent', title: '代理渠道', sort: false, width: 105 },
|
||||||
|
{ field: 'actionName', title: '动作方法名称', sort: false, width: 105 },
|
||||||
|
{ field: 'actionDescription', title: '动作方法描述', sort: false, width: 105 },
|
||||||
|
{ field: 'controllerName', title: '控制器名称', sort: false, width: 105 },
|
||||||
|
{ field: 'controllerDescription', title: '控制器名称', sort: false, width: 105 },
|
||||||
|
{ field: 'statusCode', title: '状态码', sort: false, width: 60 },
|
||||||
|
//{ field: 'createTime', title: '创建时间', width: 130, sort: false },
|
||||||
|
{ field: 'dataSources', title: '数据来源', sort: false, width: 105 },
|
||||||
|
{ width: 82, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-SysUserOperationLog-tableBox-bar' }
|
||||||
|
]
|
||||||
|
]
|
||||||
|
});
|
||||||
|
//监听排序事件
|
||||||
|
table.on('sort(LAY-app-SysUserOperationLog-tableBox)', function (obj) {
|
||||||
|
table.reloadData('LAY-app-SysUserOperationLog-tableBox', {
|
||||||
|
initSort: obj, //记录初始排序,如果不设的话,将无法标记表头的排序状态。
|
||||||
|
where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
|
||||||
|
orderField: obj.field, //排序字段
|
||||||
|
orderDirection: obj.type //排序方式
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//监听行双击事件
|
||||||
|
table.on('rowDouble(LAY-app-SysUserOperationLog-tableBox)', function (obj) {
|
||||||
|
//查看详情
|
||||||
|
doDetails(obj);
|
||||||
|
});
|
||||||
|
//头工具栏事件
|
||||||
|
table.on('pagebar(LAY-app-SysUserOperationLog-tableBox)', function (obj) {
|
||||||
|
var checkStatus = table.checkStatus(obj.config.id);
|
||||||
|
switch (obj.event) {
|
||||||
|
case 'batchDelete':
|
||||||
|
doBatchDelete(checkStatus);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
//监听工具条
|
||||||
|
table.on('tool(LAY-app-SysUserOperationLog-tableBox)',
|
||||||
|
function (obj) {
|
||||||
|
if (obj.event === 'detail') {
|
||||||
|
doDetails(obj);
|
||||||
|
} else if (obj.event === 'del') {
|
||||||
|
doDelete(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//执行预览操作
|
||||||
|
function doDetails(obj) {
|
||||||
|
coreHelper.Post("Api/SysUserOperationLog/GetDetails", { id: obj.data.id }, function (e) {
|
||||||
|
if (e.code === 0) {
|
||||||
|
admin.popup({
|
||||||
|
shadeClose: false,
|
||||||
|
title: '查看详情',
|
||||||
|
area: ['90%', '90%'],
|
||||||
|
id: 'LAY-popup-SysUserOperationLog-details',
|
||||||
|
success: function (layero, index) {
|
||||||
|
view(this.id).render('system/sysuseroperationlog/details', { data: e.data }).done(function () {
|
||||||
|
form.render();
|
||||||
|
});
|
||||||
|
// 禁止弹窗出现滚动条
|
||||||
|
//$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行单个删除
|
||||||
|
function doDelete(obj) {
|
||||||
|
coreHelper.Post("Api/SysUserOperationLog/DoDelete", { id: obj.data.id }, function (e) {
|
||||||
|
if (debug) { console.log(e); } //开启调试返回数据
|
||||||
|
table.reloadData('LAY-app-SysUserOperationLog-tableBox');
|
||||||
|
layer.msg(e.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行批量删除
|
||||||
|
function doBatchDelete(checkStatus) {
|
||||||
|
var checkData = checkStatus.data;
|
||||||
|
if (checkData.length === 0) {
|
||||||
|
return layer.msg('请选择要删除的数据');
|
||||||
|
}
|
||||||
|
layer.confirm('确定删除吗?删除后将无法恢复。',
|
||||||
|
function (index) {
|
||||||
|
var delidsStr = [];
|
||||||
|
layui.each(checkData,
|
||||||
|
function (index, item) {
|
||||||
|
delidsStr.push(item.id);
|
||||||
|
});
|
||||||
|
coreHelper.Post("Api/SysUserOperationLog/DoBatchDelete", { id: delidsStr }, function (e) {
|
||||||
|
if (debug) { console.log(e); } //开启调试返回数据
|
||||||
|
table.reloadData('LAY-app-SysUserOperationLog-tableBox');
|
||||||
|
layer.msg(e.msg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
laydate.render({
|
||||||
|
elem: '#searchTime-SysUserOperationLog-beginTime',
|
||||||
|
type: 'datetime',
|
||||||
|
range: '到',
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#searchTime-SysUserOperationLog-endTime',
|
||||||
|
type: 'datetime',
|
||||||
|
range: '到',
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#searchTime-SysUserOperationLog-createTime',
|
||||||
|
type: 'datetime',
|
||||||
|
range: '到',
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听 表格复选框操作
|
||||||
|
|
||||||
|
//重载form
|
||||||
|
form.render();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
@@ -278,10 +278,10 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
|||||||
jm.status = true;
|
jm.status = true;
|
||||||
jm.data = new
|
jm.data = new
|
||||||
{
|
{
|
||||||
count = first + second,
|
count = first + monthFirst,
|
||||||
first,
|
first,
|
||||||
second,
|
second,
|
||||||
monthCount = monthFirst + monthSecond,
|
monthCount = second + monthSecond,
|
||||||
monthFirst,
|
monthFirst,
|
||||||
monthSecond
|
monthSecond
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ namespace CoreCms.Net.Web.WebApi
|
|||||||
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
||||||
app.UseRequestResponseLog();
|
app.UseRequestResponseLog();
|
||||||
// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ʼ<EFBFBD>¼(<28><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD>㣬<EFBFBD><E3A3AC>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD>ᱨ<EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>)(ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ʼ<EFBFBD>¼(<28><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD>㣬<EFBFBD><E3A3AC>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD>ᱨ<EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>)(ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
||||||
app.UseRecordAccessLogsMildd();
|
app.UseRecordAccessLogsMildd(GlobalEnumVars.CoreShopSystemCategory.Api.ToString());
|
||||||
// <20><>¼ip<69><70><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
// <20><>¼ip<69><70><EFBFBD><EFBFBD> (ע<><EFBFBD><E2BFAA>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>)
|
||||||
app.UseIpLogMildd();
|
app.UseIpLogMildd();
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,10 @@
|
|||||||
},
|
},
|
||||||
//记录用户方访问数据
|
//记录用户方访问数据
|
||||||
"RecordAccessLogs": {
|
"RecordAccessLogs": {
|
||||||
"Enabled": false,
|
"Enabled": true, //是否开启记录操作日志功能。
|
||||||
"IgnoreApis": "/api/Home/GetNav,/api/Home/GetIds4Users"
|
"EnabledFileMode": false, //是否开启记录到文件功能。(影响效率,接口不建议开启)
|
||||||
|
"EnabledDbMode": false, //是否开启记录到数据库模式。(影响效率,接口不建议开启)
|
||||||
|
"IgnoreApis": "/api/tools/getuserinfo,/api/tools/getNavs,/api/CodeGenerator/CodeGenDown" //使用小写逗号分隔
|
||||||
},
|
},
|
||||||
//记录IP请求数据
|
//记录IP请求数据
|
||||||
"IPLog": {
|
"IPLog": {
|
||||||
|
|||||||
52
数据库/MySql/20220410/1、创建表SysUserOperationLog.sql
Normal file
52
数据库/MySql/20220410/1、创建表SysUserOperationLog.sql
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : rm-wz92918pm46bsbc37mo.mysql.rds.aliyuncs.com
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 50732
|
||||||
|
Source Host : rm-wz92918pm46bsbc37mo.mysql.rds.aliyuncs.com:3306
|
||||||
|
Source Schema : coreshop
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 50732
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 10/04/2022 02:24:03
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for SysUserOperationLog
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `SysUserOperationLog`;
|
||||||
|
CREATE TABLE `SysUserOperationLog` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '序列',
|
||||||
|
`userName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户登录账号',
|
||||||
|
`userNickName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户登录昵称',
|
||||||
|
`userId` int(11) NULL DEFAULT NULL COMMENT '用户序列',
|
||||||
|
`ip` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'IP地址',
|
||||||
|
`apiPath` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求地址',
|
||||||
|
`beginTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '开始时间',
|
||||||
|
`endTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '结束时间',
|
||||||
|
`opTime` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '耗时',
|
||||||
|
`requestMethod` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求方式',
|
||||||
|
`requestData` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '请求数据',
|
||||||
|
`responseBodyData` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '返回数据',
|
||||||
|
`agent` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '代理渠道',
|
||||||
|
`actionName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '动作方法名称',
|
||||||
|
`actionDescription` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '动作方法描述',
|
||||||
|
`controllerName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '控制器名称',
|
||||||
|
`controllerDescription` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '控制器名称',
|
||||||
|
`statusCode` int(11) NULL DEFAULT NULL COMMENT '状态码',
|
||||||
|
`createTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间',
|
||||||
|
`dataSources` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '数据来源',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of SysUserOperationLog
|
||||||
|
-- ----------------------------
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
24
数据库/MySql/20220410/2、添加菜单.sql
Normal file
24
数据库/MySql/20220410/2、添加菜单.sql
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Schema : coreshop
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 50732
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 10/04/2022 02:25:27
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of SysMenu
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `SysMenu` VALUES (1381, 111, 'sysuseroperationlog', '用户操作日志', '', 'system/sysuseroperationlog/index', '', 0, 400, '', NULL, NULL, 0, 0, '2022-04-10 02:06:29', NULL);
|
||||||
|
INSERT INTO `SysMenu` VALUES (1382, 111, 'GetPageList', '获取列表', NULL, NULL, '/Api/SysUserOperationLog/GetPageList', 1, 0, 'SysUserOperationLog:GetPageList', NULL, NULL, 0, 0, '2022-04-10 02:06:29', NULL);
|
||||||
|
INSERT INTO `SysMenu` VALUES (1383, 111, 'GetIndex', '首页数据', NULL, NULL, '/Api/SysUserOperationLog/GetIndex', 1, 1, 'SysUserOperationLog:GetIndex', NULL, NULL, 0, 0, '2022-04-10 02:06:29', NULL);
|
||||||
|
INSERT INTO `SysMenu` VALUES (1384, 111, 'DoDelete', '单选删除', NULL, NULL, '/Api/SysUserOperationLog/DoDelete', 1, 2, 'SysUserOperationLog:DoDelete', NULL, NULL, 0, 0, '2022-04-10 02:06:29', NULL);
|
||||||
|
INSERT INTO `SysMenu` VALUES (1385, 111, 'DoBatchDelete', '批量删除', NULL, NULL, '/Api/SysUserOperationLog/DoBatchDelete', 1, 3, 'SysUserOperationLog:DoBatchDelete', NULL, NULL, 0, 0, '2022-04-10 02:06:29', NULL);
|
||||||
|
INSERT INTO `SysMenu` VALUES (1386, 111, 'GetDetails', '预览数据', NULL, NULL, '/Api/SysUserOperationLog/GetDetails', 1, 4, 'SysUserOperationLog:GetDetails', NULL, NULL, 0, 0, '2022-04-10 02:06:29', NULL);
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
BIN
数据库/MySql/20220410/coreshop完整数据库脚本.rar
Normal file
BIN
数据库/MySql/20220410/coreshop完整数据库脚本.rar
Normal file
Binary file not shown.
@@ -1,3 +1,6 @@
|
|||||||
|
2022-04-10
|
||||||
|
【新增】表【SysUserOperationLog】用户操作日志记录
|
||||||
|
|
||||||
2022-03-29
|
2022-03-29
|
||||||
【新增】表【CoreCmsInvoice】 新增 【fileUrl】发票下载地址字段
|
【新增】表【CoreCmsInvoice】 新增 【fileUrl】发票下载地址字段
|
||||||
|
|
||||||
|
|||||||
105
数据库/SqlServer/20220410/1、创建数据库脚本.sql
Normal file
105
数据库/SqlServer/20220410/1、创建数据库脚本.sql
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
/****** Object: Table [dbo].[SysUserOperationLog] Script Date: 2022/4/10 2:03:44 ******/
|
||||||
|
SET ANSI_NULLS ON
|
||||||
|
GO
|
||||||
|
|
||||||
|
SET QUOTED_IDENTIFIER ON
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE TABLE [dbo].[SysUserOperationLog](
|
||||||
|
[id] [int] IDENTITY(1,1) NOT NULL,
|
||||||
|
[userName] [nvarchar](50) NULL,
|
||||||
|
[userNickName] [nvarchar](50) NULL,
|
||||||
|
[userId] [int] NOT NULL,
|
||||||
|
[ip] [nvarchar](150) NULL,
|
||||||
|
[apiPath] [nvarchar](150) NULL,
|
||||||
|
[beginTime] [datetime] NOT NULL,
|
||||||
|
[endTime] [datetime] NOT NULL,
|
||||||
|
[opTime] [nvarchar](50) NULL,
|
||||||
|
[requestMethod] [nvarchar](50) NULL,
|
||||||
|
[requestData] [nvarchar](max) NULL,
|
||||||
|
[responseBodyData] [nvarchar](max) NULL,
|
||||||
|
[agent] [nvarchar](1000) NULL,
|
||||||
|
[actionName] [nvarchar](50) NULL,
|
||||||
|
[actionDescription] [nvarchar](50) NULL,
|
||||||
|
[controllerName] [nvarchar](50) NULL,
|
||||||
|
[controllerDescription] [nvarchar](50) NULL,
|
||||||
|
[statusCode] [int] NOT NULL,
|
||||||
|
[createTime] [datetime] NOT NULL,
|
||||||
|
[dataSources] [nvarchar](50) NULL,
|
||||||
|
CONSTRAINT [PK_SysUserOperationLog] PRIMARY KEY CLUSTERED
|
||||||
|
(
|
||||||
|
[id] ASC
|
||||||
|
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||||
|
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||||
|
GO
|
||||||
|
|
||||||
|
ALTER TABLE [dbo].[SysUserOperationLog] ADD CONSTRAINT [DF_SysUserOperationLog_userId] DEFAULT ((0)) FOR [userId]
|
||||||
|
GO
|
||||||
|
|
||||||
|
ALTER TABLE [dbo].[SysUserOperationLog] ADD CONSTRAINT [DF_SysUserOperationLog_statusCode] DEFAULT ((0)) FOR [statusCode]
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'id'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>˺<EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'userName'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>dz<EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'userNickName'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'userId'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP<EFBFBD><EFBFBD>ַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'ip'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'apiPath'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD>ʼʱ<EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'beginTime'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'endTime'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD>ʱ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'opTime'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'requestMethod'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'requestData'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'responseBodyData'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'agent'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'actionName'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'actionDescription'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'controllerName'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'controllerDescription'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'״̬<EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'statusCode'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'createTime'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog', @level2type=N'COLUMN',@level2name=N'dataSources'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysUserOperationLog'
|
||||||
|
GO
|
||||||
|
|
||||||
|
|
||||||
BIN
数据库/SqlServer/20220410/20220410完整数据库带演示商品.rar
Normal file
BIN
数据库/SqlServer/20220410/20220410完整数据库带演示商品.rar
Normal file
Binary file not shown.
BIN
数据库/SqlServer/20220410/2、添加菜单脚本.sql
Normal file
BIN
数据库/SqlServer/20220410/2、添加菜单脚本.sql
Normal file
Binary file not shown.
@@ -1,3 +1,6 @@
|
|||||||
|
2022-04-10
|
||||||
|
【新增】表【SysUserOperationLog】用户操作日志记录
|
||||||
|
|
||||||
2022-03-29
|
2022-03-29
|
||||||
【新增】表【CoreCmsInvoice】 新增 【fileUrl】发票下载地址字段
|
【新增】表【CoreCmsInvoice】 新增 【fileUrl】发票下载地址字段
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user