@RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json") public ResponseEntity<String> createFromJson(@RequestBody String json) { Userinfo userinfo = Userinfo.fromJsonToUserinfo(json); userService.saveUserinfo(userinfo); HttpHeaders headers = new HttpHeaders(); headers.add(CONTENT_TYPE, APPLICATION_JSON); return new ResponseEntity<String>(headers, HttpStatus.CREATED); }
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, headers = "Accept=application/json") public ResponseEntity<String> updateFromJson( @RequestBody String json, @PathVariable("id") Long id) { HttpHeaders headers = new HttpHeaders(); headers.add(CONTENT_TYPE, APPLICATION_JSON); Userinfo userinfo = Userinfo.fromJsonToUserinfo(json); if (userService.updateUserinfo(userinfo) == null) { return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND); } return new ResponseEntity<String>(headers, HttpStatus.OK); }