/** * Get user detail page. * * @param user current user * @param model mode * @param userId user to get * @return "user/userDetail" */ @RequestMapping("/{userId}") @PreAuthorize("hasAnyRole('A') or #user.userId == #userId") public String getUserDetail(User user, final ModelMap model, @PathVariable final String userId) { model.addAttribute("roleSet", EnumSet.allOf(Role.class)); User userFromDB = userService.getUserByIdWithoutCache(userId); model.addAttribute("user", userFromDB); getUserShareList(userFromDB, model); return "user/userDetail"; }
/** * Get the current user profile. * * @param user current user * @param model model * @return "user/userInfo" */ @RequestMapping("/profile") public String userProfile(User user, ModelMap model) { checkNotEmpty(user.getUserId(), "UserID should not be NULL!"); User currentUser = userService.getUserByIdWithoutCache(user.getUserId()); model.addAttribute("user", currentUser); getUserShareList(currentUser, model); model.addAttribute("action", "profile"); return "user/userInfo"; }
/** * 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"; }