getRecipes fungerar enligt anvisningar finns ej testfall för att testa detta dock

This commit is contained in:
Ivan Bogosavljevic 2024-04-17 11:09:27 +02:00
parent 7a5ade039d
commit ef3aecfe38

View file

@ -1,15 +1,14 @@
package krusty; package krusty;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import spark.Request; import spark.Request;
import spark.Response; import spark.Response;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
import java.sql.*;
import static krusty.Jsonizer.toJson;
public class Database { public class Database {
/** /**
* Modify it to fit your environment and then use this string when connecting to your database! * Modify it to fit your environment and then use this string when connecting to your database!
@ -67,7 +66,10 @@ public class Database {
} }
public String getRecipes(Request req, Response res) { public String getRecipes(Request req, Response res) {
return "{}"; String query = "Select c.name, i.name, r.amount, i.unit FROM Cookie c, Ingredient i, Recipe r WHERE r.cookie_id = c.cookie_id AND r.ingredient_id = i.ingredient_id;";
String title = "recipes";
return getJson(query, title);
} }
public String getPallets(Request req, Response res) { public String getPallets(Request req, Response res) {