delTradingDeal + unlock card
This commit is contained in:
parent
3e8003ab50
commit
8e44e37804
@ -46,10 +46,18 @@ public class DBConnection {
|
||||
* @return true bei erfolg, sonst false
|
||||
*/
|
||||
public boolean updateCardLock(String name, boolean lock){
|
||||
System.out.println("Update user_cards set gesperrt = " + lock + " where name = \'" + name + "\';");
|
||||
return PostgresHelper.executeUpdate("Update user_cards set gesperrt = " + lock + " where name = \'" + name + "\';");
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht einen Trading Deal aus der Datenbank
|
||||
* @param id Id des deals der gelöscht werden soll
|
||||
* @return True bei erfolg, sonst false
|
||||
*/
|
||||
public boolean deleteTradingDeal(String id){
|
||||
return PostgresHelper.executeUpdate("delete from trading where id = \'" + id + "\';");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt der DB einen Trading deal hinzu
|
||||
* @param username User der den Trade hinzufügt
|
||||
|
@ -405,7 +405,28 @@ public class Response {
|
||||
* @throws JsonProcessingException Fehler beim de-/serialisieren
|
||||
*/
|
||||
private void deleteMethodes(){
|
||||
if (this.url.startsWith("/messages")) {
|
||||
if (this.url.startsWith("/tradings")) {
|
||||
String tradeid = this.url.substring(this.url.lastIndexOf('/') + 1);
|
||||
System.out.println("Format in /tradings/{tradingid}: " + tradeid);
|
||||
ArrayList<TradingDeal> allTradingDeals = new DBConnection().getAllTradingDeals();
|
||||
TradingDeal tr = null;
|
||||
if (allTradingDeals != null && !allTradingDeals.isEmpty()) {
|
||||
for (TradingDeal i : allTradingDeals) {
|
||||
if (i.getId().equals(tradeid)) {
|
||||
tr = i;
|
||||
}
|
||||
}
|
||||
if (tr != null) {
|
||||
if (new DBConnection().deleteTradingDeal(tradeid)) {
|
||||
if (new DBConnection().updateCardLock(tr.getCardToTrade().getName(), false))
|
||||
sendResponse("", "204");
|
||||
} else {
|
||||
sendError("500");
|
||||
}
|
||||
}else{
|
||||
sendError("500");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user