Class ShoppingItemDTO
java.lang.Object
com.goldenleaf.shop.dto.ShoppingItemDTO
Data Transfer Object representing a single item in the shopping cart.
Used exclusively in ShoppingCartDTO responses.
Contains read-only data about the product and its current state in the cart.
Important security rules:
- All price-related fields are calculated server-side — never trust client input
- Quantity is validated against stock during add/update operations
- This DTO is output-only — never used for input from client
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionRequired for JSON deserializationShoppingItemDTO(Long id, Long productId, String productName, int quantity, double pricePerUnit) -
Method Summary
Modifier and TypeMethodDescriptionbooleangetId()doubleintdoubleCalculates subtotal for this item.inthashCode()voidvoidsetPricePerUnit(double pricePerUnit) voidsetProductId(Long productId) voidsetProductName(String productName) voidsetQuantity(int quantity) toString()
-
Constructor Details
-
ShoppingItemDTO
public ShoppingItemDTO()Required for JSON deserialization -
ShoppingItemDTO
-
-
Method Details
-
getId
-
setId
-
getProductId
-
setProductId
-
getProductName
-
setProductName
-
getQuantity
public int getQuantity() -
setQuantity
public void setQuantity(int quantity) -
getPricePerUnit
public double getPricePerUnit() -
setPricePerUnit
public void setPricePerUnit(double pricePerUnit) -
getSubtotal
public double getSubtotal()Calculates subtotal for this item. Convenience method for frontend or logging.- Returns:
- quantity × pricePerUnit, rounded to 2 decimal places
-
toString
-
equals
-
hashCode
-