basic api functuinality added, still needs debugging

This commit is contained in:
Bruno
2022-06-17 16:23:04 +02:00
parent 1f8922788c
commit 724e765cd6
3 changed files with 26 additions and 10 deletions

View File

@@ -10,10 +10,11 @@ import whattocook.repositories.ItemRepository;
import whattocook.implementation.ApiServiceImpl;
import java.io.IOException;
import java.util.LinkedList;
@Controller
public class SpoonacularController {
private final int nextPages = 10;
private int nextRecepies;
@Autowired
private ItemRepository itemRepository;
@Autowired
@@ -21,6 +22,16 @@ public class SpoonacularController {
@GetMapping("api/forFridge")
public HttpEntity<String> getForFridge() throws IOException, InterruptedException {
return new HttpEntity<>(service.getForIngridients(itemRepository.findAll(), 10));
return new HttpEntity<>(service.getForIngridients(itemRepository.findAll(), nextRecepies));
}
@GetMapping("api/random")
public HttpEntity<String> getRandom() throws IOException, InterruptedException {
return new HttpEntity<>(service.getRandom(new LinkedList<>(), nextRecepies));
//when user has food preferences apply instead of linked list.
}
public void setNextRecepies(int nextRecepies) {
this.nextRecepies = nextRecepies;
}
}