mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-31 01:01:27 +08:00
JeecgBoot 3.6.0大版本发布
This commit is contained in:
@ -205,23 +205,23 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
|
||||
}
|
||||
Object predicates = obj.get("predicates");
|
||||
if (predicates != null) {
|
||||
|
||||
//update-begin-author:liusq---date:2023-10-15--for: [issues/5331]网关路由配置问题
|
||||
List<PredicatesVo> list = JSON.parseArray(predicates.toString(), PredicatesVo.class);
|
||||
//获取合并后的Predicates,防止配置多个path导致路径失效的问题
|
||||
Map<String, List<String>> groupedPredicates = new HashMap<>();
|
||||
|
||||
for (PredicatesVo predicatesVo : list) {
|
||||
String name = predicatesVo.getName();
|
||||
List<String> args = predicatesVo.getArgs();
|
||||
groupedPredicates.computeIfAbsent(name, k -> new ArrayList<>()).addAll(args);
|
||||
}
|
||||
|
||||
//合并后的list
|
||||
list = new ArrayList<>();
|
||||
for (Map.Entry<String, List<String>> entry : groupedPredicates.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
List<String> args = entry.getValue();
|
||||
list.add(new PredicatesVo(name, args));
|
||||
}
|
||||
|
||||
//update-end-author:liusq---date:2023-10-15--for:[issues/5331]网关路由配置问题
|
||||
List<PredicateDefinition> predicateDefinitionList = new ArrayList<>();
|
||||
for (Object map : list) {
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONString(map));
|
||||
|
||||
@ -6,11 +6,15 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 路由配置VO
|
||||
* @author lsq
|
||||
* @Date 2023/10/15
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PredicatesVo {
|
||||
private String name;
|
||||
private List<String> args;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
import org.jeecg.loader.vo.PredicatesVo;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 测试
|
||||
* @author: lsq
|
||||
* @date: 2023年10月13日 11:32
|
||||
*/
|
||||
public class TestRoutes {
|
||||
|
||||
@Test
|
||||
public void TestRoutes() {
|
||||
List<PredicatesVo> list = new ArrayList<>();
|
||||
PredicatesVo a = new PredicatesVo();
|
||||
a.setName("path");
|
||||
String[] aArr={"/sys/**","/eoa/**"};
|
||||
a.setArgs(Arrays.asList(aArr));
|
||||
list.add(a);
|
||||
|
||||
PredicatesVo b = new PredicatesVo();
|
||||
b.setName("path");
|
||||
String[] bArr={"/sys/**","/demo/**"};
|
||||
b.setArgs(Arrays.asList(bArr));
|
||||
list.add(b);
|
||||
|
||||
Map<String, List<String>> groupedPredicates = new HashMap<>();
|
||||
for (PredicatesVo predicatesVo : list) {
|
||||
String name = predicatesVo.getName();
|
||||
List<String> args1 = predicatesVo.getArgs();
|
||||
groupedPredicates.computeIfAbsent(name, k -> new ArrayList<>()).addAll(args1);
|
||||
}
|
||||
System.out.println(groupedPredicates);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user