From dc3cb5dea834cde14d1b527c22b35f1d5faebd5a Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期六, 15 二月 2025 19:26:55 +0800
Subject: [PATCH] zjh20250215

---
 ltkj-framework/src/main/java/com/ltkj/framework/aspectj/AsynAspect.java |   42 +++++++++++++++---------------------------
 1 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/ltkj-framework/src/main/java/com/ltkj/framework/aspectj/AsynAspect.java b/ltkj-framework/src/main/java/com/ltkj/framework/aspectj/AsynAspect.java
index 1993ebf..0e11b1f 100644
--- a/ltkj-framework/src/main/java/com/ltkj/framework/aspectj/AsynAspect.java
+++ b/ltkj-framework/src/main/java/com/ltkj/framework/aspectj/AsynAspect.java
@@ -1,62 +1,50 @@
 package com.ltkj.framework.aspectj;
 
-import com.ltkj.common.annotation.DataSource;
-import com.ltkj.common.utils.StringUtils;
 import com.ltkj.db.DataSourceContextHolder;
 import com.ltkj.framework.datasource.DynamicDataSourceContextHolder;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Pointcut;
-import org.aspectj.lang.reflect.MethodSignature;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
-
-import java.util.Objects;
 
 /**
  * ClassName: AsynAspect <br/>
- * Description: <br/>
+ * Description: 鍦ㄥ紓姝ユ柟娉曟墽琛屾椂锛岃幏鍙栧苟浼犻�掑綋鍓嶇嚎绋嬬殑鏁版嵁婧愩��<br/>
  * date: 2025/2/15 18:07<br/>
  *
  * @author zjh<br />
  */
 @Aspect
-@Order(2)
 @Component
 public class AsynAspect {
 
-    protected Logger logger = LoggerFactory.getLogger(getClass());
+    private static final Logger logger = LoggerFactory.getLogger(AsynAspect.class);
 
-    @Pointcut("@annotation(org.springframework.scheduling.annotation.Async)"
-            + "|| @within(org.springframework.scheduling.annotation.Async)")
-    public void dsPointCut() {
-
+    @Pointcut("@annotation(org.springframework.scheduling.annotation.Async) || @within(org.springframework.scheduling.annotation.Async)")
+    public void asyncPointCut() {
+        // 寮傛鏂规硶鍒囧叆鐐�
     }
 
-    @Around("dsPointCut()")
+    @Around("asyncPointCut()")
     public Object around(ProceedingJoinPoint point) throws Throwable {
-        String key = DataSourceContextHolder.getDataSourceKey();
-        logger.info("鎵ц涔嬪墠");
-        logger.info("DataSourceContextHolder ->{}",key);
-        logger.info("DynamicDataSourceContextHolder ->{}", DynamicDataSourceContextHolder.getDataSourceType());
+        // 鑾峰彇褰撳墠绾跨▼鐨� DataSource
+        String currentDataSource = DataSourceContextHolder.getDataSourceKey();
 
-        DynamicDataSourceContextHolder.setDataSourceType(key);
+        logger.info("褰撳墠绾跨▼鏁版嵁婧�: {}", currentDataSource);
+
+        // 鍦ㄥ紓姝ユ柟娉曟墽琛屽墠锛岃缃暟鎹簮鍒� DynamicDataSourceContextHolder
+        DynamicDataSourceContextHolder.setDataSourceType(currentDataSource);
 
         try {
+            // 鎵ц寮傛鏂规硶
             return point.proceed();
         } finally {
-            logger.info("鎵ц涔嬪悗");
-            logger.info("DataSourceContextHolder ->{}",key);
-            logger.info("DynamicDataSourceContextHolder ->{}",DynamicDataSourceContextHolder.getDataSourceType());
-            // 閿�姣佹暟鎹簮 鍦ㄦ墽琛屾柟娉曚箣鍚�
+            // 鎵ц瀹屾瘯鍚庢竻鐞嗘暟鎹簮
             DynamicDataSourceContextHolder.clearDataSourceType();
-            logger.info("鎵ц涔嬪悗 clear涔嬪悗");
-            logger.info("DataSourceContextHolder ->{}",key);
-            logger.info("DynamicDataSourceContextHolder ->{}",DynamicDataSourceContextHolder.getDataSourceType());
+            logger.info("娓呯悊鏁版嵁婧愶紝鎭㈠榛樿鏁版嵁婧�");
         }
     }
 }

--
Gitblit v1.8.0