Procházet zdrojové kódy

:white_check_mark: AutoLog日志优化

Twelve615 před 1 rokem
rodič
revize
df6afead8d

+ 9 - 0
airport/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/AutoLogAspect.java

@@ -2,6 +2,7 @@ package org.jeecg.common.aspect;
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.PropertyFilter;
+import com.google.common.base.Strings;
 import org.apache.shiro.SecurityUtils;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.ProceedingJoinPoint;
@@ -14,6 +15,7 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.enums.ModuleType;
+import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.modules.base.service.BaseCommonService;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.IPUtils;
@@ -104,6 +106,13 @@ public class AutoLogAspect {
             dto.setUserid(sysUser.getUsername());
             dto.setUsername(sysUser.getRealname());
 
+        } else {
+            String authorization = request.getHeader("Authorization");
+            if (!Strings.isNullOrEmpty(authorization)) {
+                String name = JwtUtil.getUsername(authorization);
+                dto.setUserid(name);
+                dto.setUsername(name);
+            }
         }
         //耗时
         dto.setCostTime(time);

+ 3 - 1
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aop/ControllerAspect.java

@@ -20,9 +20,11 @@ import org.jetbrains.annotations.NotNull;
 import org.springframework.core.io.InputStreamSource;
 import org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException;
 import org.springframework.stereotype.Component;
+import org.springframework.validation.BindingResult;
 import org.springframework.web.context.request.RequestAttributes;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.security.auth.message.AuthException;
 import javax.servlet.ServletRequest;
