@RequestMapping(value = "/{id}", method = RequestMethod.PUT) public Developer updateOne(@RequestBody Developer newDeveloper, @PathVariable Long id) { Developer developer = developerRespository.findOne(id); if (developer == null) throw new DeveloperException(id); newDeveloper = developerRespository.save(newDeveloper); return newDeveloper; }
@RequestMapping(value = "/{id}", method = RequestMethod.GET) public Developer getById(@PathVariable Long id) { Developer developer = developerRespository.findOne(id); if (developer == null) throw new DeveloperException(id); // lanzar una exception cuando el developer es null. return developer; }
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public void deleteOne(@PathVariable Long id) { Developer developer = developerRespository.findOne(id); if (developer == null) throw new DeveloperException(id); developerRespository.delete(id); }