package cn.com.ctop.common.module.model;

import cn.com.ctop.common.module.entity.TagInfo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TagInfoTreeModel implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     *对应TagInfo中的id字段,前端数据树中的key
     */
    private String key;

    /**
     *对应TagInfo中的id字段,前端数据树中的value
     */
    private String value;

    /**
     *对应name字段,前端数据树中的title
     */
    private String title;

    /**
     * 以下所有字段均与TagInfo相同
     */
    private boolean isLeaf;

    private Long id;
    private Long parentId;
    private String tagName;
    private Integer tagOrder;
    private String description;
    private String tagCode;
    private Integer status;
    private Integer delFlag;
    private Integer level;
    private Date createTime;
    private Date updateTime;
    private List<TagInfoTreeModel> children = new ArrayList<>();

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

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

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean isLeaf() {
        return isLeaf;
    }

    public void setIsLeaf(boolean leaf) {
        isLeaf = leaf;
    }

    public Long getId() {
        return id;
    }

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

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getTagName() {
        return tagName;
    }

    public void setTagName(String tagName) {
        this.tagName = tagName;
    }

    public Integer getTagOrder() {
        return tagOrder;
    }

    public void setTagOrder(Integer tagOrder) {
        this.tagOrder = tagOrder;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getTagCode() {
        return tagCode;
    }

    public void setTagCode(String tagCode) {
        this.tagCode = tagCode;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * 将SysDepart对象转换成SysDepartTreeModel对象
     * @param tagInfo
     */
    public TagInfoTreeModel(TagInfo tagInfo) {
        this.key = tagInfo.getId()+"";
        this.value = tagInfo.getId()+"";
        this.title = tagInfo.getTagName();
        this.id = tagInfo.getId();
        this.parentId = tagInfo.getParentId();
        this.tagName = tagInfo.getTagName();
        this.tagOrder = tagInfo.getTagOrder();
        this.description = tagInfo.getDescription();
        this.tagCode = tagInfo.getTagCode();
        this.status = tagInfo.getStatus();
        this.delFlag = tagInfo.getDelFlag();
        this.createTime = tagInfo.getCreateTime();
        this.updateTime = tagInfo.getUpdateTime();
        this.level = tagInfo.getLevel();
    }


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

    public void setChildren(List<TagInfoTreeModel> children) {
        if (children==null){
            this.isLeaf=true;
        }
        this.children = children;
    }

    public TagInfoTreeModel() {

    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }
}
