代码之家  ›  专栏  ›  技术社区  ›  Vili Terry Li

如何检查另一个用户是否在公司层次结构中处于同一级别或更低级别?

  •  1
  • Vili Terry Li  · 技术社区  · 15 年前

    我有这个:

    UserProfile prof = getUserProfile(properties.CurrentUserId);
    UserProfile toCheck = getUserProfile(anotherUsersId);
    

    有没有一个简单的方法来检查这个?

    2 回复  |  直到 15 年前
        1
  •  2
  •   Alex Angas Colin    15 年前

    这里有一些方法可以帮助您:

    我发现没有“简单的方法”,但您可以编写自己的助手类,使用这些方法,遍历用户配置文件,并找到所需的信息。

    旁白:“同事”与此无关。他们是一个列表,通过完整的“我的网站”实现,用户可以管理自己。

        2
  •  0
  •   Vili Terry Li    15 年前

    function compare(manager, toCheck, prof) 
    {
        toManager=toCheck.manager;
        if (toManager!=null)
        {
            if (manager==tomanager || prof==tomanager)
            {
                return true;
            }
            else
            {
                return compare("", tomanager, prof);
            }
        }
        else // he/she is the boss
        {
            return false;
        }
    
    }
    
    ...
    
    if (prof.manager!=null)
    {
        compare(prof.manager, toCheck, prof);
    }
    else  // he/she is the boss
    {
        return true;
    }