package com.mortals.xhx.module.area.model;

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

import com.mortals.framework.common.code.YesNo;
import com.mortals.xhx.module.area.model.vo.AreaVo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.mortals.xhx.module.site.model.SiteEntity;
import lombok.Data;

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

/**
 * 区域前端映射树结构实体类
 *
 * @author zxfei
 * @date 2022-01-12
 */
@Data
public class AreaTreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

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

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

    private String areaCode;

    private Boolean isLeaf;

    /**
     * 节点类型
     */
    private String type;

    /**
     * 图标
     */
    private String icon;

    /**
     * 子节点
     */
    private List<AreaTreeSelect> children;

    public AreaTreeSelect(AreaEntity entity) {
        this.id = entity.getIid();
        this.label = entity.getName();
        if ("False".equalsIgnoreCase(entity.getHaveSonArea())) {
            this.isLeaf = true;
            this.children = new ArrayList();
        } else {
            this.isLeaf = false;
        }
        this.areaCode=entity.getAreaCode();
        this.type = "area";
        this.icon = "el-icon-folder";
    }

    public AreaTreeSelect(SiteEntity entity) {
        this.id = entity.getId().toString();
        this.label = entity.getSiteName();
        this.isLeaf = true;
        this.type = "site";
        this.icon = "el-icon-document";

    }

}