package com.xinelu.manage.vo.termbank;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 知识库树图信息对象vo
 *
 * @author zh
 * @date 2024-06-13
 */
@Data
public class TermBankTreeVO implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private Long id;

    /**
     * 节点名称
     */
    private String label;

    /**
     * 节点层级
     */
    private String value;


    private String termCode;

    private String termContent;

    private String parentTermCode;

    private Long termLevel;

    private Long termSort;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TermBankTreeVO> children;

    public TermBankTreeVO() {

    }

    public TermBankTreeVO(TermBankVO termBank) {
        this.id = termBank.getId();
        this.termCode = termBank.getTermCode();
        this.termContent = termBank.getTermContent();
        this.parentTermCode = termBank.getParentTermCode();
        this.termLevel = termBank.getTermLevel();
        this.termSort = termBank.getTermSort();
        this.children = termBank.getChildren().stream().map(TermBankTreeVO::new).collect(Collectors.toList());
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTermCode() {
        return termCode;
    }

    public void setTermCode(String termCode) {
        this.termCode = termCode;
    }

    public String getTermContent() {
        return termContent;
    }

    public void setTermContent(String termContent) {
        this.termContent = termContent;
    }

    public String getParentTermCode() {
        return parentTermCode;
    }

    public void setParentTermCode(String parentTermCode) {
        this.label = parentTermCode;
    }

    public Long getTermLevel() {
        return termLevel;
    }

    public void setTermLevel(String termLevel) {
        this.label = termLevel;
    }

    public Long getTermSort() {
        return termSort;
    }

    public void setTermSort(String termSort) {
        this.label = termSort;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public List<TermBankTreeVO> getChildren() {
        return children;
    }

    public void setChildren(List<TermBankTreeVO> children) {
        this.children = children;
    }
}
