Beispiel #1
0
 /**
  * Get the follower list.
  *
  * @param user current user
  * @param model model
  * @return "user/userOptionGroup"
  */
 @RequestMapping("/switchUserList")
 public String switchUserList(User user, ModelMap model) {
   if (user.getRole().hasPermission(Permission.SWITCH_TO_ANYONE)) {
     List<User> allUserByRole = userService.getAllUserByRole(Role.USER.getFullName());
     model.addAttribute("shareUserList", allUserByRole);
   } else {
     User currUser = userService.getUserByIdWithoutCache(user.getUserId());
     model.addAttribute("shareUserList", currUser.getOwners());
   }
   return "user/userOptionGroup";
 }
Beispiel #2
0
  /**
   * Get user list that current user will be shared, excluding current user.
   *
   * @param user current user
   * @param model model
   */
  private void getUserShareList(User user, ModelMap model) {
    if (user == null) {
      model.addAttribute("followers", Lists.newArrayList());
      model.addAttribute("shareUserList", Lists.newArrayList());
      return;
    }

    List<User> users = Lists.newArrayList();
    String userId = user.getUserId();
    for (User u : userService.getAllUserByRole(Role.USER.getFullName())) {
      if (u.getUserId().equals(userId)) {
        continue;
      }
      users.add(u.getUserBaseInfo());
    }
    model.addAttribute("followers", user.getFollowers());
    model.addAttribute("shareUserList", users);
  }
Beispiel #3
0
  /**
   * Get user list on the given role.
   *
   * @param model model
   * @param roleName role
   * @param keywords search keyword.
   * @return user/userList
   */
  @PreAuthorize("hasAnyRole('A')")
  @RequestMapping({"", "/"})
  public String getUserList(
      ModelMap model,
      @RequestParam(required = false) String roleName,
      @RequestParam(required = false) String keywords) {

    List<User> userList = null;
    if (StringUtils.isEmpty(keywords)) {
      userList = userService.getAllUserByRole(roleName);
    } else {
      userList = userService.getUserListByKeyWord(keywords);
      model.put("keywords", keywords);
    }

    model.addAttribute("userList", userList);
    EnumSet<Role> roleSet = EnumSet.allOf(Role.class);
    model.addAttribute("roleSet", roleSet);
    model.addAttribute("roleName", roleName);

    return "user/userList";
  }