feat(log): 添加页面路由记录功能到操作日志
- 在 OperLogEvent 中新增 operPage 字段用于存储页面路由信息 - 在 SysOperLog 实体类中添加 operPage 属性并配置 Excel 导出 - 修改 LogAspect 切面类从请求头获取 X-Page-Route 并设置到操作日志 - 在前端请求拦截器中添加当前路由路径到请求头 X-Page-Route - 更新 SysOperLogMapper.xml 映射文件包含 operPage 字段映射
This commit is contained in:
@@ -96,6 +96,11 @@ public class OperLogEvent implements Serializable {
|
||||
*/
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 页面路由
|
||||
*/
|
||||
private String operPage;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
|
||||
@@ -72,6 +72,8 @@ public class LogAspect {
|
||||
String ip = ServletUtils.getClientIP();
|
||||
operLog.setOperIp(ip);
|
||||
operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
|
||||
// 从请求头获取前端页面路由
|
||||
operLog.setOperPage(StringUtils.substring(ServletUtils.getRequest().getHeader("X-Page-Route"), 0, 255));
|
||||
operLog.setOperName(LoginHelper.getUsername());
|
||||
|
||||
if (e != null) {
|
||||
|
||||
@@ -133,6 +133,12 @@ public class SysOperLog implements Serializable {
|
||||
@ExcelProperty(value = "操作时间")
|
||||
private Date operTime;
|
||||
|
||||
/**
|
||||
* 页面路由
|
||||
*/
|
||||
@ExcelProperty(value = "页面路由")
|
||||
private String operPage;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<result property="operName" column="oper_name"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<result property="operUrl" column="oper_url"/>
|
||||
<result property="operPage" column="oper_page"/>
|
||||
<result property="operIp" column="oper_ip"/>
|
||||
<result property="operLocation" column="oper_location"/>
|
||||
<result property="operParam" column="oper_param"/>
|
||||
|
||||
@@ -6,6 +6,7 @@ import errorCode from '@/utils/errorCode'
|
||||
import { tansParams, blobValidate } from "@/utils/klp";
|
||||
import cache from '@/plugins/cache'
|
||||
import { saveAs } from 'file-saver'
|
||||
import router from '@/router'
|
||||
|
||||
let downloadLoadingInstance;
|
||||
// 是否显示重新登录
|
||||
@@ -85,6 +86,10 @@ service.interceptors.request.use(config => {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 将当前页面路由放入请求头,供后端操作日志记录
|
||||
if (router.currentRoute && router.currentRoute.path) {
|
||||
config.headers['X-Page-Route'] = router.currentRoute.path
|
||||
}
|
||||
return config
|
||||
}, error => {
|
||||
console.log(error)
|
||||
|
||||
Reference in New Issue
Block a user