|
|
@@ -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("后台直播间列表变更");
|
|
|
+
|
|
|
+ }
|
|
|
+}
|