コード例 #1
0
 /**
  * POST /taskusers { "name": "name of the taskuser" }
  *
  * <p>Creates a new taskuser.
  *
  * @param json
  * @return json containing the id of the newly created taskuser
  */
 @RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
 public ResponseEntity<String> createFromJson(@RequestBody String json) {
   TaskUser createdTaskUser = taskusers.save(TaskUser.fromJsonToTaskUser(json));
   HttpHeaders headers = new HttpHeaders();
   headers.add("Content-Type", "application/text");
   return new ResponseEntity<String>(
       "{\"id\":" + createdTaskUser.getId() + "}", headers, HttpStatus.CREATED);
 }
コード例 #2
0
 /**
  * PUT /taskusers/ { "id": id, "title": "text of taskuser", idDone: true|false }
  *
  * <p>Updates an existing taskuser.
  *
  * @param json full json representation of the taskuser to update
  * @return
  */
 @RequestMapping(method = RequestMethod.PUT, headers = "Accept=application/json")
 public ResponseEntity<String> updateFromJson(@RequestBody String json) {
   HttpHeaders headers = new HttpHeaders();
   headers.add("Content-Type", "application/text");
   if (taskusers.save(TaskUser.fromJsonToTaskUser(json)) == null) {
     return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
   }
   return new ResponseEntity<String>(headers, HttpStatus.OK);
 }