diff --git a/server/src/main/java/service/RecipeService.java b/server/src/main/java/service/RecipeService.java index 57cdf16..1c0ea4e 100644 --- a/server/src/main/java/service/RecipeService.java +++ b/server/src/main/java/service/RecipeService.java @@ -24,22 +24,22 @@ public class RecipeService { this.recipeIngredientRepository = recipeIngredientRepository; } - Optional findById(Long id) { + public Optional findById(Long id) { return recipeRepository.findById(id); } - List findAll() { + public List findAll() { return recipeRepository.findAll(); } - List findAll(int limit) { + public List findAll(int limit) { return recipeRepository.findAll(PageRequest.of(0, limit)).toList(); } /** * Creates a new recipe. Returns empty if the recipe with the same name already exists. * @param recipe Recipe to be saved in the db. - * @return The created recipe (the recipe arg with a new assigned id). + * @return The created recipe (the recipe arg with a new assigned id) or empty if it already exists in db. */ public Optional create(Recipe recipe) { if (recipeRepository.existsByName(recipe.getName())) {