|
@@ -0,0 +1,47 @@
|
|
|
+package com.persagy.apm.common.aspect;
|
|
|
+
|
|
|
+import com.persagy.apm.common.context.poems.PoemsContext;
|
|
|
+import com.persagy.apm.energyalarmstarter.alarmdata.feign.AlarmUrlParam;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.aspectj.lang.JoinPoint;
|
|
|
+import org.aspectj.lang.annotation.Aspect;
|
|
|
+import org.aspectj.lang.annotation.Before;
|
|
|
+import org.aspectj.lang.annotation.Pointcut;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 调用alarm-data-starter接口时使用的切面
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/9/16 10:57 下午
|
|
|
+ **/
|
|
|
+@Aspect
|
|
|
+@Component
|
|
|
+public class AlarmDataAspect {
|
|
|
+ @Pointcut("execution(public * com.persagy.apm.energyalarmstarter.alarmdata.service.*.*(..))")
|
|
|
+ public void feignPointCut() {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Before("feignPointCut()")
|
|
|
+ public void before(JoinPoint joinPoint) {
|
|
|
+ List<Object> args = Arrays.asList(joinPoint.getArgs());
|
|
|
+ if (CollectionUtils.isEmpty(args)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Object arg : args) {
|
|
|
+ if (!(arg instanceof AlarmUrlParam)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 通用参数配置
|
|
|
+ AlarmUrlParam argParam = (AlarmUrlParam) arg;
|
|
|
+ argParam.setProjectId(PoemsContext.getContext().getProjectId());
|
|
|
+ argParam.setUserId(PoemsContext.getContext().getUserId());
|
|
|
+ argParam.setGroupCode(PoemsContext.getContext().getGroupCode());
|
|
|
+ argParam.setAppId("energy-alarm-service");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|