Class OrderService
- java.lang.Object
-
- edu.cnm.deepdive.albuquirky.service.OrderService
-
@Service public class OrderService extends Object
This class handles all of the business logic for getting, putting, posting, and deleting items from theOrderon behalf of theOrderServiceclass, using methods from theOrderRepositoryinterface.
-
-
Constructor Summary
Constructors Constructor Description OrderService(OrderRepository orderRepository, ProfileRepository profileRepository, ProductOnOrderRepository productOnOrderRepository)The constructor creates instances ofOrderRepositoryandProfileRepository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Order>get(long id)Retrieves a specificOrderby ID.List<Order>getByBuyer(Profile profile)Retrieves all orders placed by a specific buyer.List<Order>getBySeller(Profile profile)Retrieves all orders sold by a specific seller.List<ProductOnOrder>getProductsOnOrder(long id)Ordersave(Order order, Profile profile)Saves anOrderin the database.ProductOnOrdersaveProductOnOrder(ProductOnOrder productOnOrder, Order order)
-
-
-
Constructor Detail
-
OrderService
@Autowired public OrderService(OrderRepository orderRepository, ProfileRepository profileRepository, ProductOnOrderRepository productOnOrderRepository)
The constructor creates instances ofOrderRepositoryandProfileRepository.- Parameters:
orderRepository- TheOrderRepositoryto be created.profileRepository- TheProfileRepositoryto be created.productOnOrderRepository- TheProductOnOrderRepositoryto be created.
-
-
Method Detail
-
get
public Optional<Order> get(long id)
Retrieves a specificOrderby ID.- Parameters:
id- The ID of theOrderbeing requested.- Returns:
- An
Optionalcontaining the matchingOrder.
-
getByBuyer
public List<Order> getByBuyer(Profile profile)
Retrieves all orders placed by a specific buyer.
-
getBySeller
public List<Order> getBySeller(Profile profile)
Retrieves all orders sold by a specific seller.
-
getProductsOnOrder
public List<ProductOnOrder> getProductsOnOrder(long id)
-
saveProductOnOrder
public ProductOnOrder saveProductOnOrder(ProductOnOrder productOnOrder, Order order)
-
-