/** DELETE /transporters/:id -> delete the "id" transporter. */ @RequestMapping( value = "/transporters/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Void> deleteTransporter(@PathVariable Long id) { log.debug("REST request to delete Transporter : {}", id); transporterRepository.delete(id); return ResponseEntity.ok() .headers(HeaderUtil.createEntityDeletionAlert("transporter", id.toString())) .build(); }
/** PUT /transporters -> Updates an existing transporter. */ @RequestMapping( value = "/transporters", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Transporter> updateTransporter(@RequestBody Transporter transporter) throws URISyntaxException { log.debug("REST request to update Transporter : {}", transporter); if (transporter.getId() == null) { return createTransporter(transporter); } Transporter result = transporterRepository.save(transporter); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("transporter", transporter.getId().toString())) .body(result); }
/** POST /transporters -> Create a new transporter. */ @RequestMapping( value = "/transporters", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Transporter> createTransporter(@RequestBody Transporter transporter) throws URISyntaxException { log.debug("REST request to save Transporter : {}", transporter); if (transporter.getId() != null) { return ResponseEntity.badRequest() .header("Failure", "A new transporter cannot already have an ID") .body(null); } Transporter result = transporterRepository.save(transporter); return ResponseEntity.created(new URI("/api/transporters/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert("transporter", result.getId().toString())) .body(result); }