Beispiel #1
0
 @ResponseBody
 @RequestMapping(value = "/{userid}", method = RequestMethod.DELETE)
 @RequiresRoles("admin")
 public Object remove(@PathVariable("userid") String userid) {
   userService.deleteById(userid);
   return new MapContainer("success", true);
 }
Beispiel #2
0
  @RequestMapping(method = RequestMethod.PUT)
  public String update(User user, String repass, Model model) {
    MapContainer form = UserFormValidator.validateUpdate(user, repass);
    if (!form.isEmpty()) {
      model.addAllAttributes(form);
      model.addAttribute("user", user);
      return "backend/user/edit";
    }

    user.setLastUpdate(new Date());
    userService.update(user);
    return "redirect:/backend/users";
  }
Beispiel #3
0
  @RequestMapping(value = "/my", method = RequestMethod.PUT)
  public String upmy(User user, String repass, Model model) {
    MapContainer form = UserFormValidator.validateMy(user, repass);
    if (!form.isEmpty()) {
      model.addAllAttributes(form);
      model.addAttribute("my", user);
      return "backend/user/my";
    }

    user.setRole(WebContextFactory.get().getUser().getRole());
    user.setLastUpdate(new Date());
    userService.update(user);
    return "redirect:/backend/users";
  }
Beispiel #4
0
  @RequestMapping(method = RequestMethod.POST)
  @RequiresRoles("admin")
  public String insert(User user, String repass, Model model) {
    MapContainer form = UserFormValidator.validateInsert(user, repass);
    if (!form.isEmpty()) {
      model.addAllAttributes(form);
      return "backend/user/edit";
    }

    user.setId(IdGenerator.uuid19());
    user.setCreateTime(new Date());
    user.setLastUpdate(user.getCreateTime());

    userService.insert(user);
    return "redirect:/backend/users";
  }
Beispiel #5
0
 @RequestMapping(value = "/edit", method = RequestMethod.GET)
 public String edit(String uid, Model model) {
   if (!StringUtils.isBlank(uid)) model.addAttribute("user", userService.loadById(uid));
   return "backend/user/edit";
 }
Beispiel #6
0
 @RequestMapping(method = RequestMethod.GET)
 @RequiresRoles("admin")
 public String index(@RequestParam(value = "page", defaultValue = "1") int page, Model model) {
   model.addAttribute("page", userService.list(page, 15));
   return "backend/user/list";
 }