Ejemplo n.º 1
0
  /**
   * 根据角色ID查找剩余的功能列表
   *
   * @param roleId 角色ID
   * @return 功能列表
   */
  public List<Function> findLeftFunctionsByRoleId(Long roleId) {
    List<Function> leftFunctions = new ArrayList<Function>();
    List<Function> functions = new ArrayList<Function>();
    Role role = roleDao.get(roleId);
    if (null != role) {
      Set<Function> functionSet = role.getFunctions();
      for (Function function : functionSet) {
        // 过滤Root类型的功能(functionParen为0)
        // if (0 != function.getFunctionParent()) {
        functions.add(function);
        // }
      }
    }

    List<Function> allFunctions = functionDao.loadAll();
    for (Function functionDB : allFunctions) {
      // 过滤Root类型的功能(functionParen为0)
      // if (0 != functionDB.getFunctionParent()) {
      leftFunctions.add(functionDB);
      // }
    }

    leftFunctions.removeAll(functions);

    return leftFunctions;
  }
Ejemplo n.º 2
0
 /**
  * 通过角色ID查找角色
  *
  * @param roleId 角色ID
  * @return 角色
  */
 public Role loadRole(Long roleId) {
   return (Role) roleDao.get(roleId);
 }
Ejemplo n.º 3
0
 /**
  * 根据角色ID移除角色
  *
  * @param roleId 角色ID
  */
 public void deleteRole(Long roleId) {
   Role role = roleDao.get(roleId);
   roleDao.delete(role);
 }