public List<JSONObject> getDictTree(String remarks) {
List<JSONObject> tree = new ArrayList<>();
List<SysDict> list=sysDictRepository.getAllByRemarksAndIsEnableAndDelFlag(remarks,"1", Constants.DELETE_DEFAULT);
for (SysDict dic : list)
{
JSONObject parent = new JSONObject();
parent.put("label",dic.getLabel());
parent.put("id",dic.getId());
//获取一级节点的子节点
List<SysDictContent> children = sysDictContentRepository.findAllByParentId(dic.getId());
List<JSONObject> childrenList = new ArrayList<>();
if(children!=null && !children.isEmpty()){
for (SysDictContent child : children) {
JSONObject childJson = new JSONObject();
childJson.put("label",child.getLabel());
childJson.put("id",child.getId());
childrenList.add(childJson);
}
parent.put("children",childrenList);
}
tree.add(parent);
}
return tree;
}