package com.lightinit.hsdatashow.common;

import com.lightinit.hsdatashow.json.pojo.RoleAttributesEntity;
import com.lightinit.hsdatashow.json.pojo.RoleComboEntity;
import com.lightinit.hsdatashow.entity.SentryRole;

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

/**
 * Created by Mr.Yao on 2017/4/24.
 */
public class RoleComboUtils {

    public static RoleComboEntity  RoleComboxConverter(SentryRole role) {
        RoleComboEntity entity=new RoleComboEntity();
        if (role!=null)
        {
            List<RoleComboEntity> tmpList=new ArrayList<RoleComboEntity>();
            List<SentryRole> list=role.getChildren();
            if(list!=null && list.size()>0){
                for (SentryRole _item:list) {
                    RoleComboEntity _entity=RoleComboxConverter(_item);
                    if (_entity!=null)
                        tmpList.add(_entity);
                }
                entity.setIconCls("fi-page-copy");
                entity.setChildren(tmpList);
            }else {
                entity.setIconCls("fi-page");
                entity.setChildren(null);
            }
            entity.setId(role.getId());
            entity.setText(role.getRolename());
            RoleAttributesEntity roleAttributesEntity=new RoleAttributesEntity();
            if (role.getParentid()!=null) {
                roleAttributesEntity.setParentid(role.getParentid());
            }
        }
        return entity;
    }

}
