@RequestMapping(value = "/modify/{userid}", method = RequestMethod.POST) public String modifyUser( @ModelAttribute("userBean") UserFormBean userBean, @PathVariable Integer userid, Model model) { User u = userService.getUserById(userid); userBean.setUserId(u.getUserId()); userBean.setCreatedBy(u.getCreatedBy()); userService.modifyUser(userFrom2user(u, userBean)); return "redirect:/user"; }
@RequestMapping(value = "/modify/{userid}", method = RequestMethod.GET) public String modifyUser(@PathVariable Integer userid, Model model) { UserFormBean formBean = new UserFormBean(); User user = userService.getUserById(userid); BeanUtils.copyProperties(user, formBean); if (user.getRoles() != null && user.getRoles().size() > 0) { Set<String> roleNames = new HashSet<String>(); for (Role role : user.getRoles()) { roleNames.add(role.getRoleName()); } formBean.setRoleNames(roleNames); } model.addAttribute("userBean", formBean); model.addAttribute("roles", roleService.findAll()); return "user/modify"; }
@RequestMapping(value = "/delete/{userid}", method = RequestMethod.DELETE) public String deleteUserViaREST(@PathVariable Integer userid) { userService.deleteUser(userService.getUserById(userid)); return "redirect:/user"; }
@RequestMapping(value = "/delete", method = RequestMethod.GET) public String deleteUser(@RequestParam("userId") Integer userid) { userService.deleteUser(userService.getUserById(userid)); return "redirect:/user"; }