Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
ade70583
提交
ade70583
authored
2月 16, 2023
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
操作日志新增消耗时间属性
上级
5676cf9a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
53 行增加
和
10 行删除
+53
-10
LogAspect.java
.../src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
+20
-0
SysOperLog.java
...tem/src/main/java/com/ruoyi/system/domain/SysOperLog.java
+14
-0
SysOperLogMapper.xml
...tem/src/main/resources/mapper/system/SysOperLogMapper.xml
+4
-3
index.vue
ruoyi-ui/src/views/monitor/operlog/index.vue
+14
-7
ry_20230216.sql
sql/ry_20230216.sql
+1
-0
没有找到文件。
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
浏览文件 @
ade70583
...
@@ -8,8 +8,10 @@ import org.aspectj.lang.JoinPoint;
...
@@ -8,8 +8,10 @@ import org.aspectj.lang.JoinPoint;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.AfterThrowing
;
import
org.aspectj.lang.annotation.AfterThrowing
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.NamedThreadLocal
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -41,6 +43,18 @@ public class LogAspect
...
@@ -41,6 +43,18 @@ public class LogAspect
/** 排除敏感属性字段 */
/** 排除敏感属性字段 */
public
static
final
String
[]
EXCLUDE_PROPERTIES
=
{
"password"
,
"oldPassword"
,
"newPassword"
,
"confirmPassword"
};
public
static
final
String
[]
EXCLUDE_PROPERTIES
=
{
"password"
,
"oldPassword"
,
"newPassword"
,
"confirmPassword"
};
/** 计算操作消耗时间 */
private
static
final
ThreadLocal
<
Long
>
TIME_THREADLOCAL
=
new
NamedThreadLocal
<
Long
>(
"Cost Time"
);
/**
* 处理请求前执行
*/
@Before
(
value
=
"@annotation(controllerLog)"
)
public
void
boBefore
(
JoinPoint
joinPoint
,
Log
controllerLog
)
{
TIME_THREADLOCAL
.
set
(
System
.
currentTimeMillis
());
}
/**
/**
* 处理完请求后执行
* 处理完请求后执行
*
*
...
@@ -96,6 +110,8 @@ public class LogAspect
...
@@ -96,6 +110,8 @@ public class LogAspect
operLog
.
setRequestMethod
(
ServletUtils
.
getRequest
().
getMethod
());
operLog
.
setRequestMethod
(
ServletUtils
.
getRequest
().
getMethod
());
// 处理设置注解上的参数
// 处理设置注解上的参数
getControllerMethodDescription
(
joinPoint
,
controllerLog
,
operLog
,
jsonResult
);
getControllerMethodDescription
(
joinPoint
,
controllerLog
,
operLog
,
jsonResult
);
// 设置消耗时间
operLog
.
setCostTime
(
System
.
currentTimeMillis
()
-
TIME_THREADLOCAL
.
get
());
// 保存数据库
// 保存数据库
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordOper
(
operLog
));
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordOper
(
operLog
));
}
}
...
@@ -105,6 +121,10 @@ public class LogAspect
...
@@ -105,6 +121,10 @@ public class LogAspect
log
.
error
(
"异常信息:{}"
,
exp
.
getMessage
());
log
.
error
(
"异常信息:{}"
,
exp
.
getMessage
());
exp
.
printStackTrace
();
exp
.
printStackTrace
();
}
}
finally
{
TIME_THREADLOCAL
.
remove
();
}
}
}
/**
/**
...
...
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java
浏览文件 @
ade70583
...
@@ -83,6 +83,10 @@ public class SysOperLog extends BaseEntity
...
@@ -83,6 +83,10 @@ public class SysOperLog extends BaseEntity
@Excel
(
name
=
"操作时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd HH:mm:ss"
)
@Excel
(
name
=
"操作时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
operTime
;
private
Date
operTime
;
/** 消耗时间 */
@Excel
(
name
=
"消耗时间"
,
suffix
=
"毫秒"
)
private
Long
costTime
;
public
Long
getOperId
()
public
Long
getOperId
()
{
{
return
operId
;
return
operId
;
...
@@ -252,4 +256,14 @@ public class SysOperLog extends BaseEntity
...
@@ -252,4 +256,14 @@ public class SysOperLog extends BaseEntity
{
{
this
.
operTime
=
operTime
;
this
.
operTime
=
operTime
;
}
}
public
Long
getCostTime
()
{
return
costTime
;
}
public
void
setCostTime
(
Long
costTime
)
{
this
.
costTime
=
costTime
;
}
}
}
ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml
浏览文件 @
ade70583
...
@@ -21,16 +21,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -21,16 +21,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"status"
column=
"status"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"errorMsg"
column=
"error_msg"
/>
<result
property=
"errorMsg"
column=
"error_msg"
/>
<result
property=
"operTime"
column=
"oper_time"
/>
<result
property=
"operTime"
column=
"oper_time"
/>
<result
property=
"costTime"
column=
"cost_time"
/>
</resultMap>
</resultMap>
<sql
id=
"selectOperLogVo"
>
<sql
id=
"selectOperLogVo"
>
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time
, cost_time
from sys_oper_log
from sys_oper_log
</sql>
</sql>
<insert
id=
"insertOperlog"
parameterType=
"SysOperLog"
>
<insert
id=
"insertOperlog"
parameterType=
"SysOperLog"
>
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time)
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg,
cost_time,
oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate())
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg},
#{costTime},
sysdate())
</insert>
</insert>
<select
id=
"selectOperLogList"
parameterType=
"SysOperLog"
resultMap=
"SysOperLogResult"
>
<select
id=
"selectOperLogList"
parameterType=
"SysOperLog"
resultMap=
"SysOperLogResult"
>
...
...
ruoyi-ui/src/views/monitor/operlog/index.vue
浏览文件 @
ade70583
...
@@ -102,16 +102,15 @@
...
@@ -102,16 +102,15 @@
</el-row>
</el-row>
<el-table
ref=
"tables"
v-loading=
"loading"
:data=
"list"
@
selection-change=
"handleSelectionChange"
:default-sort=
"defaultSort"
@
sort-change=
"handleSortChange"
>
<el-table
ref=
"tables"
v-loading=
"loading"
:data=
"list"
@
selection-change=
"handleSelectionChange"
:default-sort=
"defaultSort"
@
sort-change=
"handleSortChange"
>
<el-table-column
type=
"selection"
width=
"5
5
"
align=
"center"
/>
<el-table-column
type=
"selection"
width=
"5
0
"
align=
"center"
/>
<el-table-column
label=
"日志编号"
align=
"center"
prop=
"operId"
/>
<el-table-column
label=
"日志编号"
align=
"center"
prop=
"operId"
/>
<el-table-column
label=
"系统模块"
align=
"center"
prop=
"title"
/>
<el-table-column
label=
"系统模块"
align=
"center"
prop=
"title"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"操作类型"
align=
"center"
prop=
"businessType"
>
<el-table-column
label=
"操作类型"
align=
"center"
prop=
"businessType"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<dict-tag
:options=
"dict.type.sys_oper_type"
:value=
"scope.row.businessType"
/>
<dict-tag
:options=
"dict.type.sys_oper_type"
:value=
"scope.row.businessType"
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"请求方式"
align=
"center"
prop=
"requestMethod"
/>
<el-table-column
label=
"操作人员"
align=
"center"
prop=
"operName"
width=
"110"
:show-overflow-tooltip=
"true"
sortable=
"custom"
:sort-orders=
"['descending', 'ascending']"
/>
<el-table-column
label=
"操作人员"
align=
"center"
prop=
"operName"
width=
"100"
:show-overflow-tooltip=
"true"
sortable=
"custom"
:sort-orders=
"['descending', 'ascending']"
/>
<el-table-column
label=
"操作地址"
align=
"center"
prop=
"operIp"
width=
"130"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"操作地址"
align=
"center"
prop=
"operIp"
width=
"130"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"操作地点"
align=
"center"
prop=
"operLocation"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"操作地点"
align=
"center"
prop=
"operLocation"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"操作状态"
align=
"center"
prop=
"status"
>
<el-table-column
label=
"操作状态"
align=
"center"
prop=
"status"
>
...
@@ -119,11 +118,16 @@
...
@@ -119,11 +118,16 @@
<dict-tag
:options=
"dict.type.sys_common_status"
:value=
"scope.row.status"
/>
<dict-tag
:options=
"dict.type.sys_common_status"
:value=
"scope.row.status"
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"操作日期"
align=
"center"
prop=
"operTime"
sortable=
"custom"
:sort-orders=
"['descending', 'ascending']"
width=
"180
"
>
<el-table-column
label=
"操作日期"
align=
"center"
prop=
"operTime"
width=
"160"
sortable=
"custom"
:sort-orders=
"['descending', 'ascending']
"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<span>
{{
parseTime
(
scope
.
row
.
operTime
)
}}
</span>
<span>
{{
parseTime
(
scope
.
row
.
operTime
)
}}
</span>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"消耗时间"
align=
"center"
prop=
"costTime"
width=
"110"
:show-overflow-tooltip=
"true"
sortable=
"custom"
:sort-orders=
"['descending', 'ascending']"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
costTime
}}
毫秒
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
>
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<el-button
<el-button
...
@@ -168,13 +172,16 @@
...
@@ -168,13 +172,16 @@
<el-col
:span=
"24"
>
<el-col
:span=
"24"
>
<el-form-item
label=
"返回参数:"
>
{{ form.jsonResult }}
</el-form-item>
<el-form-item
label=
"返回参数:"
>
{{ form.jsonResult }}
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"
12
"
>
<el-col
:span=
"
6
"
>
<el-form-item
label=
"操作状态:"
>
<el-form-item
label=
"操作状态:"
>
<div
v-if=
"form.status === 0"
>
正常
</div>
<div
v-if=
"form.status === 0"
>
正常
</div>
<div
v-else-if=
"form.status === 1"
>
失败
</div>
<div
v-else-if=
"form.status === 1"
>
失败
</div>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"12"
>
<el-col
:span=
"8"
>
<el-form-item
label=
"消耗时间:"
>
{{ form.costTime }}毫秒
</el-form-item>
</el-col>
<el-col
:span=
"10"
>
<el-form-item
label=
"操作时间:"
>
{{ parseTime(form.operTime) }}
</el-form-item>
<el-form-item
label=
"操作时间:"
>
{{ parseTime(form.operTime) }}
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"24"
>
<el-col
:span=
"24"
>
...
...
sql/ry_202
20822
.sql
→
sql/ry_202
30216
.sql
浏览文件 @
ade70583
...
@@ -432,6 +432,7 @@ create table sys_oper_log (
...
@@ -432,6 +432,7 @@ create table sys_oper_log (
status
int
(
1
)
default
0
comment
'操作状态(0正常 1异常)'
,
status
int
(
1
)
default
0
comment
'操作状态(0正常 1异常)'
,
error_msg
varchar
(
2000
)
default
''
comment
'错误消息'
,
error_msg
varchar
(
2000
)
default
''
comment
'错误消息'
,
oper_time
datetime
comment
'操作时间'
,
oper_time
datetime
comment
'操作时间'
,
cost_time
bigint
(
20
)
default
0
comment
'消耗时间'
,
primary
key
(
oper_id
)
primary
key
(
oper_id
)
)
engine
=
innodb
auto_increment
=
100
comment
=
'操作日志记录'
;
)
engine
=
innodb
auto_increment
=
100
comment
=
'操作日志记录'
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论