Commit ad69e05e by chamberone

feat: 二级菜单权限过滤

1 parent 9f28efa0
...@@ -4,6 +4,7 @@ import java.util.Arrays; ...@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
...@@ -145,13 +146,16 @@ public class UserService { ...@@ -145,13 +146,16 @@ public class UserService {
if (CollectionUtils.isNotEmpty(resources)) { if (CollectionUtils.isNotEmpty(resources)) {
// 菜单嵌套处理+菜单排序 // 菜单嵌套处理+菜单排序
final Set<String> resourceIds = resources.stream().map(r -> r.getId()).collect(Collectors.toSet());
List<ResourceInfo> levelOne = resources.stream() List<ResourceInfo> levelOne = resources.stream()
.filter(r -> StringUtils.isEmpty(r.getParentId()) && r.getType() == 1) .filter(r -> StringUtils.isEmpty(r.getParentId()) && r.getType() == 1)
.map(r -> BeanUtil.copyProperties(r, ResourceInfo.class)).collect(Collectors.toList()); .map(r -> BeanUtil.copyProperties(r, ResourceInfo.class)).collect(Collectors.toList());
for (ResourceInfo resourceInfo : levelOne) { for (ResourceInfo resourceInfo : levelOne) {
splitMenuExtra(resourceInfo); splitMenuExtra(resourceInfo);
List<ResourceEntity> levelTow = resourceDao.findByParentId(resourceInfo.getId()); List<ResourceEntity> levelTow = resourceDao.findByParentId(resourceInfo.getId());
List<ResourceInfo> levelTowResourceInfo = levelTow.stream().map(r -> { List<ResourceInfo> levelTowResourceInfo = levelTow.stream()
// 过滤未配置二级菜单
.filter(r -> resourceIds.contains(r.getId())).map(r -> {
ResourceInfo res = BeanUtil.copyProperties(r, ResourceInfo.class); ResourceInfo res = BeanUtil.copyProperties(r, ResourceInfo.class);
splitMenuExtra(res); splitMenuExtra(res);
return res; return res;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!