package com.railway.common.utils;

import com.railway.common.core.domain.TreeSelect;
import com.railway.common.core.domain.entity.SysDept;
import com.railway.common.core.domain.entity.SysMenu;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;

/**
 * @author zhaomn
 */
public class TreeSelectUtil {

  public static void setTreeSelect(List<TreeSelect> treeSelects) {
    for (TreeSelect tree : treeSelects) {
      if (CollectionUtils.isEmpty(tree.getChildren())) {
        tree.setChildren(null);
      } else {
        setTreeSelect(tree.getChildren());
      }
    }
  }

  public static void setDeptTree(List<SysDept> deptList) {
    for (SysDept dept : deptList) {
      if (CollectionUtils.isEmpty(dept.getChildren())) {
        dept.setChildren(null);
      } else {
        setDeptTree(dept.getChildren());
      }
    }
  }

  public static void setMenuTree(List<SysMenu> menuList) {
    for (SysMenu menu : menuList) {
      if (CollectionUtils.isEmpty(menu.getChildren())) {
        menu.setChildren(null);
      } else {
        setMenuTree(menu.getChildren());
      }
    }
  }

}
