Ejemplo n.º 1
0
 /** Delete user */
 @ResponseBody
 @RequestMapping(value = "delete/{id}")
 public Map<String, Object> delete(Model model, @PathVariable int id) {
   userService.delete(id);
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("msg", "success");
   return map;
 }
Ejemplo n.º 2
0
 /** Create user */
 @RequestMapping(value = "create")
 public String create(
     Model model,
     @RequestParam(value = "name") String name,
     @RequestParam(value = "age") int age) {
   User user = new User();
   user.setName(name);
   user.setAge(age);
   user = userService.save(user);
   model.addAttribute("user", user);
   return "user";
 }
Ejemplo n.º 3
0
 /** update user */
 @ResponseBody
 @RequestMapping(value = "update/{id}")
 public User update(
     Model model,
     @PathVariable int id,
     @RequestParam(value = "name", required = false) String name,
     @RequestParam(value = "age", required = false) int age) {
   User user = new User();
   user.setId(id);
   if (null != name) {
     user.setName(name);
   }
   if (0 < age) {
     user.setAge(age);
   }
   userService.update(user);
   return user;
 }
Ejemplo n.º 4
0
 /** list user */
 @ResponseBody
 @RequestMapping(value = "list")
 public List<User> list(Model model) {
   List<User> users = userService.list("");
   return users;
 }
Ejemplo n.º 5
0
 /** get user */
 @ResponseBody
 @RequestMapping(value = "get/{id}")
 public User get(Model model, @PathVariable int id) {
   User user = userService.get(id);
   return user;
 }