Browse Source

fix:admin切面

zhangqin 1 month ago
parent
commit
f3ed688d1e
1 changed files with 41 additions and 0 deletions
  1. 41 0
      fs-admin/src/main/java/com/fs/core/aspectj/LiveControllerAspect.java

+ 41 - 0
fs-admin/src/main/java/com/fs/core/aspectj/LiveControllerAspect.java

@@ -0,0 +1,41 @@
+package com.fs.core.aspectj;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.fs.live.domain.Live;
+import com.fs.live.service.ILiveService;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Aspect
+@Component
+public class LiveControllerAspect {
+
+    private static final Logger logger = LoggerFactory.getLogger(LiveControllerAspect.class);
+
+    @Autowired
+    private ILiveService liveService;
+
+    @AfterReturning(pointcut = "execution(* com.fs.live.controller.LiveController.add(..)) || " +
+            "execution(* com.fs.live.controller.LiveController.finishLive(..)) || " +
+            "execution(* com.fs.live.controller.LiveController.edit(..)) || " +
+            "execution(* com.fs.live.controller.LiveController.remove(..)) " ,
+            returning = "result")
+    public void afterLiveControllerMethodExecution(JoinPoint joinPoint,Object result) {
+        String methodName = joinPoint.getSignature().getName();
+        Object[] args = joinPoint.getArgs();
+        liveService.asyncToCache();
+        if (args[0] instanceof Live) {
+            Live live = (Live) args[0];
+            if (ObjectUtil.isNotEmpty(live) && ObjectUtil.isNotEmpty(live.getLiveId())){
+                liveService.asyncToCacheLiveDetail(live.getLiveId());
+            }
+        }
+        logger.info("后台直播间列表变更");
+
+    }
+}