组件管理加排序
This commit is contained in:
@@ -26,10 +26,7 @@ import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -110,6 +107,7 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
|
||||
ComponentVO componentVO = new ComponentVO();
|
||||
componentVO.setId(dictData.getId());
|
||||
componentVO.setName(dictData.getName());
|
||||
componentVO.setSort(dictData.getSort());
|
||||
componentVO.setChildren(
|
||||
v.stream()
|
||||
.filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
|
||||
@@ -117,6 +115,7 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
|
||||
.collect(Collectors.toList()));
|
||||
result.add(componentVO);
|
||||
});
|
||||
result.sort(Comparator.comparing(ComponentVO::getSort));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -182,7 +181,7 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
|
||||
*/
|
||||
private List<ComponentVO> getChildCategoryList(ComponentVO currMenu, List<ComponentVO> categories) {
|
||||
return categories.stream().filter(o -> Objects.equals(o.getPid(), currMenu.getId()))
|
||||
.peek(o -> o.setChildren(getChildCategoryList(o, categories)))
|
||||
.peek(o -> o.setChildren(getChildCategoryList(o, categories))).sorted(Comparator.comparing(ComponentVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user