comment and access fixes for RecipeService

This commit is contained in:
Oskar Rasieński 2026-01-07 23:46:40 +01:00
commit d56b07f2aa

View file

@ -24,22 +24,22 @@ public class RecipeService {
this.recipeIngredientRepository = recipeIngredientRepository;
}
Optional<Recipe> findById(Long id) {
public Optional<Recipe> findById(Long id) {
return recipeRepository.findById(id);
}
List<Recipe> findAll() {
public List<Recipe> findAll() {
return recipeRepository.findAll();
}
List<Recipe> findAll(int limit) {
public List<Recipe> 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<Recipe> create(Recipe recipe) {
if (recipeRepository.existsByName(recipe.getName())) {