예제 #1
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";
  }
예제 #2
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";
  }
예제 #3
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";
  }