TreeNodeVO.java 1.6 KB
package com.skua.modules.common.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 * @auther kangwei
 * @create 2025-01-15-9:52
 */
@Data
@ApiModel(value="树结构", description="树结构")
public class TreeNodeVO {
    @ApiModelProperty(value = "节点编号")
    private String id;
    @ApiModelProperty(value = "上级节点编号")
    private String parentId;

    @ApiModelProperty(value = "节点名称")
    private String label;
    @ApiModelProperty(value = "是否叶子结点")
    private boolean isLeaf;

    @ApiModelProperty(value = "完成时间")
    private String completeTime;

    @ApiModelProperty(value = "负责人")
    private String responsibler;

    @ApiModelProperty(value = "子集合")
    private List<TreeNodeVO> children = new ArrayList<>();

    public TreeNodeVO() {
    }

    public TreeNodeVO(String id, String parentId, String label) {
        this.id = id;
        this.parentId = parentId;
        this.label = label;
    }

    public TreeNodeVO(String id, String parentId, String label, String completeTime, String responsibler) {
        this.id = id;
        this.parentId = parentId;
        this.label = label;
        this.completeTime = completeTime;
        this.responsibler = responsibler;
    }

    public boolean isLeaf() {
        isLeaf = true;
        if(children != null && !children.isEmpty()){
            isLeaf = false;
        }
        return isLeaf;
    }

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