@@ -88,7 +90,7 @@ public class ControllerAspect {
             if (args != null) {
                 Object[] objects = new Object[args.length];
                 for (int i = 0; i < objects.length; i++) {
-                    if (args[i] instanceof ServletRequest || args[i] instanceof ServletResponse || args[i] instanceof InputStreamSource) {
+                    if (args[i] instanceof ServletRequest || args[i] instanceof ServletResponse || args[i] instanceof InputStreamSource || args[i] instanceof BindingResult|| args[i] instanceof MultipartFile) {
                         // 不打印request
                         continue;
                     }

+ 27 - 6
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/controller/APIController.java

@@ -126,7 +126,7 @@ public class APIController {
     }
 
     //    STLS
-    @PostMapping(value = "/a")
+/*    @PostMapping(value = "/a")
     public Result<String> a() {
         Result<String> result = new Result<String>();
         try {
@@ -309,8 +309,9 @@ public class APIController {
             result.setCode(0);
             return result;
         }
-    }
+    }*/
 
+    @AutoLog(value = "小程序-上传附件或图片", operateType = CommonConstant.OPERATE_TYPE_2)
     @ApiOperation(value = "上传附件和图片(小程序用)", notes = "上传附件和图片(小程序用)")
     @PostMapping(value = "/uploadLocality/{fileName}")
     public Result<String> uploadLocality2(MultipartFile file, @PathVariable String fileName, HttpServletRequest request) {
@@ -436,6 +437,7 @@ public class APIController {
         return result;
     }
 
+    @AutoLog(value = "小程序-授权登录", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "授权", notes = "授权")
     @PostMapping(value = "/authorization/{code}")
     public Result<JSONObject> authorization(@PathVariable String code) {
@@ -491,6 +493,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-用户匹配", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "用户匹配", notes = "用户匹配")
     @PostMapping(value = "/user_authorization")
     public Result<JSONObject> user_authorization(@RequestBody UserAuthorizationTO userAuthorizationTO) {
@@ -549,6 +552,7 @@ public class APIController {
         return result;
     }
 
+    @AutoLog(value = "小程序-用户信息修改", operateType = CommonConstant.OPERATE_TYPE_3)
     @ApiOperation(value = "用户信息修改", notes = "用户信息修改")
     @PostMapping(value = "/user_edit")
     public Result<String> user_edit(@RequestHeader("Authorization") String Authorization, @RequestBody UserEditTO userEditTO) {
@@ -598,6 +602,7 @@ public class APIController {
     }
 
     //得修改  状态判断不对
+    @AutoLog(value = "小程序-机位列表", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "机位列表", notes = "机位列表")
     @PostMapping(value = "/adminAircraftPositionList")
     public Result<IPage<AdminAircraftPositionR>> adminAircraftPositionList(@RequestHeader("Authorization") String Authorization, @RequestBody AdminAircraftPositionListTO adminAircraftPositionListTO,
@@ -676,6 +681,7 @@ public class APIController {
     }
 
 
+    @AutoLog(value = "小程序-提交到岗", operateType = CommonConstant.OPERATE_TYPE_2)
     @ApiOperation(value = "提交到岗", notes = "提交到岗")
     @PostMapping(value = "/submitToPost")
     @Transactional
@@ -755,7 +761,7 @@ public class APIController {
      * @param adminPostRecordItem
      * @return
      */
-    @AutoLog(value = "岗位异常信息-添加")
+    @AutoLog(value = "小程序-岗位异常信息-添加", operateType = CommonConstant.OPERATE_TYPE_2)
     @ApiOperation(value="岗位异常信息-添加", notes="岗位异常信息-添加")
     @PostMapping(value = "/addAdminPostRecordItem")
     public Result<?> add(@RequestHeader("Authorization") String Authorization, @RequestBody AdminPostRecordItem adminPostRecordItem) {
@@ -797,7 +803,7 @@ public class APIController {
         return Result.OK("添加成功!");
     }
 
-    @AutoLog(value = "岗位异常信息-分页列表查询")
+    @AutoLog(value = "小程序-岗位异常信息分页列表查询", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value="岗位异常信息-分页列表查询", notes="岗位异常信息-分页列表查询")
     @GetMapping(value = "/listAdminPostRecordItem")
     public Result<?> queryPageList(@RequestHeader("Authorization") String Authorization, AdminPostRecordItem adminPostRecordItem,
@@ -943,6 +949,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-提交岗位记录", operateType = CommonConstant.OPERATE_TYPE_2)
     @ApiOperation(value = "提交岗位记录", notes = "提交岗位记录")
     @PostMapping(value = "/setAdminPostRecord")
     @Transactional
@@ -1038,6 +1045,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-查询岗位记录", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "提交岗位列表", notes = "提交岗位记录")
     @PostMapping(value = "/adminPostRecordList")
     public Result<IPage<AdminPostRecord>> AdminPostRecordList(@RequestHeader("Authorization") String Authorization,
@@ -1085,6 +1093,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-提交廊桥测试", operateType = CommonConstant.OPERATE_TYPE_2)
     @ApiOperation(value = "提交廊桥测试", notes = "提交廊桥测试")
     @PostMapping(value = "/setAdminAirbridgeTest")
     public Result<String> setAdminAirbridgeTest(@RequestHeader("Authorization") String Authorization,
@@ -1176,6 +1185,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-查询廊桥测试记录", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "廊桥测试列表", notes = "廊桥测试记录")
     @PostMapping(value = "/adminAirbridgeTestList")
     public Result<IPage<AdminAirbridgeTest>> AdminAirbridgeTestList(@RequestHeader("Authorization") String Authorization,
@@ -1284,6 +1294,7 @@ public class APIController {
     }
 
     //发起交接要创建安检还有订单
+    @AutoLog(value = "小程序-发起交接", operateType = CommonConstant.OPERATE_TYPE_2)
     @ApiOperation(value = "发起交接", notes = "发起交接")
     @PostMapping(value = "/initiateHandover")
     public Result<String> initiateHandover(@RequestHeader("Authorization") String Authorization,
@@ -1356,6 +1367,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-手动关闭交接订单", operateType = CommonConstant.OPERATE_TYPE_3)
     @ApiOperation(value = "手动结束订单(安检id)", notes = "手动结束订单(安检id)")
     @PostMapping(value = "/manual_termination_order/{id}")
     public Result<Boolean> manual_termination_order(@RequestHeader("Authorization") String Authorization,
@@ -1413,6 +1425,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-手动恢复交接订单", operateType = CommonConstant.OPERATE_TYPE_3)
     @ApiOperation(value = "手动恢复订单(订单orderNum)", notes = "手动恢复订单(订单orderNum)")
     @PostMapping(value = "/recoveryTerminationOrder/{orderNum}")
     public Result<Boolean> recoveryTerminationOrder(@RequestHeader("Authorization") String Authorization,
@@ -1600,6 +1613,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-获取安检列表", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "获取安检列表", notes = "获取安检列表")
     @PostMapping(value = "/getSecurityCheckList")
     public Result<IPage<AdminSecurityCheck>> getSecurityCheckList(@RequestHeader("Authorization") String Authorization,
@@ -1645,7 +1659,7 @@ public class APIController {
         }
     }
 
-
+    @AutoLog(value = "小程序-提交交出安检信息", operateType = CommonConstant.OPERATE_TYPE_2)
     @ApiOperation(value = "提交交出安检信息", notes = "提交交出安检信息")
     @PostMapping(value = "/setSecurityMessage")
     public Result<String> setSecurityMessage(@RequestHeader("Authorization") String Authorization,
@@ -1740,6 +1754,7 @@ public class APIController {
     }
 
 
+    @AutoLog(value = "小程序-撤销暂存", operateType = CommonConstant.OPERATE_TYPE_3)
     @ApiOperation(value = "撤销暂存", notes = "提交交出安检信息")
     @PostMapping(value = "/delectSecurityMessage")
     public Result<String> delectSecurityMessage(@RequestHeader("Authorization") String Authorization,
@@ -1792,7 +1807,7 @@ public class APIController {
 
 
     //-------------------------- 订单 ++++++++++++++++++++++++++++++++++++
-
+    @AutoLog(value = "小程序-查询交接记录", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "获取订单列表(交接记录)", notes = "获取订单列表(交接记录)")
     @PostMapping(value = "/getOrderList")
     public Result<IPage<AdminOrder>> getOrderList(@RequestHeader("Authorization") String Authorization,
@@ -1847,6 +1862,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-查看订单(交接记录)详情", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "查看订单(交接记录)详情", notes = "查看订单(交接记录)详情")
     @GetMapping(value = "/getOrderExamine/{orderId}")
     public Result<List<AdminOrderExamine>> getOrderExamine(@RequestHeader("Authorization") String Authorization,
@@ -1891,6 +1907,7 @@ public class APIController {
     }
 
     //一个人一个订单下的记录(查看详情里面点进去的)
+    @AutoLog(value = "小程序-查询修改记录", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "交接记录的修改记录", notes = "交接记录的修改记录")
     @GetMapping(value = "/getEditMessage/{orderNum}")
     public Result<List<AdminEditMessage>> getEditMessage(@RequestHeader("Authorization") String Authorization,
@@ -1937,6 +1954,7 @@ public class APIController {
     }
 
     //交接记录修改  交接记录信息1.修改原有交接记录信息和添加修改记录 2.如果超时(判断状态让前端传审批中)就先添加修改记录等待管理通过后在修改交接记录信息
+    @AutoLog(value = "小程序-修改交接记录", operateType = CommonConstant.OPERATE_TYPE_3)
     @ApiOperation(value = "交接记录修改 超时type 1,没有超时 2", notes = "交接记录修改超时type 1,没有超时 2")
     @PostMapping(value = "/recordEdit/{type}")
     public Result<String> recordEdit(@RequestHeader("Authorization") String Authorization,
@@ -2055,6 +2073,7 @@ public class APIController {
     }
 
     //全部修改记录
+    @AutoLog(value = "小程序-获取全部修改记录列表", operateType = CommonConstant.OPERATE_TYPE_1)
     @ApiOperation(value = "获取全部修改记录列表", notes = "获取全部修改记录列表")
     @PostMapping(value = "/EditMessageAll")
     public Result<IPage<AdminEditMessage>> EditMessageAll(@RequestHeader("Authorization") String Authorization,
@@ -2111,6 +2130,7 @@ public class APIController {
     }
 
 
+    @AutoLog(value = "小程序-撤销审批修改记录", operateType = CommonConstant.OPERATE_TYPE_3)
     @ApiOperation(value = "撤销审批修改记录", notes = "撤销审批修改记录")
     @PostMapping(value = "/revocationOfApproval/{id}")
     public Result<String> revocationOfApproval(@RequestHeader("Authorization") String Authorization,
@@ -2163,6 +2183,7 @@ public class APIController {
         }
     }
 
+    @AutoLog(value = "小程序-重新提交修改记录", operateType = CommonConstant.OPERATE_TYPE_3)
     @ApiOperation(value = "重新提交修改记录", notes = "重新提交修改记录")
     @PostMapping(value = "/resubmit/{id}")
     public Result<String> resubmit(@RequestHeader("Authorization") String Authorization,