Converted api classes to be only statically accessible | Renamed SpoonacularController to RecipeSearchController
This commit is contained in:
@@ -5,7 +5,6 @@ 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.RestController;
|
||||
import spoonaccular.RecipeInformation;
|
||||
import spoonaccular.RecipeSearch;
|
||||
import spoonaccular.models.recipe_by_ingredient.ExtendedRecipeByIngredient;
|
||||
import spoonaccular.models.recipe_information.Recipe;
|
||||
@@ -17,29 +16,26 @@ import java.util.List;
|
||||
|
||||
@RestController()
|
||||
@BasePathAwareController()
|
||||
public class SpoonacularController {
|
||||
private int nextRecepies=10;
|
||||
private int nextRecepiesForOneRandom=20;
|
||||
public class RecipeSearchController {
|
||||
private final int nextRecipes=10;
|
||||
private final int nextRecipesForOneRandom = 20;
|
||||
|
||||
@Autowired
|
||||
private ItemRepository itemRepository;
|
||||
@Autowired
|
||||
private RecipeInformation recipeInformation;
|
||||
@Autowired
|
||||
private RecipeSearch recipeSearch;
|
||||
|
||||
@GetMapping("/recipe/forFridge")
|
||||
public List<ExtendedRecipeByIngredient> getForFridge() throws IOException {
|
||||
return recipeSearch.getForIngridients(itemRepository.findAll(), nextRecepies);
|
||||
return RecipeSearch.getForIngridients(itemRepository.findAll(), nextRecipes);
|
||||
}
|
||||
|
||||
@GetMapping("/recipe/random")
|
||||
public List<Recipe> getRandom() throws IOException, InterruptedException, JSONException {
|
||||
return recipeSearch.getRandom(new LinkedList<>(), nextRecepies);
|
||||
public List<Recipe> getRandom() throws IOException, JSONException {
|
||||
return RecipeSearch.getRandom(new LinkedList<>(), nextRecipes);
|
||||
//when user has food preferences apply instead of linked list.
|
||||
}
|
||||
|
||||
@GetMapping("/recipe/oneFridge")
|
||||
public ExtendedRecipeByIngredient getOneFridge() throws IOException {
|
||||
return recipeSearch.getOneForIngridients(itemRepository.findAll(), nextRecepiesForOneRandom);
|
||||
return RecipeSearch.getOneForIngridients(itemRepository.findAll(), nextRecipesForOneRandom);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user