@ResponseBody @RequestMapping(value = "/{userid}", method = RequestMethod.DELETE) @RequiresRoles("admin") public Object remove(@PathVariable("userid") String userid) { userService.deleteById(userid); return new MapContainer("success", true); }
@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"; }
@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"; }
@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"; }
@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"; }
@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"; }