package com.xhkjedu.smarking.vo.report.reportsubject;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class PointVo {
    //知识点表
    private String pointid;

    //知识点名称
    private String pointname;

    //知识点排序
    private Integer pointorder;

    //所属知识点id
    private String pointpid;

    private List<PointVo> children = new ArrayList<>();


    public PointVo() {}

    public PointVo(String pointid, String pointpid) {
        this.pointid = pointid;
        this.pointpid = pointpid;
        this.children = new ArrayList<>();
    }

    public void addChild(PointVo child) {
        children.add(child);
    }

    // 获取父节点的方法
    public PointVo getParent(List<PointVo> allNodes) {
        for (PointVo node : allNodes) {
            if (node.getPointid().equals(this.pointpid)) {
                return node;
            }
        }
        return null;
    }
}
