Class CategoryService
java.lang.Object
org.codewithmagret.rest.category.CategoryService
Service class for handling business logic related to Category entities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCategory(Category category) Adds a new category to the repository.booleandeleteCategory(Long id) Deletes a category by its ID.Retrieves all categories from the repository.getCategoryById(Long id) Retrieves a category by its ID.updateCategory(Long id, Category categoryToUpdate) Updates an existing category in the repository.
-
Constructor Details
-
CategoryService
public CategoryService()Default constructor for CategoryService.
-
-
Method Details
-
getCategories
-
getCategoryById
-
addCategory
-
updateCategory
-
deleteCategory
Deletes a category by its ID.- Parameters:
id- the ID of the category to delete- Returns:
- true if the category was deleted, false if the category was not found
-