@RequestMapping(value = "/adminEditUser", method = RequestMethod.POST) public String updateUser(@ModelAttribute(value = "user") User user, BindingResult result) { if (user != null) { userService.updateUser(user); } return "redirect:/adminPanel"; }
@RequestMapping(value = "adminPanel", method = RequestMethod.GET) public String adminPanel(ModelMap model, Principal principal) { // User admin = userService.getUser(principal.getName()); model.addAttribute("users", userService.getAllUsers()); return "adminPanel"; }
@RequestMapping(value = "adminEditUser", method = RequestMethod.GET) public String editUser(HttpServletRequest request, ModelMap model) { String id = request.getParameter("id"); if (id != null && !id.isEmpty()) { model.addAttribute("user", userService.getUser(Integer.parseInt(id))); return "adminEditUser"; } return "adminPanel"; }
@RequestMapping(value = "/adminDeleteUser", method = RequestMethod.GET) public String deleteAccount(HttpServletRequest request, Principal principal) { String id = request.getParameter("id"); if (id != null && !id.isEmpty()) { userService.removeUser(Long.parseLong(id)); } HttpSession session = request.getSession(false); if (session != null) { session.invalidate(); } return "redirect:/adminPanel"; }