Class CategoryService
java.lang.Object
com.equipmentrental.equipment_rental_system.service.CategoryService
-
Constructor Summary
ConstructorsConstructorDescriptionCategoryService(CategoryRepository categoryRepository, EquipmentRepository equipmentRepository) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteById(Long categoryId) Deletes a category if no equipment items are assigned to it (BR-06).findAll()Returns all categories in the system.Finds a category by its ID.Saves a new or updated category.
-
Constructor Details
-
CategoryService
public CategoryService(CategoryRepository categoryRepository, EquipmentRepository equipmentRepository)
-
-
Method Details
-
findAll
-
findById
Finds a category by its ID.- Parameters:
categoryId- the ID of the category to find- Returns:
- the category
- Throws:
ResourceNotFoundException- if no category exists with the given ID
-
save
-
deleteById
Deletes a category if no equipment items are assigned to it (BR-06).- Parameters:
categoryId- the ID of the category to delete- Throws:
ResourceNotFoundException- if no category exists with the given IDDeletionBlockedException- if equipment items are still assigned to this category
-