com.springframework.model.Product

Here are the examples of the java api com.springframework.model.Product taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

18 Source : ProductServiceImpl.java
with GNU General Public License v3.0
from spring-framework-guru

@Caching(evict = { @CacheEvict(value = "allproductcache", allEntries = true), @CacheEvict(value = "productcache", key = "#product.id") })
@Override
public Product deleteProductById(int id) {
    Product product = null;
    Optional optional = productRepository.findById(id);
    if (optional.isPresent()) {
        product = productRepository.findById(id).get();
        productRepository.deleteById(id);
    }
    System.out.println("Product deleted in database\n ");
    return product;
}

18 Source : ProductServiceImpl.java
with GNU General Public License v3.0
from spring-framework-guru

@Caching(evict = { @CacheEvict(value = "allproductcache", allEntries = true), @CacheEvict(value = "productcache", key = "#product.id") })
@Override
public Product addProduct(Product product) {
    return productRepository.save(product);
}

18 Source : ProductController.java
with GNU General Public License v3.0
from spring-framework-guru

@GetMapping("product/{id}")
public ResponseEnreplacedy<Product> getProductById(@PathVariable int id) {
    Product retrievedProduct = productService.getProduct(id);
    return new ResponseEnreplacedy<Product>(retrievedProduct, HttpStatus.OK);
}

18 Source : ProductController.java
with GNU General Public License v3.0
from spring-framework-guru

@PutMapping("product")
public ResponseEnreplacedy<Product> updateProduct(@RequestBody Product product) {
    // logger.info(".... Updating product Content of id: " + product.getId());
    Product updatedProduct = productService.updateProduct(product);
    return new ResponseEnreplacedy<>(updatedProduct, HttpStatus.OK);
}

18 Source : ProductController.java
with GNU General Public License v3.0
from spring-framework-guru

@PostMapping("product")
public ResponseEnreplacedy<Product> saveAProduct(@RequestBody Product product) {
    Product saveProduct = productService.addProduct(product);
    return new ResponseEnreplacedy<>(saveProduct, HttpStatus.OK);
}

17 Source : ProductServiceImpl.java
with GNU General Public License v3.0
from spring-framework-guru

@CachePut(key = "#product.id")
@Override
public Product updateProduct(Product product) {
    Product updateProduct = null;
    Optional optional = productRepository.findById(product.getId());
    if (optional.isPresent()) {
        Product getProduct = productRepository.findById(product.getId()).get();
        getProduct.setPName(product.getPName());
        getProduct.setPrice(product.getPrice());
        updateProduct = addProduct(getProduct);
    }
    System.out.println("Product updated\n");
    return updateProduct;
}

17 Source : ProductController.java
with GNU General Public License v3.0
from spring-framework-guru

@DeleteMapping("product/{id}")
public ResponseEnreplacedy<Product> deleteProduct(@PathVariable("id") int id) {
    ResponseEnreplacedy responseEnreplacedy;
    Product deletedProduct = productService.deleteProductById(id);
    responseEnreplacedy = new ResponseEnreplacedy<Product>(deletedProduct, HttpStatus.OK);
    return responseEnreplacedy;
}