Class ProductService
java.lang.Object
ntnu.idatt2016.v233.SmartMat.service.product.ProductService
Service for Products
uses both the ProductRepository and the ProductUtil
- Version:
- 1.1
- Author:
- Birk
-
Constructor Summary
ConstructorsConstructorDescriptionProductService
(ProductRepository productRepository) Creates a new ProductService -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteProductById
(long id) Deletes a product by its IDGets all products in the databasegetProductById
(Long id) Gets a product by its IDgetProductByName
(String name) getProductVolume
(long id) Gets the volume of a productsaveProduct
(Product product) Saves a product to the databasevoid
updateProduct
(Product product) Updates a product
-
Constructor Details
-
ProductService
Creates a new ProductService- Parameters:
productRepository
- The repository to use
-
-
Method Details
-
getProductById
Gets a product by its ID- Parameters:
id
- The ID of the product to get- Returns:
- The product with the given ID, if it exists
-
getAllProducts
Gets all products in the database- Returns:
- All products in the database
-
saveProduct
Saves a product to the database- Parameters:
product
- The product to save- Returns:
- The saved product
-
deleteProductById
public void deleteProductById(long id) Deletes a product by its ID- Parameters:
id
- The ID of the product to delete
-
getProductByName
- Parameters:
name
- The name of the product to get- Returns:
- The product with the given name, if it exists
-
getProductVolume
Gets the volume of a product- Parameters:
id
- The id of the product to get the volume from- Returns:
- The volume of the product, if it exists
-
updateProduct
Updates a product- Parameters:
product
- The product to update
-