コード例 #1
0
 /** POST /evolutionPrescriptions -> Create a new evolutionPrescription. */
 @RequestMapping(
     value = "/episodes/{episode_id}/evolutionPrescriptions",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<EvolutionPrescription> createByEpisode(
     @PathVariable(value = "episode_id") Long episodeId,
     @RequestBody EvolutionPrescription evolutionPrescription)
     throws URISyntaxException {
   log.debug("REST request to save EvolutionPrescription : {}", evolutionPrescription);
   if (evolutionPrescription.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new evolutionPrescription cannot already have an ID")
         .body(null);
   }
   Episode episode = new Episode();
   episode.setId(episodeId);
   evolutionPrescription.setEpisode(episode);
   EvolutionPrescription result = evolutionPrescriptionRepository.save(evolutionPrescription);
   return ResponseEntity.created(
           new URI("/api/episodes/" + episodeId + "/evolutionPrescriptions/" + result.getId()))
       .headers(
           HeaderUtil.createEntityCreationAlert(
               "evolutionPrescription", result.getId().toString()))
       .body(result);
 }
コード例 #2
0
 /** PUT /evolutionPrescriptions -> Updates an existing evolutionPrescription. */
 @RequestMapping(
     value = "/episodes/{episode_id}/evolutionPrescriptions",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<EvolutionPrescription> updateByEpisode(
     @PathVariable(value = "episode_id") Long episodeId,
     @RequestBody EvolutionPrescription evolutionPrescription)
     throws URISyntaxException {
   log.debug("REST request to update EvolutionPrescription : {}", evolutionPrescription);
   if (evolutionPrescription.getId() == null) {
     return create(evolutionPrescription);
   }
   Episode episode = new Episode();
   episode.setId(episodeId);
   evolutionPrescription.setEpisode(episode);
   EvolutionPrescription result = evolutionPrescriptionRepository.save(evolutionPrescription);
   return ResponseEntity.ok()
       .headers(
           HeaderUtil.createEntityUpdateAlert(
               "evolutionPrescription", evolutionPrescription.getId().toString()))
       .body(result);
 }