Ejemplo n.º 1
0
 @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";
 }
Ejemplo n.º 2
0
 @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";
 }
Ejemplo n.º 3
0
 @RequestMapping(value = "/delete/{userid}", method = RequestMethod.DELETE)
 public String deleteUserViaREST(@PathVariable Integer userid) {
   userService.deleteUser(userService.getUserById(userid));
   return "redirect:/user";
 }
Ejemplo n.º 4
0
 @RequestMapping(value = "/delete", method = RequestMethod.GET)
 public String deleteUser(@RequestParam("userId") Integer userid) {
   userService.deleteUser(userService.getUserById(userid));
   return "redirect:/user";
 }