Ejemplo n.º 1
0
 @RequestMapping(
     value = "{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseBody
 public User findUser(@PathVariable("id") int id) {
   return userService.findUserById(id);
 }
Ejemplo n.º 2
0
 @RequestMapping(
     value = "",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseBody
 public List<User> findAll() {
   return userService.findAll();
 }
Ejemplo n.º 3
0
 @RequestMapping(
     value = "{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseBody
 public ResponseEntity<Void> deleteUser(@PathVariable("id") int id) {
   userService.deleteUser(id);
   return new ResponseEntity<>(HttpStatus.OK);
 }
Ejemplo n.º 4
0
 @RequestMapping(
     value = "",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseBody
 public ResponseEntity<User> updateUser(@RequestBody User user) {
   User savedUser = userService.update(user);
   return new ResponseEntity<User>(savedUser, HttpStatus.OK);
 }