/** * 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"; }
/** * 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); }