Merge branch 'master' of https://git.bib.de/Subway-Surfers/VPR_App into Max_EssensverwaltungMitarbeiter
This commit is contained in:
commit
0326d80a21
@ -8,9 +8,11 @@ public class Account {
|
||||
// region Felder
|
||||
private String passwort;
|
||||
|
||||
private int id;
|
||||
private transient int id;
|
||||
|
||||
private String benutzername;
|
||||
private String name;
|
||||
|
||||
private int rid;
|
||||
// endregion
|
||||
|
||||
// region Getter & Setter
|
||||
@ -32,18 +34,23 @@ public class Account {
|
||||
|
||||
|
||||
public String getBenutzername() {
|
||||
return benutzername;
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setBenutzername(String benutzername) {
|
||||
this.benutzername = benutzername;
|
||||
this.name = benutzername;
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Konstruktoren
|
||||
public Account(String passwort, String benutzername) {
|
||||
public Account(String passwort, String name) {
|
||||
this.passwort = passwort;
|
||||
this.benutzername = benutzername;
|
||||
this.name = name;
|
||||
|
||||
if(this instanceof MitarbeiterAccount)
|
||||
rid = 0;
|
||||
else if (this instanceof ElternAccount)
|
||||
rid = 1;
|
||||
}
|
||||
// endregion
|
||||
|
||||
|
@ -7,15 +7,14 @@
|
||||
|
||||
package Logik;
|
||||
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Benutzer extends Account {
|
||||
public class ElternAccount extends Account {
|
||||
|
||||
// region Felder
|
||||
private String email;
|
||||
|
||||
private ArrayList<Kind> kinder;
|
||||
private transient ArrayList<Kind> kinder;
|
||||
// endregion
|
||||
|
||||
// region Getter & Setter
|
||||
@ -37,7 +36,7 @@ public class Benutzer extends Account {
|
||||
// endregion
|
||||
|
||||
// region Konstruktoren
|
||||
public Benutzer(String passwort, String benutzername, String email) {
|
||||
public ElternAccount(String passwort, String benutzername, String email) {
|
||||
super(passwort, benutzername);
|
||||
this.email = email;
|
||||
kinder = new ArrayList<>();
|
@ -11,7 +11,6 @@ public class Kind {
|
||||
private String vorname;
|
||||
private int bid;
|
||||
|
||||
// TODO Zutat implementieren!
|
||||
private ArrayList<Zutat> filter;
|
||||
// endregion
|
||||
|
||||
@ -48,8 +47,6 @@ public class Kind {
|
||||
this.bid = bid;
|
||||
}
|
||||
|
||||
// TODO Zutat implementieren!
|
||||
|
||||
public ArrayList<Zutat> getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class MitarbeiterAccount extends Account {
|
||||
* @param kinder Eine Liste mit allen zugehörigen Kindern des Accounts
|
||||
*/
|
||||
public void accountErstellen(String passwort, String benutzername, String email, ArrayList<Kind> kinder) {
|
||||
Benutzer newAccount = new Benutzer(passwort, benutzername, email);
|
||||
ElternAccount newAccount = new ElternAccount(passwort, benutzername, email);
|
||||
newAccount.setKinder(kinder);
|
||||
// Id muss aus der Datenbank geholt werden und dann gesetzt werden
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.WatchEvent;
|
||||
|
||||
import Logik.ElternAccount;
|
||||
import Logik.Kind;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@ -28,20 +28,18 @@ public class RestApiClient implements IRestAPI{
|
||||
gson = new Gson();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
Kind kind = new Kind("Klein", "Kevin", 2);
|
||||
RestApiClient client1 = new RestApiClient();
|
||||
|
||||
String json = new Gson().toJson(kind);
|
||||
|
||||
new RestApiClient().post("Kind", json);
|
||||
client1.post("Gericht", "{\"name\" : \"Svens Beine\", \"69.69\", \"beschreibung\" : \"Muss net schmegge, muss wirge\"}");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerName
|
||||
* Methode für einen Get-Aufruf. Ruft alle Elemente einer Tabelle auf.
|
||||
*
|
||||
* @param controllerName Name des aufzurufenden Controllers
|
||||
*/
|
||||
@Override
|
||||
public void get(String controllerName) {
|
||||
@ -67,8 +65,10 @@ public class RestApiClient implements IRestAPI{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerName
|
||||
* @param id
|
||||
* Methode für einen Get-Aufruf. Ruft ein spezifisches Element auf.
|
||||
*
|
||||
* @param controllerName Name des aufzurufenden Controllers
|
||||
* @param id Id der Aufzurufenden Zeile
|
||||
*/
|
||||
@Override
|
||||
public void get(String controllerName, int id) {
|
||||
@ -83,13 +83,9 @@ public class RestApiClient implements IRestAPI{
|
||||
// Send the request and get the response
|
||||
HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
Kind[] test = gson.fromJson(httpResponse.body(), Kind[].class);
|
||||
|
||||
// Print the response status code and body
|
||||
System.out.println("Status Code: " + httpResponse.statusCode());
|
||||
for(Kind i : test){
|
||||
System.out.println(i.getVorname());
|
||||
}
|
||||
System.out.println("Status Code: " + httpResponse.statusCode() + httpResponse.body());
|
||||
|
||||
//System.out.println("Response Body: " + test);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -97,9 +93,11 @@ public class RestApiClient implements IRestAPI{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerName
|
||||
* @param id
|
||||
* @param bezahlt
|
||||
* Methode für einen Get-Aufruf. Ruft ein spezielles Element auf.
|
||||
*
|
||||
* @param controllerName Name des aufzurufenden Controllers
|
||||
* @param id Id der Aufzurufenden Zeile
|
||||
* @param bezahlt TODO Warum ist das hier?
|
||||
*/
|
||||
@Override
|
||||
public void get(String controllerName, int id, boolean bezahlt) {
|
||||
@ -123,8 +121,11 @@ public class RestApiClient implements IRestAPI{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerName
|
||||
* @param id
|
||||
* Methode für einen Put-Aufruf. Aktualisiert einen Eintrag.
|
||||
*
|
||||
* @param controllerName Name des aufzurufenden Controllers.
|
||||
* @param id Id des zu änderenden Eintrags.
|
||||
* @param jsonData JsonString mit den neuen Daten.
|
||||
*/
|
||||
@Override
|
||||
public void put(String controllerName, int id, String jsonData) {
|
||||
@ -150,7 +151,10 @@ public class RestApiClient implements IRestAPI{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerName
|
||||
* Methode für einen Post-Aufruf. Fügt einen Eintrag in eine Datenbank hinzu.
|
||||
*
|
||||
* @param controllerName Name des aufzurufenden Controllers.
|
||||
* @param jsonData JsonString mit den Daten des Eintrags.
|
||||
*/
|
||||
@Override
|
||||
public void post(String controllerName, String jsonData) {
|
||||
@ -177,12 +181,33 @@ public class RestApiClient implements IRestAPI{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerName
|
||||
* @param id
|
||||
* Methode für einen Delete-Aufruf. Löscht einen Eintrag mit einer Id.
|
||||
*
|
||||
* @param controllerName Name des aufzurufenden Controllers
|
||||
* @param id Id des zu löschenden Eintrags.
|
||||
*/
|
||||
@Override
|
||||
public void delete(String controllerName, int id) {
|
||||
URI apiUri = URI.create(String.format("%s/%s/%d", urlBase,controllerName, 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("Response Body: " + httpResponse.body());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user