Class ClothingItemService
java.lang.Object
com.needleandstitch.pavuk.service.ClothingItemService
Service layer for managing clothing items.
This class provides business logic for operations related to clothing items, such as retrieving, creating, updating, and deleting clothing items.
Usage:
- Retrieve clothing items by ID
- Create new clothing items
- Update existing clothing items
- Delete clothing items
- Since:
- 15.12.2024
- Version:
- 1.0.0
- Author:
- Needle & Stitch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateClothingItem
(String name, String description, BigDecimal price, Set<Image> images, Category category) Creates a new clothing item.void
Deletes a clothing item by its ID.findAll()
Retrieves a list of all clothing items.Retrieves a clothing item by its ID.updateClothingItem
(Long id, String name, String description, BigDecimal price, Set<Image> images, Category category) Updates an existing clothing item.
-
Constructor Details
-
ClothingItemService
public ClothingItemService()
-
-
Method Details
-
findById
Retrieves a clothing item by its ID.- Parameters:
id
- The ID of the clothing item to retrieve- Returns:
- The clothing item with the specified ID
- Throws:
jakarta.persistence.EntityNotFoundException
- if the clothing item is not found
-
findAll
Retrieves a list of all clothing items.- Returns:
- a list of all clothing items
-
createClothingItem
@Transactional public ClothingItem createClothingItem(String name, String description, BigDecimal price, Set<Image> images, Category category) Creates a new clothing item.- Parameters:
name
- The name of the clothing itemdescription
- A description of the clothing itemprice
- The price of the clothing itemimages
- A set of images associated with the clothing itemcategory
- The category to which the clothing item belongs- Returns:
- The created clothing item
-
updateClothingItem
@Transactional public ClothingItem updateClothingItem(Long id, String name, String description, BigDecimal price, Set<Image> images, Category category) Updates an existing clothing item.- Parameters:
id
- The ID of the clothing item to updatename
- The new name for the clothing itemdescription
- The new description for the clothing itemprice
- The new price for the clothing itemimages
- The new set of images for the clothing itemcategory
- The new category for the clothing item- Returns:
- The updated clothing item
-
deleteClothingItem
Deletes a clothing item by its ID.- Parameters:
id
- The ID of the clothing item to delete- Throws:
jakarta.persistence.EntityNotFoundException
- if the clothing item with the specified ID does not exist
-