コード例 #1
0
 @RequestMapping(value = "/persoana/{id}", method = RequestMethod.GET)
 public ResponseEntity show(@PathVariable("id") int id) {
   for (Persoana p : this.persoane) {
     if (p.getId() == id) {
       return new ResponseEntity<Persoana>(p, new HttpHeaders(), HttpStatus.OK);
     }
   }
   return new ResponseEntity<String>(null, new HttpHeaders(), HttpStatus.NOT_FOUND);
 }
コード例 #2
0
 @CrossOrigin
 @RequestMapping(value = "/persoana/{id}/{nume}", method = RequestMethod.PUT)
 public List<Persoana> update(@PathVariable("id") int id, @PathVariable("nume") String nume) {
   for (Persoana p : this.persoane) {
     if (p.getId() == id) {
       p.setName(nume);
     }
   }
   return this.persoane;
 }
コード例 #3
0
 @CrossOrigin
 @RequestMapping(value = "/persoana/{id}", method = RequestMethod.DELETE)
 public ResponseEntity remove(@PathVariable("id") int id) {
   for (Persoana p : this.persoane) {
     if (p.getId() == id) {
       this.persoane.remove(p);
       return new ResponseEntity<String>(null, new HttpHeaders(), HttpStatus.NO_CONTENT);
     }
   }
   return new ResponseEntity<String>(null, new HttpHeaders(), HttpStatus.NOT_FOUND);
 }