升级Spring Boot到2.5.x,升级Spring Cloud到2020.x
This commit is contained in:
@@ -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;
|
||||
|
||||
+12
-4
@@ -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<AuthorizationContext> {
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
private AsynMenuService asynMenuService;
|
||||
|
||||
@Override
|
||||
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, AuthorizationContext authorizationContext) {
|
||||
@@ -43,6 +45,12 @@ public class PermissionAuthManager extends DefaultPermissionServiceImpl implemen
|
||||
|
||||
@Override
|
||||
public List<SysMenu> findMenuByRoleCodes(String roleCodes) {
|
||||
return menuService.findByRoleCodes(roleCodes);
|
||||
Future<List<SysMenu>> futureResult = asynMenuService.findByRoleCodes(roleCodes);
|
||||
try {
|
||||
return futureResult.get();
|
||||
} catch (Exception e) {
|
||||
log.error("asynMenuService.findMenuByRoleCodes-error", e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
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
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Configuration
|
||||
public class AsycTaskExecutorConfig extends DefaultAsycTaskConfig {
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Component
|
||||
public class AsynMenuService {
|
||||
@Lazy
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
|
||||
@Async
|
||||
public Future<List<SysMenu>> findByRoleCodes(String roleCodes) {
|
||||
List<SysMenu> result = menuService.findByRoleCodes(roleCodes);
|
||||
return new AsyncResult<>(result);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
+4
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user