package com.ruoyi.common.core.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

/**
 * Tree基类
 *
 * @author ruoyi
 */
@EqualsAndHashCode(callSuper = true)
@Data
public abstract class TreeEntity extends BaseEntity
{
    private static final long serialVersionUID = 1L;


    /** 父部门ID */
    protected String parentId = "0";

    /** 祖级列表 */
    protected String ancestors = "0,";

    public abstract String getId();

    public String makeSelfAsNewParentIds() {
        if (StringUtils.isEmpty(getAncestors())) {
            return getId() + ",";
        }
        return getAncestors() + getId() + ",";
    }
}
