feat: 体系数据列表 release
This commit is contained in:
@@ -17,6 +17,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -64,6 +65,10 @@ public class SarMenuStandard extends BaseEntity {
|
||||
@TableField("DISPLAY_SEQ")
|
||||
private Integer displaySeq;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
@TableField(exist = false)
|
||||
private Integer systemSort;
|
||||
|
||||
@ApiModelProperty(value = "路径")
|
||||
@TableField("HREF")
|
||||
private String href;
|
||||
@@ -146,4 +151,54 @@ public class SarMenuStandard extends BaseEntity {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// 添加用于构建映射的方法
|
||||
public void buildPathMap(Map<String, String> pathMap, String parentPath) {
|
||||
String currentPath = parentPath.isEmpty() ? this.menuName : parentPath + "/" + this.menuName;
|
||||
pathMap.put(this.id, currentPath);
|
||||
for (SarMenuStandard child : children) {
|
||||
child.buildPathMap(pathMap, currentPath);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加用于收集子节点ID的方法
|
||||
public void collectChildIds(List<String> childIds) {
|
||||
childIds.add(this.id);
|
||||
for (SarMenuStandard child : children) {
|
||||
child.collectChildIds(childIds);
|
||||
}
|
||||
}
|
||||
|
||||
public static SarMenuStandard findNodeById(SarMenuStandard node, String menuId) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
// 检查当前节点的ID是否匹配
|
||||
if (menuId.equals(node.getId())) {
|
||||
return node;
|
||||
}
|
||||
// 在子节点中递归搜索
|
||||
for (SarMenuStandard child : node.getChildren()) {
|
||||
SarMenuStandard found = findNodeById(child, menuId);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
// 如果在当前节点及其子节点中都没有找到,返回null
|
||||
return null;
|
||||
}
|
||||
|
||||
// 递归方法来设置每个节点的 systemSort
|
||||
public static void setSystemSort(SarMenuStandard node, String parentSort) {
|
||||
// 计算当前节点的 systemSort
|
||||
String currentSort = parentSort.isEmpty() ? String.valueOf(node.getDisplaySeq()) : parentSort + node.getDisplaySeq();
|
||||
|
||||
// 设置当前节点的 systemSort
|
||||
node.setSystemSort(Integer.parseInt(currentSort));
|
||||
|
||||
// 递归设置子节点的 systemSort
|
||||
for (SarMenuStandard child : node.getChildren()) {
|
||||
setSystemSort(child, currentSort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user