uuuhhhhhh

This commit is contained in:
2024-01-24 11:44:01 +01:00
parent 509dc31d62
commit 7acd24e285
4 changed files with 115 additions and 16 deletions

View File

@@ -371,4 +371,59 @@ public class RestApiClient implements IRestAPI{
}
}
public int getGerichtIdOnTag(String name, String datum){
URI apiUri = URI.create(String.format("%s/Tagesplan/getGerichtIdOnTag?name=%s&datum=%s", urlBase, name, datum));
System.out.println(apiUri);
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(apiUri)
.header("Content-Type", "application/json")
.GET()
.build();
try {
// Send the request and get the response
HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Print the response status code and body
System.out.println("Status Code: " + httpResponse.statusCode());
System.out.println("Response Body: " + httpResponse.body());
JsonElement jsonElement = JsonParser.parseString(httpResponse.body());
JsonArray json = jsonElement.getAsJsonArray();
JsonObject o = json.get(0).getAsJsonObject();
return o.get("id").getAsInt();
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
public void deleteGericht(int id){
URI apiUri = URI.create(String.format("%s/Tagesplan/%d", urlBase, id));
System.out.println(apiUri);
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(apiUri)
.header("Content-Type", "application/json")
.DELETE()
.build();
try {
// Send the request and get the response
HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Print the response status code and body
System.out.println("Status Code: " + httpResponse.statusCode());
System.out.println("Delete Gericht: Response Body: " + httpResponse.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}