From eeeddf0836a5a5aa03a3342d34318c7202313e93 Mon Sep 17 00:00:00 2001
From: 唐耀东 <18861537@qq.com>
Date: 星期四, 09 十二月 2021 15:02:30 +0800
Subject: [PATCH] 提交代码
---
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
index 642076d..db4ceac 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
@@ -1,11 +1,14 @@
package com.ruoyi.framework.aspectj;
import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.domain.dto.EquipmentLogDTO;
import com.ruoyi.common.core.domain.dto.OperLogDTO;
import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.core.service.EquipmentService;
import com.ruoyi.common.core.service.OperLogService;
import com.ruoyi.common.enums.BusinessStatus;
import com.ruoyi.common.enums.HttpMethod;
+import com.ruoyi.common.enums.LogType;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
@@ -65,18 +68,28 @@
// *========鏁版嵁搴撴棩蹇�=========*//
OperLogDTO operLog = new OperLogDTO();
+ // 鑱旀満鏃ュ織
+ EquipmentLogDTO equipmentLogDTO = new EquipmentLogDTO();
+
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
+ equipmentLogDTO.setStatus(BusinessStatus.SUCCESS.ordinal());
+
// 璇锋眰鐨勫湴鍧�
String ip = ServletUtils.getClientIP();
operLog.setOperIp(ip);
+ equipmentLogDTO.setIp(ip);
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
if (loginUser != null) {
operLog.setOperName(loginUser.getUsername());
+ equipmentLogDTO.setUserName(loginUser.getUsername());
}
if (e != null) {
operLog.setStatus(BusinessStatus.FAIL.ordinal());
operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
+
+ equipmentLogDTO.setStatus(BusinessStatus.FAIL.ordinal());
+ equipmentLogDTO.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
}
// 璁剧疆鏂规硶鍚嶇О
String className = joinPoint.getTarget().getClass().getName();
@@ -86,8 +99,15 @@
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
// 澶勭悊璁剧疆娉ㄨВ涓婄殑鍙傛暟
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
- // 淇濆瓨鏁版嵁搴�
- SpringUtils.getBean(OperLogService.class).recordOper(operLog);
+ if (LogType.SYS_LOG.ordinal() == controllerLog.type().ordinal()) {
+ // 淇濆瓨鏁版嵁搴�
+ SpringUtils.getBean(OperLogService.class).recordOper(operLog);
+ }
+ if (LogType.EQUIPMENT_LOG.ordinal() == controllerLog.type().ordinal()) {
+ equipmentLogDTO.setOperation(controllerLog.operation().ordinal());
+ // 淇濆瓨鏁版嵁搴�
+ SpringUtils.getBean(EquipmentService.class).recordOper(equipmentLogDTO);
+ }
} catch (Exception exp) {
// 璁板綍鏈湴寮傚父鏃ュ織
log.error("==鍓嶇疆閫氱煡寮傚父==");
@@ -181,6 +201,6 @@
}
}
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
- || o instanceof BindingResult;
+ || o instanceof BindingResult;
}
}
--
Gitblit v1.9.1