四零语境后端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

1 month ago
  1. import org.jeecg.loader.vo.PredicatesVo;
  2. import org.junit.jupiter.api.Test;
  3. import java.util.*;
  4. /**
  5. * @Description: 测试
  6. * @author: lsq
  7. * @date: 2023年10月13日 11:32
  8. */
  9. public class TestRoutes {
  10. @Test
  11. public void TestRoutes() {
  12. List<PredicatesVo> list = new ArrayList<>();
  13. PredicatesVo a = new PredicatesVo();
  14. a.setName("path");
  15. String[] aArr={"/sys/**","/eoa/**"};
  16. a.setArgs(Arrays.asList(aArr));
  17. list.add(a);
  18. PredicatesVo b = new PredicatesVo();
  19. b.setName("path");
  20. String[] bArr={"/sys/**","/demo/**"};
  21. b.setArgs(Arrays.asList(bArr));
  22. list.add(b);
  23. Map<String, List<String>> groupedPredicates = new HashMap<>();
  24. for (PredicatesVo predicatesVo : list) {
  25. String name = predicatesVo.getName();
  26. List<String> args1 = predicatesVo.getArgs();
  27. groupedPredicates.computeIfAbsent(name, k -> new ArrayList<>()).addAll(args1);
  28. }
  29. System.out.println(groupedPredicates);
  30. }
  31. }