@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); }
@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; }
@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); }