Class ClothingItemService

java.lang.Object
com.needleandstitch.pavuk.service.ClothingItemService

@Service public class ClothingItemService extends Object
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 Details

    • ClothingItemService

      public ClothingItemService()
  • Method Details

    • findById

      @Transactional(readOnly=true) public ClothingItem findById(Long id)
      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

      @Transactional(readOnly=true) public List<ClothingItem> 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 item
      description - A description of the clothing item
      price - The price of the clothing item
      images - A set of images associated with the clothing item
      category - 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 update
      name - The new name for the clothing item
      description - The new description for the clothing item
      price - The new price for the clothing item
      images - The new set of images for the clothing item
      category - The new category for the clothing item
      Returns:
      The updated clothing item
    • deleteClothingItem

      @Transactional public void deleteClothingItem(Long id)
      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