menus = new ArrayList<>();
for (SysMenu sysMenu : sysMenus) {
- if (ObjectUtils.equals(-1L, sysMenu.getParentId())) {
+ if (ObjectUtil.equal(-1L, sysMenu.getParentId())) {
menus.add(sysMenu);
}
for (SysMenu menu : sysMenus) {
diff --git a/zlt-commons/pom.xml b/zlt-commons/pom.xml
index c8fa009c..0f78ccaf 100644
--- a/zlt-commons/pom.xml
+++ b/zlt-commons/pom.xml
@@ -16,7 +16,7 @@
zlt-db-spring-boot-starter
zlt-swagger2-spring-boot-starter
zlt-log-spring-boot-starter
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
zlt-auth-client-spring-boot-starter
zlt-sentinel-spring-boot-starter
zlt-common-core
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
index 954cf054..c08a178b 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
@@ -25,6 +25,9 @@ import java.util.stream.Collectors;
*
* @author zlt
* @date 2018/10/28
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
@Slf4j
public abstract class DefaultPermissionServiceImpl {
@@ -32,7 +35,7 @@ public abstract class DefaultPermissionServiceImpl {
@Autowired
private SecurityProperties securityProperties;
- private AntPathMatcher antPathMatcher = new AntPathMatcher();
+ private final AntPathMatcher antPathMatcher = new AntPathMatcher();
/**
* 查询当前用户拥有的资源权限
diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java
index cde1ff9a..1b7bbec8 100644
--- a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java
+++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java
@@ -3,7 +3,7 @@ package com.central.common.feign.fallback;
import com.central.common.feign.UserService;
import com.central.common.model.LoginAppUser;
import com.central.common.model.SysUser;
-import feign.hystrix.FallbackFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
/**
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/pom.xml b/zlt-commons/zlt-loadbalancer-spring-boot-starter/pom.xml
similarity index 87%
rename from zlt-commons/zlt-ribbon-spring-boot-starter/pom.xml
rename to zlt-commons/zlt-loadbalancer-spring-boot-starter/pom.xml
index 1c212de0..09797311 100644
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/pom.xml
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/pom.xml
@@ -1,48 +1,48 @@
-
-
-
- com.zlt
- zlt-commons
- 4.6.0
-
- 4.0.0
- jar
- zlt-ribbon-spring-boot-starter
- 远程通信通用组件
-
-
- com.zlt
- zlt-common-core
-
-
- org.springframework.cloud
- spring-cloud-starter-openfeign
-
-
- org.springframework.cloud
- spring-cloud-starter-netflix-ribbon
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-discovery
- true
-
-
- org.apache.httpcomponents
- httpclient
-
-
- javax.servlet
- javax.servlet-api
- true
-
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- true
-
-
-
+
+
+
+ com.zlt
+ zlt-commons
+ 4.6.0
+
+ 4.0.0
+ jar
+ zlt-loadbalancer-spring-boot-starter
+ 负载均衡通用组件
+
+
+ com.zlt
+ zlt-common-core
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+ true
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ javax.servlet
+ javax.servlet-api
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/RestTemplateAutoConfigure.java b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/RestTemplateAutoConfigure.java
similarity index 88%
rename from zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/RestTemplateAutoConfigure.java
rename to zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/RestTemplateAutoConfigure.java
index c96fb859..090a1d3f 100644
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/RestTemplateAutoConfigure.java
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/RestTemplateAutoConfigure.java
@@ -1,77 +1,80 @@
-package com.central.common.ribbon;
-
-import com.central.common.ribbon.config.RestTemplateProperties;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.cloud.client.loadbalancer.LoadBalanced;
-import org.springframework.context.annotation.Bean;
-import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * @author zlt
- * @date 2018/11/17
- */
-@EnableConfigurationProperties(RestTemplateProperties.class)
-public class RestTemplateAutoConfigure {
- @Autowired
- private RestTemplateProperties restTemplateProperties;
-
- @LoadBalanced
- @Bean
- public RestTemplate restTemplate() {
- RestTemplate restTemplate = new RestTemplate();
- restTemplate.setRequestFactory(httpRequestFactory());
- return restTemplate;
- }
-
- /**
- * httpclient 实现的ClientHttpRequestFactory
- */
- @Bean
- public ClientHttpRequestFactory httpRequestFactory() {
- return new HttpComponentsClientHttpRequestFactory(httpClient());
- }
-
- /**
- * 使用连接池的 httpclient
- */
- @Bean
- public HttpClient httpClient() {
- Registry registry = RegistryBuilder.create()
- .register("http", PlainConnectionSocketFactory.getSocketFactory())
- .register("https", SSLConnectionSocketFactory.getSocketFactory())
- .build();
- PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
- // 最大链接数
- connectionManager.setMaxTotal(restTemplateProperties.getMaxTotal());
- // 同路由并发数20
- connectionManager.setDefaultMaxPerRoute(restTemplateProperties.getMaxPerRoute());
-
- RequestConfig requestConfig = RequestConfig.custom()
- // 读超时
- .setSocketTimeout(restTemplateProperties.getReadTimeout())
- // 链接超时
- .setConnectTimeout(restTemplateProperties.getConnectTimeout())
- // 链接不够用的等待时间
- .setConnectionRequestTimeout(restTemplateProperties.getReadTimeout())
- .build();
-
- return HttpClientBuilder.create()
- .setDefaultRequestConfig(requestConfig)
- .setConnectionManager(connectionManager)
- .setRetryHandler(new DefaultHttpRequestRetryHandler(3, true))
- .build();
- }
-}
+package com.central.common.lb;
+
+import com.central.common.lb.config.RestTemplateProperties;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.http.client.ClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author zlt
+ * @date 2018/11/17
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@EnableConfigurationProperties(RestTemplateProperties.class)
+public class RestTemplateAutoConfigure {
+ @Autowired
+ private RestTemplateProperties restTemplateProperties;
+
+ @LoadBalanced
+ @Bean
+ public RestTemplate restTemplate(ClientHttpRequestFactory httpRequestFactory) {
+ RestTemplate restTemplate = new RestTemplate();
+ restTemplate.setRequestFactory(httpRequestFactory);
+ return restTemplate;
+ }
+
+ /**
+ * httpclient 实现的ClientHttpRequestFactory
+ */
+ @Bean
+ public ClientHttpRequestFactory httpRequestFactory(HttpClient httpClient) {
+ return new HttpComponentsClientHttpRequestFactory(httpClient);
+ }
+
+ /**
+ * 使用连接池的 httpclient
+ */
+ @Bean
+ public HttpClient httpClient() {
+ Registry registry = RegistryBuilder.create()
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
+ .register("https", SSLConnectionSocketFactory.getSocketFactory())
+ .build();
+ PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
+ // 最大链接数
+ connectionManager.setMaxTotal(restTemplateProperties.getMaxTotal());
+ // 同路由并发数20
+ connectionManager.setDefaultMaxPerRoute(restTemplateProperties.getMaxPerRoute());
+
+ RequestConfig requestConfig = RequestConfig.custom()
+ // 读超时
+ .setSocketTimeout(restTemplateProperties.getReadTimeout())
+ // 链接超时
+ .setConnectTimeout(restTemplateProperties.getConnectTimeout())
+ // 链接不够用的等待时间
+ .setConnectionRequestTimeout(restTemplateProperties.getReadTimeout())
+ .build();
+
+ return HttpClientBuilder.create()
+ .setDefaultRequestConfig(requestConfig)
+ .setConnectionManager(connectionManager)
+ .setRetryHandler(new DefaultHttpRequestRetryHandler(3, true))
+ .build();
+ }
+}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/annotation/EnableBaseFeignInterceptor.java b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/annotation/EnableBaseFeignInterceptor.java
similarity index 83%
rename from zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/annotation/EnableBaseFeignInterceptor.java
rename to zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/annotation/EnableBaseFeignInterceptor.java
index ea58d081..a0a9a817 100644
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/annotation/EnableBaseFeignInterceptor.java
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/annotation/EnableBaseFeignInterceptor.java
@@ -1,6 +1,6 @@
-package com.central.common.ribbon.annotation;
+package com.central.common.lb.annotation;
-import com.central.common.ribbon.config.FeignInterceptorConfig;
+import com.central.common.lb.config.FeignInterceptorConfig;
import org.springframework.context.annotation.Import;
import java.lang.annotation.ElementType;
@@ -22,4 +22,4 @@ import java.lang.annotation.Target;
@Import(FeignInterceptorConfig.class)
public @interface EnableBaseFeignInterceptor {
-}
+}
\ No newline at end of file
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/annotation/EnableFeignInterceptor.java b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/annotation/EnableFeignInterceptor.java
similarity index 74%
rename from zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/annotation/EnableFeignInterceptor.java
rename to zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/annotation/EnableFeignInterceptor.java
index 5f97ac6b..9bd4c02e 100644
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/annotation/EnableFeignInterceptor.java
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/annotation/EnableFeignInterceptor.java
@@ -1,7 +1,7 @@
-package com.central.common.ribbon.annotation;
+package com.central.common.lb.annotation;
-import com.central.common.ribbon.config.FeignHttpInterceptorConfig;
-import com.central.common.ribbon.config.FeignInterceptorConfig;
+import com.central.common.lb.config.FeignHttpInterceptorConfig;
+import com.central.common.lb.config.FeignInterceptorConfig;
import org.springframework.context.annotation.Import;
import java.lang.annotation.ElementType;
@@ -14,9 +14,11 @@ import java.lang.annotation.Target;
*
* @author zlt
*/
+
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Import({FeignInterceptorConfig.class, FeignHttpInterceptorConfig.class})
public @interface EnableFeignInterceptor {
}
+
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/FeignHttpInterceptorConfig.java b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/FeignHttpInterceptorConfig.java
similarity index 98%
rename from zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/FeignHttpInterceptorConfig.java
rename to zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/FeignHttpInterceptorConfig.java
index e6b7a996..7140c7ba 100644
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/FeignHttpInterceptorConfig.java
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/FeignHttpInterceptorConfig.java
@@ -1,4 +1,4 @@
-package com.central.common.ribbon.config;
+package com.central.common.lb.config;
import com.central.common.constant.CommonConstant;
import com.central.common.constant.SecurityConstants;
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/FeignInterceptorConfig.java b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/FeignInterceptorConfig.java
similarity index 87%
rename from zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/FeignInterceptorConfig.java
rename to zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/FeignInterceptorConfig.java
index b1a463cf..59da835e 100644
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/FeignInterceptorConfig.java
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/FeignInterceptorConfig.java
@@ -1,4 +1,4 @@
-package com.central.common.ribbon.config;
+package com.central.common.lb.config;
import cn.hutool.core.util.StrUtil;
import com.central.common.constant.SecurityConstants;
@@ -10,6 +10,9 @@ import org.springframework.context.annotation.Bean;
* feign拦截器,只包含基础数据
*
* @author zlt
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
public class FeignInterceptorConfig {
/**
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/RestTemplateProperties.java b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/RestTemplateProperties.java
similarity index 84%
rename from zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/RestTemplateProperties.java
rename to zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/RestTemplateProperties.java
index bbd13882..b0dd15cb 100644
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/RestTemplateProperties.java
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/java/com/central/common/lb/config/RestTemplateProperties.java
@@ -1,33 +1,36 @@
-package com.central.common.ribbon.config;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * RestTemplate 配置
- *
- * @author zlt
- * @date 2017/11/17
- */
-@Setter
-@Getter
-@ConfigurationProperties(prefix = "zlt.rest-template")
-public class RestTemplateProperties {
- /**
- * 最大链接数
- */
- private int maxTotal = 200;
- /**
- * 同路由最大并发数
- */
- private int maxPerRoute = 50;
- /**
- * 读取超时时间 ms
- */
- private int readTimeout = 35000;
- /**
- * 链接超时时间 ms
- */
- private int connectTimeout = 10000;
-}
+package com.central.common.lb.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * RestTemplate 配置
+ *
+ * @author zlt
+ * @date 2017/11/17
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Setter
+@Getter
+@ConfigurationProperties(prefix = "zlt.rest-template")
+public class RestTemplateProperties {
+ /**
+ * 最大链接数
+ */
+ private int maxTotal = 200;
+ /**
+ * 同路由最大并发数
+ */
+ private int maxPerRoute = 50;
+ /**
+ * 读取超时时间 ms
+ */
+ private int readTimeout = 35000;
+ /**
+ * 链接超时时间 ms
+ */
+ private int connectTimeout = 10000;
+}
diff --git a/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/resources/META-INF/spring.factories b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 00000000..bd79ca62
--- /dev/null
+++ b/zlt-commons/zlt-loadbalancer-spring-boot-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+com.central.common.lb.RestTemplateAutoConfigure
\ No newline at end of file
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/FeignAutoConfigure.java b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/FeignAutoConfigure.java
deleted file mode 100644
index afa6bbbd..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/FeignAutoConfigure.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.central.common.ribbon;
-
-import feign.Logger;
-import org.springframework.context.annotation.Bean;
-
-/**
- * Feign统一配置
- *
- * @author zlt
- * @date 2018/9/18 14:04
- */
-public class FeignAutoConfigure {
-
- /**
- * Feign 日志级别
- */
- @Bean
- Logger.Level feignLoggerLevel() {
- return Logger.Level.FULL;
- }
-}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/LbIsolationAutoConfigure.java b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/LbIsolationAutoConfigure.java
deleted file mode 100644
index 6dbb941a..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/LbIsolationAutoConfigure.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.central.common.ribbon;
-
-import com.central.common.constant.ConfigConstants;
-import com.central.common.ribbon.config.RuleConfigure;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.cloud.netflix.ribbon.RibbonClients;
-
-/**
- * 自定义负载均衡配置
- *
- * @author zlt
- * @date 2019/9/3
- *
- * Blog: https://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@ConditionalOnProperty(value = ConfigConstants.CONFIG_RIBBON_ISOLATION_ENABLED, havingValue = "true")
-@RibbonClients(defaultConfiguration = {RuleConfigure.class})
-public class LbIsolationAutoConfigure {
-
-}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/RibbonAutoConfigure.java b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/RibbonAutoConfigure.java
deleted file mode 100644
index df4983c8..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/RibbonAutoConfigure.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.central.common.ribbon;
-
-import com.central.common.ribbon.config.RestTemplateProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.cloud.netflix.ribbon.DefaultPropertiesFactory;
-import org.springframework.context.annotation.Bean;
-
-/**
- * Ribbon扩展配置类
- *
- * @author zlt
- * @date 2018/11/17 9:24
- */
-@EnableConfigurationProperties(RestTemplateProperties.class)
-public class RibbonAutoConfigure {
- @Bean
- public DefaultPropertiesFactory defaultPropertiesFactory() {
- return new DefaultPropertiesFactory();
- }
-}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/RuleConfigure.java b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/RuleConfigure.java
deleted file mode 100644
index 75d61d4f..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/config/RuleConfigure.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.central.common.ribbon.config;
-
-import com.alibaba.cloud.nacos.ribbon.NacosServer;
-import com.central.common.ribbon.rule.VersionIsolationRule;
-import com.netflix.loadbalancer.IRule;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.context.annotation.Bean;
-
-/**
- * @author zlt
- * @date 2020/4/24
- *
- * Blog: https://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-public class RuleConfigure {
- @Bean
- @ConditionalOnClass(NacosServer.class)
- @ConditionalOnMissingBean
- public IRule versionIsolationRule() {
- return new VersionIsolationRule();
- }
-}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/filter/LbIsolationFilter.java b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/filter/LbIsolationFilter.java
deleted file mode 100644
index 22c5e4ff..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/filter/LbIsolationFilter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.central.common.ribbon.filter;
-
-import cn.hutool.core.util.StrUtil;
-import com.central.common.constant.CommonConstant;
-import com.central.common.constant.ConfigConstants;
-import com.central.common.context.LbIsolationContextHolder;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
-import org.springframework.web.filter.OncePerRequestFilter;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * 负载均衡隔离规则过滤器
- *
- * @author zlt
- * @date 2019/9/15
- */
-@ConditionalOnClass(Filter.class)
-public class LbIsolationFilter extends OncePerRequestFilter {
- @Value("${" + ConfigConstants.CONFIG_RIBBON_ISOLATION_ENABLED + ":false}")
- private boolean enableIsolation;
-
- @Override
- protected boolean shouldNotFilter(HttpServletRequest request) {
- return !enableIsolation;
- }
-
- @Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
- FilterChain filterChain) throws IOException, ServletException {
- try {
- String version = request.getHeader(CommonConstant.Z_L_T_VERSION);
- if(StrUtil.isNotEmpty(version)){
- LbIsolationContextHolder.setVersion(version);
- }
-
- filterChain.doFilter(request, response);
- } finally {
- LbIsolationContextHolder.clear();
- }
- }
-}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/rule/VersionIsolationRule.java b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/rule/VersionIsolationRule.java
deleted file mode 100644
index de3222c0..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/com/central/common/ribbon/rule/VersionIsolationRule.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.central.common.ribbon.rule;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.RandomUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.cloud.nacos.ribbon.NacosServer;
-import com.central.common.constant.CommonConstant;
-import com.central.common.context.LbIsolationContextHolder;
-import com.netflix.loadbalancer.*;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * 根据实例版本号隔离规则
- * 详细用法:https://mp.weixin.qq.com/s/9XQ-SIbYsov3KBx9TGFN0g
- *
- * 实例获取规则顺序如下(不满足则走下一个规则):
- * 1. 相同版本号的实例
- * 2. 无版本号的实例
- * 3. 所有实例中轮询
- *
- * @author zlt
- * @date 2019/9/3
- *
- * Blog: https://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-public class VersionIsolationRule extends RoundRobinRule {
- private final static String KEY_DEFAULT = "default";
- /**
- * 优先根据版本号取实例
- */
- @Override
- public Server choose(ILoadBalancer lb, Object key) {
- if (lb == null) {
- return null;
- }
- String version;
- if (key != null && !KEY_DEFAULT.equals(key)) {
- version = key.toString();
- } else {
- version = LbIsolationContextHolder.getVersion();
- }
-
- List targetList = null;
- List upList = lb.getReachableServers();
- if (StrUtil.isNotEmpty(version)) {
- //取指定版本号的实例
- targetList = upList.stream().filter(
- server -> version.equals(
- ((NacosServer) server).getMetadata().get(CommonConstant.METADATA_VERSION)
- )
- ).collect(Collectors.toList());
- }
-
- if (CollUtil.isEmpty(targetList)) {
- //只取无版本号的实例
- targetList = upList.stream().filter(
- server -> {
- String metadataVersion = ((NacosServer) server).getMetadata().get(CommonConstant.METADATA_VERSION);
- return StrUtil.isEmpty(metadataVersion);
- }
- ).collect(Collectors.toList());
- }
-
- if (CollUtil.isNotEmpty(targetList)) {
- return getServer(targetList);
- }
- return super.choose(lb, key);
- }
-
- /**
- * 随机取一个实例
- */
- private Server getServer(List upList) {
- int nextInt = RandomUtil.randomInt(upList.size());
- return upList.get(nextInt);
- }
-}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/org/springframework/cloud/netflix/ribbon/DefaultPropertiesFactory.java b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/org/springframework/cloud/netflix/ribbon/DefaultPropertiesFactory.java
deleted file mode 100644
index 8dd490a1..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/java/org/springframework/cloud/netflix/ribbon/DefaultPropertiesFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.springframework.cloud.netflix.ribbon;
-
-import com.netflix.loadbalancer.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-import org.springframework.util.StringUtils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.springframework.cloud.netflix.ribbon.SpringClientFactory.NAMESPACE;
-
-/**
- * 扩展 spring cloud ribbon的PropertiesFactory
- * 使其能够支持 配置全局的ribbon.NFLoadBalancerRuleClassName=package.YourRule
- * 然后各个微服务还可以根据自身情况做个性化定制。如:SERVICE_ID.ribbon.NFLoadBalancerRuleClassName=package.YourRule
- *
- * @author zlt
- * @date 2018/11/17 9:29
- */
-public class DefaultPropertiesFactory extends PropertiesFactory {
-
- @Autowired
- private Environment environment;
-
- private Map classToProperty = new HashMap<>(5);
-
- public DefaultPropertiesFactory() {
- super();
- classToProperty.put(ILoadBalancer.class, "NFLoadBalancerClassName");
- classToProperty.put(IPing.class, "NFLoadBalancerPingClassName");
- classToProperty.put(IRule.class, "NFLoadBalancerRuleClassName");
- classToProperty.put(ServerList.class, "NIWSServerListClassName");
- classToProperty.put(ServerListFilter.class, "NIWSServerListFilterClassName");
- }
-
- /**
- * 重写 支持 ribbon.NFLoadBalancerRuleClassName=package.YourRule 全局配置的方式
- */
- @Override
- public String getClassName(Class clazz, String name) {
- String className = super.getClassName(clazz, name);
- // 读取全局配置
- if(!StringUtils.hasText(className) && this.classToProperty.containsKey(clazz)){
- String classNameProperty = this.classToProperty.get(clazz);
- className = environment.getProperty(NAMESPACE + "." + classNameProperty);
- }
- return className;
- }
-}
diff --git a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/resources/META-INF/spring.factories b/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index 16f3fb91..00000000
--- a/zlt-commons/zlt-ribbon-spring-boot-starter/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,6 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-com.central.common.ribbon.RibbonAutoConfigure,\
-com.central.common.ribbon.FeignAutoConfigure,\
-com.central.common.ribbon.RestTemplateAutoConfigure,\
-com.central.common.ribbon.filter.LbIsolationFilter,\
-com.central.common.ribbon.LbIsolationAutoConfigure
diff --git a/zlt-config/src/main/resources/application.properties b/zlt-config/src/main/resources/application.properties
index 87d5e328..7050b047 100644
--- a/zlt-config/src/main/resources/application.properties
+++ b/zlt-config/src/main/resources/application.properties
@@ -1,18 +1,7 @@
########################## application级别通用配置 ##########################
-##### ribbon配置
-## 从注册中心刷新servelist的时间 默认30秒,单位ms
-ribbon.ServerListRefreshInterval=15000
-## 请求连接的超时时间 默认1秒,单位ms
-ribbon.ConnectTimeout=30000
-## 请求处理的超时时间 默认1秒,单位ms
-ribbon.ReadTimeout=30000
-## 对所有操作请求都进行重试,不配置这个MaxAutoRetries不起作用 默认false
-#ribbon.OkToRetryOnAllOperations=true
-## 对当前实例的重试次数 默认0
-#ribbon.MaxAutoRetries=1
-## 切换实例的重试次数 默认1
-ribbon.MaxAutoRetriesNextServer=0
-
+##### loadbalancer配置
+## 切换实例的重试
+spring.cloud.loadbalancer.retry.enabled=false
##### feign配置
feign.sentinel.enabled=true
diff --git a/zlt-demo/seata-demo/business-service/pom.xml b/zlt-demo/seata-demo/business-service/pom.xml
index 1c56e802..b73229c3 100644
--- a/zlt-demo/seata-demo/business-service/pom.xml
+++ b/zlt-demo/seata-demo/business-service/pom.xml
@@ -12,7 +12,7 @@
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
org.springframework.boot
diff --git a/zlt-demo/seata-demo/order-service/pom.xml b/zlt-demo/seata-demo/order-service/pom.xml
index b5697844..2d8bcad5 100644
--- a/zlt-demo/seata-demo/order-service/pom.xml
+++ b/zlt-demo/seata-demo/order-service/pom.xml
@@ -17,7 +17,7 @@
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
org.springframework.boot
diff --git a/zlt-demo/seata-demo/storage-service/pom.xml b/zlt-demo/seata-demo/storage-service/pom.xml
index c4e7b453..edd6d5a1 100644
--- a/zlt-demo/seata-demo/storage-service/pom.xml
+++ b/zlt-demo/seata-demo/storage-service/pom.xml
@@ -17,7 +17,7 @@
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
org.springframework.boot
diff --git a/zlt-demo/txlcn-demo/txlcn-demo-common/pom.xml b/zlt-demo/txlcn-demo/txlcn-demo-common/pom.xml
index b31e18ac..07ee9498 100644
--- a/zlt-demo/txlcn-demo/txlcn-demo-common/pom.xml
+++ b/zlt-demo/txlcn-demo/txlcn-demo-common/pom.xml
@@ -40,7 +40,7 @@
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
com.zlt
diff --git a/zlt-gateway/pom.xml b/zlt-gateway/pom.xml
index f292251b..08d238c1 100644
--- a/zlt-gateway/pom.xml
+++ b/zlt-gateway/pom.xml
@@ -9,8 +9,6 @@
zlt-gateway
pom
-
- zuul-gateway
sc-gateway
diff --git a/zlt-gateway/sc-gateway/pom.xml b/zlt-gateway/sc-gateway/pom.xml
index 78712a8c..4ee10cc2 100644
--- a/zlt-gateway/sc-gateway/pom.xml
+++ b/zlt-gateway/sc-gateway/pom.xml
@@ -16,7 +16,7 @@
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
com.zlt
@@ -89,6 +89,10 @@
eu.bitwalker
UserAgentUtils
+
+ org.springframework.security.oauth
+ spring-security-oauth2
+
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/SCGatewayApp.java b/zlt-gateway/sc-gateway/src/main/java/com/central/SCGatewayApp.java
index 7724217c..c2ecc2bd 100644
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/SCGatewayApp.java
+++ b/zlt-gateway/sc-gateway/src/main/java/com/central/SCGatewayApp.java
@@ -1,6 +1,6 @@
package com.central;
-import com.central.common.ribbon.annotation.EnableBaseFeignInterceptor;
+import com.central.common.lb.annotation.EnableBaseFeignInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/PermissionAuthManager.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/PermissionAuthManager.java
index aa21abc4..1afb01b4 100644
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/PermissionAuthManager.java
+++ b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/PermissionAuthManager.java
@@ -1,7 +1,7 @@
package com.central.gateway.auth;
import com.central.common.model.SysMenu;
-import com.central.gateway.feign.MenuService;
+import com.central.gateway.feign.AsynMenuService;
import com.central.oauth2.common.service.impl.DefaultPermissionServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.server.reactive.ServerHttpRequest;
@@ -14,7 +14,9 @@ import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import javax.annotation.Resource;
+import java.util.Collections;
import java.util.List;
+import java.util.concurrent.Future;
/**
* url权限认证
@@ -29,7 +31,7 @@ import java.util.List;
@Component
public class PermissionAuthManager extends DefaultPermissionServiceImpl implements ReactiveAuthorizationManager {
@Resource
- private MenuService menuService;
+ private AsynMenuService asynMenuService;
@Override
public Mono check(Mono authentication, AuthorizationContext authorizationContext) {
@@ -43,6 +45,12 @@ public class PermissionAuthManager extends DefaultPermissionServiceImpl implemen
@Override
public List findMenuByRoleCodes(String roleCodes) {
- return menuService.findByRoleCodes(roleCodes);
+ Future> futureResult = asynMenuService.findByRoleCodes(roleCodes);
+ try {
+ return futureResult.get();
+ } catch (Exception e) {
+ log.error("asynMenuService.findMenuByRoleCodes-error", e);
+ }
+ return Collections.emptyList();
}
-}
+}
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/AsycTaskExecutorConfig.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/AsycTaskExecutorConfig.java
similarity index 71%
rename from zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/AsycTaskExecutorConfig.java
rename to zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/AsycTaskExecutorConfig.java
index 3a7c9253..49ab7e6d 100644
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/AsycTaskExecutorConfig.java
+++ b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/AsycTaskExecutorConfig.java
@@ -1,14 +1,19 @@
-package com.central.gateway.config;
-
-import com.central.common.config.DefaultAsycTaskConfig;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author zlt
- * 线程池配置、启用异步
- * @Async quartz 需要使用
- */
-@Configuration
-public class AsycTaskExecutorConfig extends DefaultAsycTaskConfig {
-
-}
+package com.central.gateway.config;
+
+import com.central.common.config.DefaultAsycTaskConfig;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 线程池配置、启用异步
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2021/8/8
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Configuration
+public class AsycTaskExecutorConfig extends DefaultAsycTaskConfig {
+
+}
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/CorsConfig.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/CorsConfig.java
index 3ff21580..7e2ea488 100644
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/CorsConfig.java
+++ b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/CorsConfig.java
@@ -29,7 +29,7 @@ public class CorsConfig {
// cookie跨域
config.setAllowCredentials(Boolean.TRUE);
config.addAllowedMethod(ALL);
- config.addAllowedOrigin(ALL);
+ config.addAllowedOriginPattern(ALL);
config.addAllowedHeader(ALL);
// 配置前端js允许访问的自定义响应头
config.addExposedHeader("setToken");
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/feign/AsynMenuService.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/feign/AsynMenuService.java
new file mode 100644
index 00000000..b6577abd
--- /dev/null
+++ b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/feign/AsynMenuService.java
@@ -0,0 +1,35 @@
+package com.central.gateway.feign;
+
+import com.central.common.model.SysMenu;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * 异步Menu服务
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2021/8/8
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Component
+public class AsynMenuService {
+ @Lazy
+ @Resource
+ private MenuService menuService;
+
+ @Async
+ public Future> findByRoleCodes(String roleCodes) {
+ List result = menuService.findByRoleCodes(roleCodes);
+ return new AsyncResult<>(result);
+ }
+}
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/feign/fallback/MenuServiceFallbackFactory.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/feign/fallback/MenuServiceFallbackFactory.java
index 90aaa50d..840ae68a 100644
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/feign/fallback/MenuServiceFallbackFactory.java
+++ b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/feign/fallback/MenuServiceFallbackFactory.java
@@ -2,7 +2,7 @@ package com.central.gateway.feign.fallback;
import cn.hutool.core.collection.CollectionUtil;
import com.central.gateway.feign.MenuService;
-import feign.hystrix.FallbackFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/filter/LbIsolationFilter.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/filter/LbIsolationFilter.java
index bb127a15..74f964d3 100644
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/filter/LbIsolationFilter.java
+++ b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/filter/LbIsolationFilter.java
@@ -6,9 +6,9 @@ import com.central.common.constant.ConfigConstants;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
-import org.springframework.cloud.gateway.config.LoadBalancerProperties;
+/*import org.springframework.cloud.gateway.config.LoadBalancerProperties;
import org.springframework.cloud.gateway.filter.LoadBalancerClientFilter;
-import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient;
+import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient;*/
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
@@ -25,6 +25,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.G
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
+/*
@Component
@ConditionalOnProperty(name = ConfigConstants.CONFIG_RIBBON_ISOLATION_ENABLED, havingValue = "true")
public class LbIsolationFilter extends LoadBalancerClientFilter {
@@ -45,3 +46,4 @@ public class LbIsolationFilter extends LoadBalancerClientFilter {
return super.choose(exchange);
}
}
+*/
diff --git a/zlt-gateway/zuul-gateway/Dockerfile b/zlt-gateway/zuul-gateway/Dockerfile
deleted file mode 100644
index 9890bf2f..00000000
--- a/zlt-gateway/zuul-gateway/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM openjdk:8u292
-
-LABEL MAINTAINER=Andy
-WORKDIR /apps
-ADD target/zuul-gateway.jar /apps/
-CMD ["java","-jar","zuul-gateway.jar"]
-# docker run --name zuul-gateway \
-# -e spring_cloud_nacos_server_addr=10.0.0.12:8848 \
-# -e zlt_datasource_ip=10.0.0.12 \
-# -e zlt_datasource_username=root \
-# -e zlt_datasource_password=redhat \
-# -e spring_redis_host=10.0.0.12 \
-# -d zuul-gateway:4.5
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/pom.xml b/zlt-gateway/zuul-gateway/pom.xml
deleted file mode 100644
index 35ee5697..00000000
--- a/zlt-gateway/zuul-gateway/pom.xml
+++ /dev/null
@@ -1,150 +0,0 @@
-
- 4.0.0
-
- com.zlt
- zlt-gateway
- 4.6.0
-
- zuul-gateway
- zuul网关
-
-
-
-
- com.zlt
- zlt-config
-
-
- com.zlt
- zlt-auth-client-spring-boot-starter
-
-
- com.zlt
- zlt-ribbon-spring-boot-starter
-
-
- com.zlt
- zlt-sentinel-spring-boot-starter
-
-
- com.zlt
- zlt-redis-spring-boot-starter
-
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-discovery
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-tomcat
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-undertow
-
-
-
- org.springframework
- spring-context-support
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
-
- com.github.zlt2000
- swagger-butler-core
-
-
-
- org.springframework.cloud
- spring-cloud-starter-netflix-zuul
-
-
- com.baomidou
- mybatis-plus-extension
-
-
-
- com.squareup.okhttp3
- okhttp
-
-
-
- io.micrometer
- micrometer-registry-prometheus
-
-
- eu.bitwalker
- UserAgentUtils
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- true
-
-
-
- org.hibernate
- hibernate-validator
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- repackage
-
-
-
-
-
- com.spotify
- docker-maven-plugin
-
- ${docker.image.prefix}/${project.artifactId}
-
- ${project.version}
- latest
-
- true
- ${docker.baseImage}
- ${docker.volumes}
-
- ${docker.java.opts}
-
- ["sh","-c","java $JAVA_OPTS ${docker.java.security.egd} -jar /${project.build.finalName}.jar"]
-
-
- /
- ${project.build.directory}
- ${project.build.finalName}.jar
-
-
-
-
-
- ${project.artifactId}
-
-
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/GatewayApp.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/GatewayApp.java
deleted file mode 100644
index 7fe04b5f..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/GatewayApp.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.central;
-
-import com.central.common.ribbon.annotation.EnableBaseFeignInterceptor;
-import com.central.common.ribbon.annotation.EnableFeignInterceptor;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
-import org.springframework.cloud.openfeign.EnableFeignClients;
-
-/**
- * @author zlt
- */
-@EnableZuulProxy
-@EnableFeignClients
-@EnableBaseFeignInterceptor
-@EnableDiscoveryClient
-@SpringBootApplication
-public class GatewayApp {
- public static void main(String[] args) {
- SpringApplication.run(GatewayApp.class, args);
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/CorsConfigration.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/CorsConfigration.java
deleted file mode 100644
index 2f2c0829..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/CorsConfigration.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.central.gateway.config;
-
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
-import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
-
-/**
- * 跨域配置
- *
- * @author zlt
- * @date 2018/8/9 15:59
- */
-@Configuration
-public class CorsConfigration {
-
- @Bean
- public CorsFilter corsFilter() {
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- CorsConfiguration config = new CorsConfiguration();
- // #允许向该服务器提交请求的URI,*表示全部允许
- config.addAllowedOrigin(CorsConfiguration.ALL);
- // 允许cookies跨域
- config.setAllowCredentials(true);
- // #允许访问的头信息,*表示全部
- config.addAllowedHeader(CorsConfiguration.ALL);
- // 允许提交请求的方法,*表示全部允许
- config.addAllowedMethod(CorsConfiguration.ALL);
- source.registerCorsConfiguration("/**", config);
- return new CorsFilter(source);
- }
-
- /**
- * 配置过滤器
- */
- @Bean
- public FilterRegistrationBean someFilterRegistration() {
- FilterRegistrationBean registration = new FilterRegistrationBean<>();
- registration.setFilter(corsFilter());
- registration.addUrlPatterns("/*");
- registration.setName("corsFilter");
- registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
- return registration;
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/DynamicZuulRouteConfig.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/DynamicZuulRouteConfig.java
deleted file mode 100644
index 42c76e42..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/DynamicZuulRouteConfig.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.central.gateway.config;
-
-import com.alibaba.cloud.nacos.NacosConfigProperties;
-import com.central.gateway.route.nacos.NacosDynRouteLocator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath;
-import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
-import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * 动态路由配置
- *
- * @author zlt
- * @date 2019/8/21
- */
-@Configuration
-@ConditionalOnProperty(prefix = "zlt.gateway.dynamicRoute", name = "enabled", havingValue = "true")
-public class DynamicZuulRouteConfig {
- @Autowired
- private ZuulProperties zuulProperties;
-
- @Autowired
- private DispatcherServletPath dispatcherServletPath;
-
- /**
- * Nacos实现方式
- */
- @Configuration
- @ConditionalOnProperty(prefix = "zlt.gateway.dynamicRoute", name = "dataType", havingValue = "nacos", matchIfMissing = true)
- public class NacosZuulRoute {
- @Autowired
- private NacosConfigProperties nacosConfigProperties;
-
- @Autowired
- private ApplicationEventPublisher publisher;
-
- @Bean
- public NacosDynRouteLocator nacosDynRouteLocator() {
- return new NacosDynRouteLocator(nacosConfigProperties, publisher, dispatcherServletPath.getPrefix(), zuulProperties);
- }
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/ResourceServerConfiguration.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/ResourceServerConfiguration.java
deleted file mode 100644
index 58e217f6..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/ResourceServerConfiguration.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.central.gateway.config;
-
-import com.central.common.config.DefaultPasswordConfig;
-import com.central.oauth2.common.config.DefaultResourceServerConf;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-
-/**
- * @author zlt
- */
-@Configuration
-@EnableResourceServer
-@Import({DefaultPasswordConfig.class})
-public class ResourceServerConfiguration extends DefaultResourceServerConf {
- @Override
- public HttpSecurity setAuthenticate(ExpressionUrlAuthorizationConfigurer.AuthorizedUrl authorizedUrl) {
- return authorizedUrl.access("@permissionService.hasPermission(request, authentication)").and();
- }
-}
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/SwaggerConfig.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/SwaggerConfig.java
deleted file mode 100644
index d28318b5..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/SwaggerConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.central.gateway.config;
-
-import com.didispace.swagger.butler.EnableSwaggerButler;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * swagger 聚合文档配置
- * zuul routers 映射具体服务的/v2/api-docs swagger
- *
- * @author 作者 owen E-mail: 624191343@qq.com
- */
-@Configuration
-@EnableSwaggerButler
-public class SwaggerConfig {
-
-}
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/ZuulRouteEntity.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/ZuulRouteEntity.java
deleted file mode 100644
index a4d9b32d..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/config/ZuulRouteEntity.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.central.gateway.config;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * zuul路由实体
- *
- * @author zlt
- * @date 2019/8/21
- */
-@Setter
-@Getter
-public class ZuulRouteEntity {
- /**
- * The ID of the route (the same as its map key by default).
- */
- private String id;
- /**
- * The path (pattern) for the route, e.g. /foo/**.
- */
- private String path;
- /**
- * The service ID (if any) to map to this route. You can specify a
- * physical URL or a service, but not both.
- */
- private String serviceId;
- /**
- * A full physical URL to map to the route. An alternative is to use a
- * service ID and service discovery to find the physical address.
- */
- private String url;
- /**
- * Flag to determine whether the prefix for this route (the path, minus
- * pattern patcher) should be stripped before forwarding.
- */
- private boolean stripPrefix = true;
- /**
- * Flag to indicate that this route should be retryable (if supported).
- * Generally retry requires a service ID and ribbon.
- */
- private Boolean retryable;
-
- private String apiName;
-
- private boolean enabled = true;
-
- private boolean customSensitiveHeaders = true;
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/feign/MenuService.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/feign/MenuService.java
deleted file mode 100644
index 032ed131..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/feign/MenuService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.central.gateway.feign;
-
-import com.central.common.constant.ServiceNameConstants;
-import com.central.common.model.SysMenu;
-import com.central.gateway.feign.fallback.MenuServiceFallbackFactory;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-
-import java.util.List;
-
-/**
- * @author zlt
- */
-@FeignClient(name = ServiceNameConstants.USER_SERVICE, fallbackFactory = MenuServiceFallbackFactory.class, decode404 = true)
-public interface MenuService {
- /**
- * 角色菜单列表
- * @param roleCodes
- */
- @GetMapping(value = "/menus/{roleCodes}")
- List findByRoleCodes(@PathVariable("roleCodes") String roleCodes);
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/feign/fallback/MenuServiceFallbackFactory.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/feign/fallback/MenuServiceFallbackFactory.java
deleted file mode 100644
index 7cba08ab..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/feign/fallback/MenuServiceFallbackFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.central.gateway.feign.fallback;
-
-import cn.hutool.core.collection.CollectionUtil;
-import com.central.gateway.feign.MenuService;
-import feign.hystrix.FallbackFactory;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * menuService降级工场
- *
- * @author zlt
- * @date 2019/1/18
- */
-@Slf4j
-@Component
-public class MenuServiceFallbackFactory implements FallbackFactory {
- @Override
- public MenuService create(Throwable throwable) {
- return roleIds -> {
- log.error("调用findByRoleCodes异常:{}", roleIds, throwable);
- return CollectionUtil.newArrayList();
- };
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/RequestStatisticsFilter.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/RequestStatisticsFilter.java
deleted file mode 100644
index 72c60b45..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/RequestStatisticsFilter.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.central.gateway.filter.pre;
-
-import cn.hutool.core.util.StrUtil;
-import com.central.common.utils.AddrUtil;
-import com.central.log.monitor.PointUtil;
-import com.netflix.zuul.ZuulFilter;
-import com.netflix.zuul.context.RequestContext;
-import eu.bitwalker.useragentutils.UserAgent;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * 请求统计分析埋点过滤器
- *
- * @author zlt
- * @date 2019/5/6
- */
-@Slf4j
-@Component
-public class RequestStatisticsFilter extends ZuulFilter {
- @Override
- public String filterType() {
- return FilterConstants.PRE_TYPE;
- }
-
- @Override
- public int filterOrder() {
- return 0;
- }
-
- @Override
- public boolean shouldFilter() {
- return true;
- }
-
- @Override
- public Object run() {
- RequestContext ctx = RequestContext.getCurrentContext();
- HttpServletRequest req = ctx.getRequest();
- UserAgent userAgent = UserAgent.parseUserAgentString(req.getHeader("User-Agent"));
-
- //埋点
- PointUtil.debug("0", "request-statistics",
- "ip=" + AddrUtil.getRemoteAddr(req)
- + "&browser=" + getBrowser(userAgent.getBrowser().getName())
- + "&operatingSystem=" + getOperatingSystem(userAgent.getOperatingSystem().getName()));
-
- return null;
- }
-
- private String getBrowser(String browser) {
- if (StrUtil.isNotEmpty(browser)) {
- if (browser.contains("CHROME")) {
- return "CHROME";
- } else if (browser.contains("FIREFOX")) {
- return "FIREFOX";
- } else if (browser.contains("SAFARI")) {
- return "SAFARI";
- } else if (browser.contains("EDGE")) {
- return "EDGE";
- }
- }
- return browser;
- }
-
- private String getOperatingSystem(String operatingSystem) {
- if (StrUtil.isNotEmpty(operatingSystem)) {
- if (operatingSystem.contains("MAC_OS_X")) {
- return "MAC_OS_X";
- } else if (operatingSystem.contains("ANDROID")) {
- return "ANDROID";
- }
- }
- return operatingSystem;
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/TraceFilter.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/TraceFilter.java
deleted file mode 100644
index 2739492e..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/TraceFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.central.gateway.filter.pre;
-
-import cn.hutool.core.util.IdUtil;
-import com.central.common.constant.CommonConstant;
-import com.central.log.properties.TraceProperties;
-import com.netflix.zuul.ZuulFilter;
-import com.netflix.zuul.context.RequestContext;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
-import org.springframework.stereotype.Component;
-
-import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.FORM_BODY_WRAPPER_FILTER_ORDER;
-
-/**
- * 生成日志链路追踪id,并传入header中
- *
- * @author zlt
- * @date 2019/8/13
- */
-@Component
-public class TraceFilter extends ZuulFilter {
- @Autowired
- private TraceProperties traceProperties;
-
- @Override
- public String filterType() {
- return FilterConstants.PRE_TYPE;
- }
-
- @Override
- public int filterOrder() {
- return FORM_BODY_WRAPPER_FILTER_ORDER - 1;
- }
-
- @Override
- public boolean shouldFilter() {
- //根据配置控制是否开启过滤器
- return traceProperties.getEnable();
- }
-
- @Override
- public Object run() {
- //链路追踪id
- String traceId = IdUtil.fastSimpleUUID();
- MDC.put(CommonConstant.LOG_TRACE_ID, traceId);
- RequestContext ctx = RequestContext.getCurrentContext();
- ctx.addZuulRequestHeader(CommonConstant.TRACE_ID_HEADER, traceId);
- return null;
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/UserInfoHeaderFilter.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/UserInfoHeaderFilter.java
deleted file mode 100644
index bee07e26..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/filter/pre/UserInfoHeaderFilter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.central.gateway.filter.pre;
-
-import cn.hutool.core.collection.CollectionUtil;
-import com.central.common.constant.SecurityConstants;
-import com.central.common.model.SysUser;
-import com.central.oauth2.common.util.AuthUtils;
-import com.netflix.zuul.ZuulFilter;
-import com.netflix.zuul.context.RequestContext;
-import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
-import org.springframework.security.authentication.AnonymousAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.oauth2.provider.OAuth2Authentication;
-import org.springframework.stereotype.Component;
-
-import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.FORM_BODY_WRAPPER_FILTER_ORDER;
-
-/**
- * 将认证用户的相关信息放入header中, 后端服务可以直接读取使用
- *
- * @author zlt
- * @date 2018/11/20
- *
- * Blog: https://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@Component
-public class UserInfoHeaderFilter extends ZuulFilter {
- @Override
- public String filterType() {
- return FilterConstants.PRE_TYPE;
- }
-
- @Override
- public int filterOrder() {
- return FORM_BODY_WRAPPER_FILTER_ORDER - 1;
- }
-
- @Override
- public boolean shouldFilter() {
- return true;
- }
-
- @Override
- public Object run() {
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
- Object principal = authentication.getPrincipal();
- RequestContext ctx = RequestContext.getCurrentContext();
- //客户端模式只返回一个clientId
- if (principal instanceof SysUser) {
- SysUser user = (SysUser)principal;
- ctx.addZuulRequestHeader(SecurityConstants.USER_ID_HEADER, String.valueOf(user.getId()));
- ctx.addZuulRequestHeader(SecurityConstants.USER_HEADER, user.getUsername());
- }
- OAuth2Authentication oauth2Authentication = (OAuth2Authentication)authentication;
- String clientId = oauth2Authentication.getOAuth2Request().getClientId();
- ctx.addZuulRequestHeader(SecurityConstants.TENANT_HEADER, clientId);
- ctx.addZuulRequestHeader(SecurityConstants.ROLE_HEADER, CollectionUtil.join(authentication.getAuthorities(), ","));
- String accountType = AuthUtils.getAccountType(oauth2Authentication.getUserAuthentication());
- ctx.addZuulRequestHeader(SecurityConstants.ACCOUNT_TYPE_HEADER, accountType);
- }
- return null;
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/route/AbstractDynRouteLocator.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/route/AbstractDynRouteLocator.java
deleted file mode 100644
index c1dbcee7..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/route/AbstractDynRouteLocator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.central.gateway.route;
-
-import org.springframework.cloud.netflix.zuul.filters.RefreshableRouteLocator;
-import org.springframework.cloud.netflix.zuul.filters.SimpleRouteLocator;
-import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
-import org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute;
-import org.springframework.util.StringUtils;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * 扩展 {@link SimpleRouteLocator} 实现动态路由
- *
- * @author zlt
- * @date 2019/8/21
- */
-public abstract class AbstractDynRouteLocator extends SimpleRouteLocator implements RefreshableRouteLocator {
- private ZuulProperties properties;
-
- public AbstractDynRouteLocator(String servletPath, ZuulProperties properties) {
- super(servletPath, properties);
- this.properties = properties;
- }
-
- /**
- * 刷新路由
- */
- @Override
- public void refresh() {
- doRefresh();
- }
-
- @Override
- protected Map locateRoutes() {
- LinkedHashMap routesMap = new LinkedHashMap<>();
- // 从application.properties中加载静态路由信息
- routesMap.putAll(super.locateRoutes());
- // 从数据源中加载动态路由信息
- routesMap.putAll(loadDynamicRoute());
- // 优化一下配置
- LinkedHashMap values = new LinkedHashMap<>();
- for (Map.Entry entry : routesMap.entrySet()) {
- String path = entry.getKey();
- // Prepend with slash if not already present.
- if (!path.startsWith("/")) {
- path = "/" + path;
- }
- if (StringUtils.hasText(this.properties.getPrefix())) {
- path = this.properties.getPrefix() + path;
- if (!path.startsWith("/")) {
- path = "/" + path;
- }
- }
- values.put(path, entry.getValue());
- }
- return values;
- }
-
- /**
- * 加载路由配置,由子类去实现
- */
- public abstract Map loadDynamicRoute();
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/route/nacos/NacosDynRouteLocator.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/route/nacos/NacosDynRouteLocator.java
deleted file mode 100644
index 335c9b3d..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/route/nacos/NacosDynRouteLocator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.central.gateway.route.nacos;
-
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.cloud.nacos.NacosConfigProperties;
-import com.alibaba.nacos.api.config.listener.Listener;
-import com.alibaba.nacos.api.exception.NacosException;
-import com.central.common.utils.JsonUtil;
-import com.central.gateway.config.ZuulRouteEntity;
-import com.central.gateway.route.AbstractDynRouteLocator;
-import lombok.Setter;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.cloud.netflix.zuul.RoutesRefreshedEvent;
-import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
-import org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute;
-import org.springframework.context.ApplicationEventPublisher;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Executor;
-
-/**
- * Nacos动态路由实现类
- *
- * @author zlt
- * @date 2019/8/22
- */
-@Slf4j
-public class NacosDynRouteLocator extends AbstractDynRouteLocator {
- private static final String ZUUL_DATA_ID = "zuul-routes";
- private static final String ZUUL_GROUP_ID = "ZUUL_GATEWAY";
-
- private NacosConfigProperties nacosConfigProperties;
-
- private ApplicationEventPublisher publisher;
-
- private NacosDynRouteLocator locator;
-
- @Setter
- private List zuulRouteEntities;
-
- public NacosDynRouteLocator(NacosConfigProperties nacosConfigProperties, ApplicationEventPublisher publisher,
- String servletPath, ZuulProperties properties) {
- super(servletPath, properties);
- this.nacosConfigProperties = nacosConfigProperties;
- this.publisher = publisher;
- this.locator = this;
- addListener();
- }
-
- /**
- * 添加Nacos监听
- */
- private void addListener() {
- try {
- nacosConfigProperties.configServiceInstance().addListener(ZUUL_DATA_ID, ZUUL_GROUP_ID, new Listener() {
- @Override
- public Executor getExecutor() {
- return null;
- }
-
- @Override
- public void receiveConfigInfo(String configInfo) {
- //赋值路由信息
- locator.setZuulRouteEntities(getListByStr(configInfo));
- RoutesRefreshedEvent routesRefreshedEvent = new RoutesRefreshedEvent(locator);
- publisher.publishEvent(routesRefreshedEvent);
- }
- });
- } catch (NacosException e) {
- log.error("nacos-addListener-error", e);
- }
- }
-
- @Override
- public Map loadDynamicRoute() {
- Map routes = new LinkedHashMap<>();
- if (zuulRouteEntities == null) {
- zuulRouteEntities = getNacosConfig();
- }
- for (ZuulRouteEntity result : zuulRouteEntities) {
- if (StrUtil.isBlank(result.getPath()) || !result.isEnabled()) {
- continue;
- }
- ZuulRoute zuulRoute = new ZuulRoute();
- BeanUtil.copyProperties(result, zuulRoute);
- routes.put(zuulRoute.getPath(), zuulRoute);
- }
- return routes;
- }
-
- /**
- * 查询zuul的路由配置
- */
- private List getNacosConfig() {
- try {
- String content = nacosConfigProperties.configServiceInstance().getConfig(ZUUL_DATA_ID, ZUUL_GROUP_ID,5000);
- return getListByStr(content);
- } catch (NacosException e) {
- log.error("listenerNacos-error", e);
- }
- return new ArrayList<>(0);
- }
-
- public List getListByStr(String content) {
- if (StrUtil.isNotEmpty(content)) {
- return JsonUtil.toList(content, ZuulRouteEntity.class);
- }
- return new ArrayList<>(0);
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/service/impl/PermissionServiceImpl.java b/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/service/impl/PermissionServiceImpl.java
deleted file mode 100644
index 422e6e1f..00000000
--- a/zlt-gateway/zuul-gateway/src/main/java/com/central/gateway/service/impl/PermissionServiceImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.central.gateway.service.impl;
-
-import com.central.common.model.SysMenu;
-import com.central.gateway.feign.MenuService;
-import com.central.oauth2.common.service.impl.DefaultPermissionServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.security.core.Authentication;
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-
-/**
- * 请求权限判断service
- *
- * @author zlt
- * @date 2018/10/28
- */
-@Slf4j
-@Service("permissionService")
-public class PermissionServiceImpl extends DefaultPermissionServiceImpl {
- @Resource
- private MenuService menuService;
-
- @Override
- public List findMenuByRoleCodes(String roleCodes) {
- return menuService.findByRoleCodes(roleCodes);
- }
-
- public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
- return hasPermission(authentication, request.getMethod(), request.getRequestURI());
- }
-}
diff --git a/zlt-gateway/zuul-gateway/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/zlt-gateway/zuul-gateway/src/main/resources/META-INF/additional-spring-configuration-metadata.json
deleted file mode 100644
index efd00b85..00000000
--- a/zlt-gateway/zuul-gateway/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "properties": [
- {
- "name": "zlt.gateway.dynamicRoute.enabled",
- "description": "是否开启动态路由.",
- "type": "java.lang.Boolean",
- "defaultValue": false
- },
- {
- "name": "zlt.gateway.dynamicRoute.dataType",
- "description": "动态路由的数据类型.",
- "type": "java.lang.String",
- "defaultValue": "nacos"
- }
- ]
-}
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/src/main/resources/application.yml b/zlt-gateway/zuul-gateway/src/main/resources/application.yml
deleted file mode 100644
index 9f0c4be4..00000000
--- a/zlt-gateway/zuul-gateway/src/main/resources/application.yml
+++ /dev/null
@@ -1,169 +0,0 @@
-#spring:
- # sentinel动态配置规则
-# cloud:
-# sentinel:
-# zuul:
-# enabled: true
-# order:
-# pre: 2000
-# post: 500
-# error: -100
-# filter:
-# enabled: false
-# datasource:
- # 限流
-# ds1:
-# nacos:
-# server-addr: ${spring.cloud.nacos.server-addr}
-# dataId: ${spring.application.name}-sentinel-gw-flow
-# groupId: DEFAULT_GROUP
-# rule-type: gw-flow
- # api分组
-# ds2:
-# nacos:
-# server-addr: ${spring.cloud.nacos.server-addr}
-# dataId: ${spring.application.name}-sentinel-gw-api-group
-# groupId: DEFAULT_GROUP
-# rule-type: gw-api-group
-
-zlt:
- oauth2:
- token:
- store:
- type: redis
- security:
- ignore:
- # 忽略认证的地址
- httpUrls: >
- /api-uaa/oauth/**,
- /api-uaa/validata/**,
- /api-uaa/css/**,
- /api-uaa/images/**,
- /api-uaa/js/**,
- /api-user/users-anon/**,
- /login.html,
- /user/login
- auth:
- urlPermission:
- #是否开启url级别权限
- enable: false
- #配置只进行登录认证,不进行url权限认证的api
- ignoreUrls: >
- /api-user/menus/current,
- /api-user/users/current,
- /api-log/requestStat
- #白名单
- includeClientIds:
- - webApp
- renew:
- #是否开启token自动续签(目前只有redis实现)
- enable: true
- #白名单
- includeClientIds:
- - webApp
- gateway:
- #网关动态路由
- dynamicRoute:
- enabled: true
-
-
-zuul:
- ribbon-isolation-strategy: thread
- ribbon:
- eager-load:
- enabled: true
- threadPool:
- useSeparateThreadPools: true
- threadPoolKeyPrefix: api-gateway
- #关闭重试
- retryable: false
- ignored-headers: Access-Control-Allow-Credentials,Access-Control-Allow-Origin,Access-Control-Allow-Methods
- add-host-header: true
- routes:
- auth:
- path: /api-uaa/**
- service-id: uaa-server
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- auth-login-page:
- path: /login.html
- service-id: uaa-server
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- auth-login-process:
- path: /user/login
- service-id: uaa-server
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- auth-login-token:
- path: /oauth/token
- service-id: uaa-server
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- auth-login-authorize:
- path: /oauth/authorize
- service-id: uaa-server
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- auth-check-process:
- path: /oauth/check_token
- service-id: uaa-server
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- user:
- path: /api-user/**
- service-id: user-center
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- file:
- path: /api-file/**
- service-id: file-center
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- log:
- path: /api-log/**
- service-id: log-center
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- generator:
- path: /api-generator/**
- service-id: code-generator
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- search:
- path: /api-search/**
- service-id: search-center
- strip-prefix: true
- sensitive-headers: '*'
- custom-sensitive-headers: true
- ssl-hostname-validation-enabled: false
-
-hystrix:
- threadpool:
- default:
- coreSize: 100
- maximumSize: 2000
- allowMaximumSizeToDivergeFromCoreSize: true
- maxQueueSize: -1
- command:
- default:
- execution:
- isolation:
- thread:
- timeoutInMilliseconds: 60000
-
-swagger:
- butler:
- auto-generate-from-zuul-routes: true
- generate-routes: user,file
- apiDocsPath: v2/api-docs
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/src/main/resources/bootstrap.yml b/zlt-gateway/zuul-gateway/src/main/resources/bootstrap.yml
deleted file mode 100644
index b64a9d42..00000000
--- a/zlt-gateway/zuul-gateway/src/main/resources/bootstrap.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-server:
- port: 9900
- undertow:
- buffer-size: 1024
- direct-buffers: true
-
-spring:
- application:
- name: api-gateway
\ No newline at end of file
diff --git a/zlt-gateway/zuul-gateway/src/main/resources/pubkey.txt b/zlt-gateway/zuul-gateway/src/main/resources/pubkey.txt
deleted file mode 100644
index 0c1d7c8d..00000000
--- a/zlt-gateway/zuul-gateway/src/main/resources/pubkey.txt
+++ /dev/null
@@ -1,9 +0,0 @@
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjmgfejBXsPYynAIPczHA
-eEvTDfAVaNKQudyI7VszdezbHDM1CStCIgwiMmLd7QYf1SrrmQoqxhcSRbhjE3ej
-RF5qzhtx3kmepdpMrQptcsLjRkixaxCc4E2k6Us5707gGwbhoaTrRit5F2MnAdLY
-C1TS3WwnO/hQfqUcAglbK8yrJ4AwAv0DAoIUSWnWqzuniV1SYbdV57uswxUssoWy
-sEfPz+nv1ZLRs6Wz4eQ5Myqx2+CjWc9F8iXa2PV8Rmjms3dVbWcLUpCP18Dfzp8l
-n8vF9LfYB7UaLSpfJe6FFF6+vCg4JHfo12djTUgwGjauMF3e9mmjU83KIoQS66lp
-AQIDAQAB
------END PUBLIC KEY-----
\ No newline at end of file
diff --git a/zlt-monitor/log-center/pom.xml b/zlt-monitor/log-center/pom.xml
index 4f011845..edfff63d 100644
--- a/zlt-monitor/log-center/pom.xml
+++ b/zlt-monitor/log-center/pom.xml
@@ -19,7 +19,7 @@