From ef3aecfe38f3818637c428ed7c97edc3dea9027f Mon Sep 17 00:00:00 2001 From: Ivan Bogosavljevic Date: Wed, 17 Apr 2024 11:09:27 +0200 Subject: [PATCH] =?UTF-8?q?getRecipes=20fungerar=20enligt=20anvisningar=20?= =?UTF-8?q?finns=20ej=20testfall=20f=C3=B6r=20att=20testa=20detta=20dock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/krusty/Database.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/krusty/Database.java b/src/main/java/krusty/Database.java index b46f9ee..a9a7cac 100644 --- a/src/main/java/krusty/Database.java +++ b/src/main/java/krusty/Database.java @@ -1,15 +1,14 @@ 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.Response; -import java.util.Arrays; -import java.util.Map; -import java.util.TreeMap; -import java.sql.*; - -import static krusty.Jsonizer.toJson; - public class 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) { - 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) {