|
@@ -8,12 +8,12 @@ import com.diagbot.entity.ServiceFilter;
|
|
import com.diagbot.entity.ServiceToken;
|
|
import com.diagbot.entity.ServiceToken;
|
|
import com.diagbot.enums.SysTypeEnum;
|
|
import com.diagbot.enums.SysTypeEnum;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+import com.diagbot.facade.ServiceFilterFacade;
|
|
import com.diagbot.rabbit.MySender;
|
|
import com.diagbot.rabbit.MySender;
|
|
import com.diagbot.util.EnDecodeUtil;
|
|
import com.diagbot.util.EnDecodeUtil;
|
|
import com.diagbot.util.GsonUtil;
|
|
import com.diagbot.util.GsonUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
@@ -52,8 +52,8 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
private static Boolean IS_GENERATE = false;
|
|
private static Boolean IS_GENERATE = false;
|
|
private static Map<String, Long> SERVICE_FILTER = new HashMap<>();
|
|
private static Map<String, Long> SERVICE_FILTER = new HashMap<>();
|
|
|
|
|
|
- @Value("${lantone.product}")
|
|
|
|
- private String lantonePrduct;
|
|
|
|
|
|
+ // @Value("${lantone.product}")
|
|
|
|
+ // private String lantonePrduct;
|
|
|
|
|
|
// @Autowired
|
|
// @Autowired
|
|
// DiagbotmanServiceClient diagbotmanServiceClient;
|
|
// DiagbotmanServiceClient diagbotmanServiceClient;
|
|
@@ -61,6 +61,8 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
private MySender mySender;
|
|
private MySender mySender;
|
|
@Autowired
|
|
@Autowired
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ServiceFilterFacade serviceFilterFacade;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -82,23 +84,13 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // log.info("APIURL:{}", requestUri);
|
|
|
|
- // log.info("SERVICENAME:{}", serviceName);
|
|
|
|
-
|
|
|
|
- // if(!IS_GENERATE) {
|
|
|
|
- // RespDTO<List<ServiceFilter>> filter = diagbotmanServiceClient.getAll();
|
|
|
|
- // if (filter != null){
|
|
|
|
- // List<ServiceFilter> list = filter.data;
|
|
|
|
- // if (ListUtil.isNotEmpty(list)){
|
|
|
|
- // for(ServiceFilter bean : list) {
|
|
|
|
- // SERVICE_FILTER.put(bean.getName(), bean.getProductId());
|
|
|
|
- // }
|
|
|
|
- // IS_GENERATE = true;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- Map<String, Long> serviceFilters = this.dealServiceFilter();
|
|
|
|
|
|
+
|
|
|
|
+ // Map<String, Long> serviceFilters = this.dealServiceFilter();
|
|
|
|
+ RespDTO<Map<String, Long>> resFilter = serviceFilterFacade.getServiceFilterRpc();
|
|
|
|
+ if (resFilter == null || !RespDTO.TRUE_CODE.equals(resFilter.code)) {
|
|
|
|
+ return getVoidMono(serverWebExchange, resFilter);
|
|
|
|
+ }
|
|
|
|
+ Map<String, Long> serviceFilters = resFilter.data;
|
|
if (serviceFilters.get(serviceName) != null) {
|
|
if (serviceFilters.get(serviceName) != null) {
|
|
String appkey = request.getHeaders().getFirst("appKeyId");
|
|
String appkey = request.getHeaders().getFirst("appKeyId");
|
|
String secret = request.getHeaders().getFirst("appKeySecret");
|
|
String secret = request.getHeaders().getFirst("appKeySecret");
|
|
@@ -127,7 +119,7 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
st.setAppkey(appkey);
|
|
st.setAppkey(appkey);
|
|
st.setSecret(secret);
|
|
st.setSecret(secret);
|
|
st.setProductId(productId);
|
|
st.setProductId(productId);
|
|
- // RespDTO<HasPermissionDTO> res = diagbotmanServiceClient.hasPermission(st);
|
|
|
|
|
|
+ //权限验证
|
|
RespDTO<LinkedHashMap> res = hasPermission(st);
|
|
RespDTO<LinkedHashMap> res = hasPermission(st);
|
|
if (res == null || !RespDTO.TRUE_CODE.equals(res.code)) {
|
|
if (res == null || !RespDTO.TRUE_CODE.equals(res.code)) {
|
|
return getVoidMono(serverWebExchange, res);
|
|
return getVoidMono(serverWebExchange, res);
|
|
@@ -175,16 +167,15 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
*
|
|
*
|
|
* @return 过滤的列表
|
|
* @return 过滤的列表
|
|
*/
|
|
*/
|
|
- private Map<String, Long> dealServiceFilter() {
|
|
|
|
- Map<String, Long> serviceFilters = new HashMap<>();
|
|
|
|
- String[] set = lantonePrduct.split(";");
|
|
|
|
- for (String s : set) {
|
|
|
|
- String[] d = s.split(",");
|
|
|
|
- serviceFilters.put(d[0], Long.valueOf(d[1]));
|
|
|
|
- }
|
|
|
|
- return serviceFilters;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ // private Map<String, Long> dealServiceFilter() {
|
|
|
|
+ // Map<String, Long> serviceFilters = new HashMap<>();
|
|
|
|
+ // String[] set = lantonePrduct.split(";");
|
|
|
|
+ // for (String s : set) {
|
|
|
|
+ // String[] d = s.split(",");
|
|
|
|
+ // serviceFilters.put(d[0], Long.valueOf(d[1]));
|
|
|
|
+ // }
|
|
|
|
+ // return serviceFilters;
|
|
|
|
+ // }
|
|
public RespDTO<LinkedHashMap> hasPermission(ServiceToken st) {
|
|
public RespDTO<LinkedHashMap> hasPermission(ServiceToken st) {
|
|
try {
|
|
try {
|
|
RespDTO<LinkedHashMap> res
|
|
RespDTO<LinkedHashMap> res
|