Java递归实例

2022-02-10 14:42:46 浏览数 (1)

代码语言:javascript复制
/**
     * 深度向下查询parentId
     * 
     * @param calltext  调用上下文,必填
     * @param parentId  父单元Id
     * @param parentIds 部门id集
     * @return 父部门下所有层级子部门id集合
     */
    public List<Department> depthFindParentId(String parentId, List<Department> units) {
        List<Department> departments = _departmentSvc.findByParentId(parentId, null);
        if (departments!=null && departments.size() > 0) {
            for (Department dep : departments) {
                units.add(dep);
                depthFindParentId(dep.getId(), units);
            }
        }
        return units;
    }

0 人点赞