package com.app.admin.framework.system.permission.role.convert;

import com.app.admin.framework.system.permission.role.model.SysRole;
import com.app.framework.core.support.view.tree.ZTreeNode;

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

public class SysRoleTreeConvert {

	public List<ZTreeNode> convertTree(List<SysRole> lists, List<Long> selectRoleIdList){
		List<ZTreeNode> nodes = new ArrayList<>();
		for (Iterator<SysRole> iterator = lists.iterator(); iterator.hasNext();) {
			SysRole r = iterator.next();
			ZTreeNode node = new ZTreeNode();
			node.setOid(r.getOid().toString());
			node.setName(r.getName());
			node.setIsParent(false);
			if(selectRoleIdList != null && selectRoleIdList.contains(r.getOid())){
				node.setChecked(true);
			}
			nodes.add(node);
		}
		return nodes;
	}
}
