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

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

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

@Data
public class TagIdModel implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    private String key;

    /**
     * 主键ID
     */
    private String value;

    /**
     * 部门名称
     */
    private String title;
    private String tagCode;

    List<TagIdModel> children = new ArrayList<>();

    /**
     * 将SysDepartTreeModel的部分数据放在该对象当中
     * @param treeModel 树状结构
     * @return 部门信息
     */
    public TagIdModel convert(TagInfoTreeModel treeModel) {
        this.key = treeModel.getId()+"";
        this.value = treeModel.getId()+"";
        this.title = treeModel.getTagName();
        this.tagCode = treeModel.getTagCode();
        return this;
    }

    /**
     * 该方法为用户部门的实现类所使用
     * @param sysDepart 系统部门信息
     * @return 部门信息
     */
    public TagIdModel convertByUserDepart(TagInfo sysDepart) {
        this.key = sysDepart.getId()+"";
        this.value = sysDepart.getId()+"";
        this.title = sysDepart.getTagName();
        return this;
    }
}
