Objective:
Build a complete API for furniture sales, including stock management and shopping cart functionality, using Spring and Spring Data JPA.
-
Create the
Furnitureentity with at least the following attributes:id(UUID)name(String)description(String)price(Double)stock(int)
-
Create the
CartItementity with at least the following attributes:id(UUID)furniture(reference toFurniture)quantity(int)
- Create
FurnitureRepositoryby extendingJpaRepository<Furniture, UUID>. - Create
CartItemRepositoryby extendingJpaRepository<CartItem, UUID>.
-
Create
FurnitureServicewith the following methods:getAllFurniture()saveFurniture()getFurnitureById()deleteFurniture()
-
Create
CartServicewith the following methods:getAllCartItems()(returns: cart item ID, furniture name, furniture description, furniture price, and quantity)addCartItem()removeCartItem()clearCart()(empties the cart)
GET /api/furniture → Get all furniture items
GET /api/furniture/{id} → Get a furniture item by ID
POST /api/furniture → Create/add a new furniture item
DELETE /api/furniture/{id} → Delete a furniture item by ID
GET /api/cart → Get all items in the cart
POST /api/cart/add → Add a furniture item to the cart
DELETE /api/cart/remove/{id} → Remove a specific item from the cart by ID
DELETE /api/cart/clear → Clear the entire cart (delete all CartItems)