@RequestMapping( value = "/doctors/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF_8) public DoctorDto getDoctor(@PathVariable("id") Long id) { LOGGER.debug("Retrieving doctor: {}", id); Doctor doctor = doctorService.findById(id); if (doctor == null) { LOGGER.debug("Could not found doctor: {}", id); EntityNotFoundException exception = new EntityNotFoundException(Doctor.ENTITY); exception.setSearchMessage("id = " + id); throw exception; } return new DoctorDto(doctor); }
@RequestMapping( value = "/doctors/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON_UTF_8) public DoctorResponse updateDoctor( @PathVariable("id") Long id, @Valid @RequestBody DoctorRequest doctorRequest) { LOGGER.debug("Updating doctor: {}", id); Doctor doctor = doctorService.findById(id); if (doctor == null) { LOGGER.debug("Could not found doctor: {}", id); EntityNotFoundException exception = new EntityNotFoundException(Doctor.ENTITY); exception.setSearchMessage("id = " + id); throw exception; } saveOrUpdate(doctor, doctorRequest); LOGGER.debug("Updated doctor: {}", id); return new DoctorResponse(id); }