basic api functuinality added, still needs debugging
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user