@Test public void structuringPermissionsSimply() { Long id = mockData(); List<PermissionDO> permissions = permissionService.getPermissionByGroupIds(Collections.singletonList(id)); Map<String, List<String>> structuringPermissions = permissionService.structuringPermissionsSimply(permissions); assertTrue(structuringPermissions.size() > 0); assertTrue(structuringPermissions.containsKey("炉石传说")); log.info("structuringPermissions: {}", structuringPermissions); }
@Override public Map<String, List<String>> structuringPermissionsSimply(List<PermissionDO> permissions) { Map<String, List<String>> res = new HashMap<>(); permissions.forEach(permission -> { if (res.containsKey(permission.getModule())) { List<String> mod = res.get(permission.getModule()); mod.add(permission.getName()); } else { List<String> mod = new ArrayList<>(); mod.add(permission.getName()); res.put(permission.getModule(), mod); } }); return res; }
PermissionServiceImpl extends ServiceImpl<PermissionMapper, PermissionDO> implements PermissionService { @Override public Map<String, List<String>> structuringPermissionsSimply(List<PermissionDO> permissions) { Map<String, List<String>> res = new HashMap<>(); permissions.forEach(permission -> { if (res.containsKey(permission.getModule())) { List<String> mod = res.get(permission.getModule()); mod.add(permission.getName()); } else { List<String> mod = new ArrayList<>(); mod.add(permission.getName()); res.put(permission.getModule(), mod); } }); return res; } }
PermissionServiceImpl extends ServiceImpl<PermissionMapper, PermissionDO> implements PermissionService { @Override public Map<String, List<String>> structuringPermissionsSimply(List<PermissionDO> permissions) { Map<String, List<String>> res = new HashMap<>(); permissions.forEach(permission -> { if (res.containsKey(permission.getModule())) { List<String> mod = res.get(permission.getModule()); mod.add(permission.getName()); } else { List<String> mod = new ArrayList<>(); mod.add(permission.getName()); res.put(permission.getModule(), mod); } }); return res; }  }
PermissionServiceImpl extends ServiceImpl<PermissionMapper, PermissionDO> implements PermissionService { @Override public Map<String, List<String>> structuringPermissionsSimply(List<PermissionDO> permissions) { Map<String, List<String>> res = new HashMap<>(); permissions.forEach(permission -> { if (res.containsKey(permission.getModule())) { List<String> mod = res.get(permission.getModule()); mod.add(permission.getName()); } else { List<String> mod = new ArrayList<>(); mod.add(permission.getName()); res.put(permission.getModule(), mod); } }); return res; }  @Override List<PermissionDO> getPermissionByGroupId(Long groupId); @Override List<PermissionDO> getPermissionByGroupIds(List<Long> groupIds); @Override Map<Long, List<PermissionDO>> getPermissionMapByGroupIds(List<Long> groupIds); @Override List<Map<String, List<Map<String, String>>>> structuringPermissions(List<PermissionDO> permissions); @Override Map<String, List<String>> structuringPermissionsSimply(List<PermissionDO> permissions); }
PermissionServiceImpl extends ServiceImpl<PermissionMapper, PermissionDO> implements PermissionService { @Override public Map<String, List<String>> structuringPermissionsSimply(List<PermissionDO> permissions) { Map<String, List<String>> res = new HashMap<>(); permissions.forEach(permission -> { if (res.containsKey(permission.getModule())) { List<String> mod = res.get(permission.getModule()); mod.add(permission.getName()); } else { List<String> mod = new ArrayList<>(); mod.add(permission.getName()); res.put(permission.getModule(), mod); } }); return res; }  @Override List<PermissionDO> getPermissionByGroupId(Long groupId); @Override List<PermissionDO> getPermissionByGroupIds(List<Long> groupIds); @Override Map<Long, List<PermissionDO>> getPermissionMapByGroupIds(List<Long> groupIds); @Override List<Map<String, List<Map<String, String>>>> structuringPermissions(List<PermissionDO> permissions); @Override Map<String, List<String>> structuringPermissionsSimply(List<PermissionDO> permissions);  }