Class ProductService
- java.lang.Object
-
- edu.cnm.deepdive.albuquirky.service.ProductService
-
@Service public class ProductService extends Object
This class handles all of the business logic for getting, putting, posting, and deleting items from theProducton behalf of theProductServiceclass, using methods from theProductRepositoryinterface.
-
-
Constructor Summary
Constructors Constructor Description ProductService(ProductRepository productRepository)Constructs the instance ofProductRepository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Product>get(long id)Returns a product by ID.Iterable<Product>getAll()Returns everyProductobject in the database.Iterable<Product>getByName(String nameFragment)Returns allProductobjects with a name matching a keyword.Iterable<Product>getByProfile(Profile profile)Iterable<Product>getByProfileAndName(Profile profile, String nameFragment)Returns allProductobjects with a name matching a keyword, sold by a particular seller.Productsave(Product product)Saves the product into the database.Productsave(Product product, Profile profile)
-
-
-
Constructor Detail
-
ProductService
@Autowired public ProductService(ProductRepository productRepository)
Constructs the instance ofProductRepository.- Parameters:
productRepository- The instance ofProductRepositoryto be created.
-
-
Method Detail
-
getByName
public Iterable<Product> getByName(String nameFragment)
Returns allProductobjects with a name matching a keyword.- Parameters:
nameFragment- The search term keyword.- Returns:
- An
Iterablecontaining allProductobjects that match the keyword.
-
getByProfileAndName
public Iterable<Product> getByProfileAndName(Profile profile, String nameFragment)
Returns allProductobjects with a name matching a keyword, sold by a particular seller.
-
-