@RequestMapping( value = "{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public User findUser(@PathVariable("id") int id) { return userService.findUserById(id); }
@RequestMapping( value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<User> findAll() { return userService.findAll(); }
@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); }
@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); }