From 6200ba627af8af4045155c1bd7e65220ce59d6ba Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 15 一月 2026 14:36:36 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/config/AspectConfig.java |   49 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/src/main/java/com/zy/common/config/AspectConfig.java b/src/main/java/com/zy/common/config/AspectConfig.java
index 3a72029..91fa0b6 100644
--- a/src/main/java/com/zy/common/config/AspectConfig.java
+++ b/src/main/java/com/zy/common/config/AspectConfig.java
@@ -8,6 +8,7 @@
 import com.zy.asrs.entity.ApiLog;
 import com.zy.asrs.service.ApiLogService;
 import com.zy.common.annotations.OpenApiLog;
+import com.zy.system.timer.LicenseTimer;
 import lombok.extern.slf4j.Slf4j;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
@@ -36,6 +37,8 @@
 
     @Autowired
     private ApiLogService apiLogService;
+    @Autowired
+    private LicenseTimer licenseTimer;
 
     @Pointcut("execution(* com.zy.asrs.controller.*(..))")
     private void webLog() {
@@ -44,17 +47,26 @@
     @Around("@within(org.springframework.web.bind.annotation.RestController)" +
             "||@within(org.springframework.stereotype.Controller)")
     public Object after(ProceedingJoinPoint joinPoint) throws Throwable {
-        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
+                .getRequestAttributes();
         HttpServletRequest request = requestAttributes != null ? requestAttributes.getRequest() : null;
         long start = System.currentTimeMillis();
         MethodSignature signature = (MethodSignature) joinPoint.getSignature();
         Method method = signature.getMethod();
-        OpenApiLog annotation = method.isAnnotationPresent(OpenApiLog.class) ? method.getAnnotation(OpenApiLog.class) : null;
+        OpenApiLog annotation = method.isAnnotationPresent(OpenApiLog.class) ? method.getAnnotation(OpenApiLog.class)
+                : null;
         Object result = null;
         Object errorResponse = null;
         try {
             result = joinPoint.proceed(joinPoint.getArgs());
             if (annotation != null && !Cools.isEmpty(annotation.memo())) {
+                if (licenseTimer != null && !licenseTimer.getSystemSupport()) {
+                    Object fail = R.error("璁稿彲璇佸け鏁�");
+                    if (annotation != null && !Cools.isEmpty(annotation.memo())) {
+                        saveErrLog(joinPoint, request, fail, new CoolException("璁稿彲璇佸け鏁�"), annotation.memo());
+                    }
+                    return fail;
+                }
                 saveLog(joinPoint, request, result, annotation.memo());
             }
             return result;
@@ -63,16 +75,22 @@
             if (annotation != null && !Cools.isEmpty(annotation.memo())) {
                 saveErrLog(joinPoint, request, errorResponse, ex, annotation.memo());
             }
-            throw ex;
+            if (ex instanceof Exception) {
+                throw (Exception) ex;
+            }
+            throw new RuntimeException(ex);
         } finally {
             long end = System.currentTimeMillis();
-//            log.info("璇锋眰鏃ュ織鐨勬墦鍗�");
-//            log.info("璇锋眰鍦板潃:{}", request != null ? Optional.ofNullable(request.getRequestURI()).orElse(null) : null);
-//            log.info("璇锋眰鏂瑰紡:{}", request != null ? request.getMethod() : null);
-//            log.info("璇锋眰绫绘柟娉�:{}", joinPoint.getSignature());
-//            log.info("璇锋眰绫绘柟娉曞弬鏁�:{}", JSONObject.toJSONString(filterArgs(joinPoint.getArgs())));
-//            log.info("璇锋眰鍝嶅簲鍙傛暟{}", JSONObject.toJSONString(result != null ? result : errorResponse));
-//            log.info("鎵ц鑰楁椂:{}", end - start);
+            // log.info("璇锋眰鏃ュ織鐨勬墦鍗�");
+            // log.info("璇锋眰鍦板潃:{}", request != null ?
+            // Optional.ofNullable(request.getRequestURI()).orElse(null) : null);
+            // log.info("璇锋眰鏂瑰紡:{}", request != null ? request.getMethod() : null);
+            // log.info("璇锋眰绫绘柟娉�:{}", joinPoint.getSignature());
+            // log.info("璇锋眰绫绘柟娉曞弬鏁�:{}",
+            // JSONObject.toJSONString(filterArgs(joinPoint.getArgs())));
+            // log.info("璇锋眰鍝嶅簲鍙傛暟{}", JSONObject.toJSONString(result != null ? result :
+            // errorResponse));
+            // log.info("鎵ц鑰楁椂:{}", end - start);
         }
     }
 
@@ -97,11 +115,11 @@
                 1,
                 new Date(),
                 null,
-                null
-        ));
+                null));
     }
 
-    private void saveErrLog(ProceedingJoinPoint joinPoint, HttpServletRequest request, Object response, Throwable ex, String memo) {
+    private void saveErrLog(ProceedingJoinPoint joinPoint, HttpServletRequest request, Object response, Throwable ex,
+                            String memo) {
         apiLogService.insert(new ApiLog(
                 null,
                 memo,
@@ -116,13 +134,12 @@
                 1,
                 new Date(),
                 null,
-                null
-        ));
+                null));
     }
 
     private Object buildErrorResponse(Throwable ex) {
         if (ex instanceof CoolException) {
-            return R.parse(ex.getMessage());
+            return R.error(ex.getMessage());
         }
         return R.error();
     }

--
Gitblit v1.9.1