From 1d53dd8f501a98ddcce8146443b51b357ef5f9b1 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 29 十二月 2022 16:55:46 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/aspect/LogAspect.java |   45 ++++++++++++++++++++++++++++-----------------
 1 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/lf/server/aspect/LogAspect.java b/src/main/java/com/lf/server/aspect/LogAspect.java
index 527b555..e76b01e 100644
--- a/src/main/java/com/lf/server/aspect/LogAspect.java
+++ b/src/main/java/com/lf/server/aspect/LogAspect.java
@@ -1,7 +1,8 @@
 package com.lf.server.aspect;
 
+import com.lf.server.annotation.SysLog;
 import com.lf.server.entity.sys.OperateEntity;
-import com.lf.server.entity.sys.UsersEntity;
+import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.WebHelper;
 import com.lf.server.service.sys.OperateService;
 import com.lf.server.service.sys.TokenService;
@@ -32,21 +33,25 @@
     @Autowired
     private OperateService operateService;
 
-    private final static String SELECT = "select";
+    private final static String SELECT = "/select";
 
-    private final static String INSERT = "insert";
+    private final static String INSERT = "/insert";
 
-    private final static String UPDATE = "update";
+    private final static String UPDATE = "/update";
 
-    private final static String DELETE = "delete";
+    private final static String DELETE = "/delete";
 
-    private final static String UPLOAD = "upload";
+    private final static String UPLOAD = "/upload";
 
-    private final static String DOWNLOAD = "download";
+    private final static String DOWNLOAD = "/download";
+
+    private final static String COUNT = "/count";
+
+    private final static String SPLIT = "\\\\";
 
     private static final Log log = LogFactory.getLog(LogAspect.class);
 
-    @Pointcut("@annotation(com.lf.server.aspect.SysLog)")
+    @Pointcut("@annotation(com.lf.server.annotation.SysLog)")
     public void logPointCut() {
         //
     }
@@ -90,7 +95,9 @@
             // 璁剧疆妯″潡
             Api api = clazz.getAnnotation(Api.class);
             if (api != null) {
-                oe.setModular(api.tags()[0]);
+                String[] strs = api.tags()[0].split(SPLIT);
+                oe.setModular1(strs[0]);
+                oe.setModular2(strs[1]);
             }
 
             // 璁剧疆绫诲悕\鏂规硶鍚嶃�佺被鍒�
@@ -103,14 +110,14 @@
                 oe.setBak(sysLog.value());
             }
 
-            UsersEntity ue = tokenService.getCurrentUser(req);
+            UserEntity ue = tokenService.getCurrentUser(req);
             if (ue != null) {
                 oe.setUserid(ue.getId());
             }
 
             operateService.insertOperate(oe);
         } catch (Exception ex) {
-            log.error(ex.getStackTrace());
+            log.error(ex.getMessage(), ex);
         }
     }
 
@@ -118,24 +125,28 @@
      * 鑾峰彇鎿嶄綔绫诲瀷
      */
     private static int getType(String methodName) {
-        if (methodName.indexOf(SELECT) > -1) {
+        if (methodName.contains(SELECT)) {
             return 1;
         }
-        if (methodName.indexOf(INSERT) > -1) {
+        if (methodName.contains(INSERT)) {
             return 2;
         }
-        if (methodName.indexOf(UPDATE) > -1) {
+        if (methodName.contains(UPDATE)) {
             return 3;
         }
-        if (methodName.indexOf(DELETE) > -1) {
+        if (methodName.contains(DELETE)) {
             return 4;
         }
-        if (methodName.indexOf(UPLOAD) > -1) {
+        if (methodName.contains(UPLOAD)) {
             return 5;
         }
-        if (methodName.indexOf(DOWNLOAD) > -1) {
+        if (methodName.contains(DOWNLOAD)) {
             return 6;
         }
+        // methodName.indexOf(COUNT) > -1
+        if (methodName.contains(COUNT)) {
+            return 7;
+        }
 
         return 0;
     }

--
Gitblit v1.9.3