mirror of https://gitee.com/y_project/RuoYi.git
操作日志新增返回参数
parent
64f0e9d282
commit
16270ae869
|
@ -36,6 +36,10 @@
|
|||
<label class="col-sm-2 control-label">请求参数:</label>
|
||||
<div class="form-control-static"><pre id="operParam"></pre></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">返回参数:</label>
|
||||
<div class="form-control-static"><pre id="jsonResult"></pre></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">状态:</label>
|
||||
<div class="form-control-static" th:class="${operLog.status == 0 ? 'label label-primary' : 'label label-danger'}" th:text="${operLog.status == 0 ? '正常' : '异常'}">
|
||||
|
@ -52,11 +56,17 @@
|
|||
<th:block th:include="include :: jsonview-js" />
|
||||
<script th:inline="javascript">
|
||||
$(function() {
|
||||
var json = [[${operLog.operParam}]];
|
||||
if ($.common.isNotEmpty(json) && json.length < 2000) {
|
||||
$("#operParam").JSONView(json);
|
||||
var operParam = [[${operLog.operParam}]];
|
||||
if ($.common.isNotEmpty(operParam) && operParam.length < 2000) {
|
||||
$("#operParam").JSONView(operParam);
|
||||
} else {
|
||||
$("#operParam").text(json);
|
||||
$("#operParam").text(operParam);
|
||||
}
|
||||
var jsonResult = [[${operLog.jsonResult}]];
|
||||
if ($.common.isNotEmpty(jsonResult) && jsonResult.length < 2000) {
|
||||
$("#jsonResult").JSONView(jsonResult);
|
||||
} else {
|
||||
$("#jsonResult").text(jsonResult);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -45,10 +45,10 @@ public class LogAspect
|
|||
*
|
||||
* @param joinPoint 切点
|
||||
*/
|
||||
@AfterReturning(pointcut = "logPointCut()")
|
||||
public void doAfterReturning(JoinPoint joinPoint)
|
||||
@AfterReturning(pointcut = "logPointCut()", returning = "jsonResult")
|
||||
public void doAfterReturning(JoinPoint joinPoint, Object jsonResult)
|
||||
{
|
||||
handleLog(joinPoint, null);
|
||||
handleLog(joinPoint, null, jsonResult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +60,10 @@ public class LogAspect
|
|||
@AfterThrowing(value = "logPointCut()", throwing = "e")
|
||||
public void doAfterThrowing(JoinPoint joinPoint, Exception e)
|
||||
{
|
||||
handleLog(joinPoint, e);
|
||||
handleLog(joinPoint, e, null);
|
||||
}
|
||||
|
||||
protected void handleLog(final JoinPoint joinPoint, final Exception e)
|
||||
protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -83,6 +83,8 @@ public class LogAspect
|
|||
// 请求的地址
|
||||
String ip = ShiroUtils.getIp();
|
||||
operLog.setOperIp(ip);
|
||||
// 返回参数
|
||||
operLog.setJsonResult(JSON.marshal(jsonResult));
|
||||
|
||||
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
|
||||
if (currentUser != null)
|
||||
|
|
|
@ -67,6 +67,10 @@ public class SysOperLog extends BaseEntity
|
|||
@Excel(name = "请求参数")
|
||||
private String operParam;
|
||||
|
||||
/** 返回参数 */
|
||||
@Excel(name = "返回参数")
|
||||
private String jsonResult;
|
||||
|
||||
/** 操作状态(0正常 1异常) */
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=异常")
|
||||
private Integer status;
|
||||
|
@ -209,6 +213,16 @@ public class SysOperLog extends BaseEntity
|
|||
this.operParam = operParam;
|
||||
}
|
||||
|
||||
public String getJsonResult()
|
||||
{
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
public void setJsonResult(String jsonResult)
|
||||
{
|
||||
this.jsonResult = jsonResult;
|
||||
}
|
||||
|
||||
public Integer getStatus()
|
||||
{
|
||||
return status;
|
||||
|
|
|
@ -17,19 +17,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="operIp" column="oper_ip" />
|
||||
<result property="operLocation" column="oper_location" />
|
||||
<result property="operParam" column="oper_param" />
|
||||
<result property="jsonResult" column="json_result" />
|
||||
<result property="status" column="status" />
|
||||
<result property="errorMsg" column="error_msg" />
|
||||
<result property="operTime" column="oper_time" />
|
||||
</resultMap>
|
||||
|
||||
<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, 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
|
||||
from sys_oper_log
|
||||
</sql>
|
||||
|
||||
<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, status, error_msg, oper_time)
|
||||
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{status}, #{errorMsg}, sysdate())
|
||||
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)
|
||||
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate())
|
||||
</insert>
|
||||
|
||||
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
|
||||
|
|
|
@ -416,6 +416,7 @@ create table sys_oper_log (
|
|||
oper_ip varchar(50) default '' comment '主机地址',
|
||||
oper_location varchar(255) default '' comment '操作地点',
|
||||
oper_param varchar(2000) default '' comment '请求参数',
|
||||
json_result varchar(2000) default '' comment '返回参数',
|
||||
status int(1) default 0 comment '操作状态(0正常 1异常)',
|
||||
error_msg varchar(2000) default '' comment '错误消息',
|
||||
oper_time datetime comment '操作时间',
|
Loading…
Reference in New Issue