Пример #1
0
 /** SEARCH /_search/prices/:query -> search for the price corresponding to the query. */
 @RequestMapping(
     value = "/_search/prices/{query}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public List<Price> search(@PathVariable String query) {
   return StreamSupport.stream(
           priceSearchRepository.search(queryString(query)).spliterator(), false)
       .collect(Collectors.toList());
 }
Пример #2
0
 /** DELETE /prices/:id -> delete the "id" price. */
 @RequestMapping(
     value = "/prices/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public void delete(@PathVariable Long id) {
   log.debug("REST request to delete Price : {}", id);
   priceRepository.delete(id);
   priceSearchRepository.delete(id);
 }
Пример #3
0
 /** PUT /prices -> Updates an existing price. */
 @RequestMapping(
     value = "/prices",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> update(@Valid @RequestBody Price price) throws URISyntaxException {
   log.debug("REST request to update Price : {}", price);
   if (price.getId() == null) {
     return create(price);
   }
   priceRepository.save(price);
   priceSearchRepository.save(price);
   return ResponseEntity.ok().build();
 }
Пример #4
0
 /** POST /prices -> Create a new price. */
 @RequestMapping(
     value = "/prices",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@Valid @RequestBody Price price) throws URISyntaxException {
   log.debug("REST request to save Price : {}", price);
   if (price.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new price cannot already have an ID")
         .build();
   }
   priceRepository.save(price);
   priceSearchRepository.save(price);
   return ResponseEntity.created(new URI("/api/prices/" + price.getId())).build();
 }