|
@@ -0,0 +1,41 @@
|
|
|
|
+package com.lantone.qc.kernel.web.config;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.diagbot.annotation.EnableMonitor;
|
|
|
|
+import com.diagbot.aop.InterfaceLogAspect;
|
|
|
|
+import com.diagbot.interceptor.CustomInterceptor;
|
|
|
|
+import com.diagbot.interceptor.FeignRequestInterceptor;
|
|
|
|
+import feign.RequestInterceptor;
|
|
|
|
+import feign.RequestTemplate;
|
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
|
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
+
|
|
|
|
+@Configuration
|
|
|
|
+@ConditionalOnBean(annotation = { EnableMonitor.class})
|
|
|
|
+public class MonitorAutoConfiguration implements WebMvcConfigurer {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
+ registry.addInterceptor(new CustomInterceptor())
|
|
|
|
+ .addPathPatterns("/**").excludePathPatterns("/static/**", "/css/**", "/js/**"); // 排除静态资源
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Bean
|
|
|
|
+ @Lazy
|
|
|
|
+ public InterfaceLogAspect interfaceLogAspect() {
|
|
|
|
+ return new InterfaceLogAspect();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Bean
|
|
|
|
+ @Lazy
|
|
|
|
+ @ConditionalOnClass({
|
|
|
|
+ RequestInterceptor.class, RequestTemplate.class})
|
|
|
|
+ public FeignRequestInterceptor feignRequestInterceptor() {
|
|
|
|
+ return new FeignRequestInterceptor();
|
|
|
|
+ }
|
|
|
|
+}
|