/** DELETE /purchasedRiskItems/:id -> delete the "id" purchasedRiskItem. */ @RequestMapping( value = "/purchasedRiskItems/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Void> deletePurchasedRiskItem(@PathVariable Long id) { log.debug("REST request to delete PurchasedRiskItem : {}", id); purchasedRiskItemRepository.delete(id); return ResponseEntity.ok() .headers(HeaderUtil.createEntityDeletionAlert("purchasedRiskItem", id.toString())) .build(); }
/** POST /purchasedRiskItems -> Create a new purchasedRiskItem. */ @RequestMapping( value = "/purchasedRiskItems", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<PurchasedRiskItem> createPurchasedRiskItem( @Valid @RequestBody PurchasedRiskItem purchasedRiskItem) throws URISyntaxException { log.debug("REST request to save PurchasedRiskItem : {}", purchasedRiskItem); if (purchasedRiskItem.getId() != null) { return ResponseEntity.badRequest() .headers( HeaderUtil.createFailureAlert( "purchasedRiskItem", "idexists", "A new purchasedRiskItem cannot already have an ID")) .body(null); } PurchasedRiskItem result = purchasedRiskItemRepository.save(purchasedRiskItem); return ResponseEntity.created(new URI("/api/purchasedRiskItems/" + result.getId())) .headers( HeaderUtil.createEntityCreationAlert("purchasedRiskItem", result.getId().toString())) .body(result); }
/** PUT /purchasedRiskItems -> Updates an existing purchasedRiskItem. */ @RequestMapping( value = "/purchasedRiskItems", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<PurchasedRiskItem> updatePurchasedRiskItem( @Valid @RequestBody PurchasedRiskItem purchasedRiskItem) throws URISyntaxException { log.debug("REST request to update PurchasedRiskItem : {}", purchasedRiskItem); if (purchasedRiskItem.getId() == null) { return createPurchasedRiskItem(purchasedRiskItem); } PurchasedRiskItem result = purchasedRiskItemRepository.save(purchasedRiskItem); return ResponseEntity.ok() .headers( HeaderUtil.createEntityUpdateAlert( "purchasedRiskItem", purchasedRiskItem.getId().toString())) .body(result); }