updated paths of SpoonacularController to match the rest

This commit is contained in:
2022-07-13 05:58:48 +02:00
parent c5014c4a11
commit 5c0de10446

View File

@@ -2,8 +2,8 @@ package whattocook.controller;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.BasePathAwareController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import spoonaccular.RecipeInformation;
import spoonaccular.RecipeSearch;
@@ -16,7 +16,7 @@ import java.util.LinkedList;
import java.util.List;
@RestController()
@RequestMapping(path = "recipe")
@BasePathAwareController()
public class SpoonacularController {
private int nextRecepies=10;
private int nextRecepiesForOneRandom=20;
@@ -27,18 +27,18 @@ public class SpoonacularController {
@Autowired
private RecipeSearch recipeSearch;
@GetMapping("/forFridge")
@GetMapping("/recipe/forFridge")
public List<ExtendedRecipeByIngredient> getForFridge() throws IOException {
return recipeSearch.getForIngridients(itemRepository.findAll(), nextRecepies);
}
@GetMapping("/random")
@GetMapping("/recipe/random")
public List<Recipe> getRandom() throws IOException, InterruptedException, JSONException {
return recipeSearch.getRandom(new LinkedList<>(), nextRecepies);
//when user has food preferences apply instead of linked list.
}
@GetMapping("/oneFridge")
@GetMapping("/recipe/oneFridge")
public ExtendedRecipeByIngredient getOneFridge() throws IOException {
return recipeSearch.getOneForIngridients(itemRepository.findAll(), nextRecepiesForOneRandom);
}