Dieser Commit ist enthalten in:
Ursprung
3109d019df
Commit
553f951cb5
@ -20,44 +20,35 @@
|
|||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TeamTeilnahme {
|
public class TeamTeilnahme {
|
||||||
private TeamTeilnahme(){}
|
private TeamTeilnahme(){}
|
||||||
|
|
||||||
|
private static final SQL.Statement byEventTeam = new SQL.Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?");
|
||||||
|
private static final SQL.Statement byEvent = new SQL.Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?");
|
||||||
|
private static final SQL.Statement byTeam = new SQL.Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?");
|
||||||
|
|
||||||
public static boolean nimmtTeil(int teamID, int eventID){
|
public static boolean nimmtTeil(int teamID, int eventID){
|
||||||
try {
|
return byEvent.select(ResultSet::next, teamID, eventID);
|
||||||
return SQL.select("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?", teamID, eventID).next();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new SecurityException("Could not perform select", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<Team> getTeams(int eventID){
|
public static Set<Team> getTeams(int eventID){
|
||||||
try {
|
return byEvent.select(rs -> {
|
||||||
ResultSet resultSet = SQL.select("SELECT * FROM TeamTeilnahme WHERE EventID = ?", eventID);
|
|
||||||
Set<Team> teams = new HashSet<>();
|
Set<Team> teams = new HashSet<>();
|
||||||
while (resultSet.next()) {
|
while(rs.next())
|
||||||
teams.add(Team.get(resultSet.getInt("TeamID")));
|
teams.add(Team.get(rs.getInt("TeamID")));
|
||||||
}
|
|
||||||
return teams;
|
return teams;
|
||||||
} catch (SQLException e) {
|
}, eventID);
|
||||||
throw new SecurityException("Could not perform select", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<Event> getEvents(int teamID){
|
public static Set<Event> getEvents(int teamID){
|
||||||
try {
|
return byTeam.select(rs -> {
|
||||||
ResultSet resultSet = SQL.select("SELECT * FROM TeamTeilnahme WHERE EventID = ?", teamID);
|
|
||||||
Set<Event> events = new HashSet<>();
|
Set<Event> events = new HashSet<>();
|
||||||
while (resultSet.next()) {
|
while(rs.next())
|
||||||
events.add(Event.get(resultSet.getInt("EventID")));
|
events.add(Event.get(rs.getInt("EventID")));
|
||||||
}
|
|
||||||
return events;
|
return events;
|
||||||
} catch (SQLException e) {
|
}, teamID);
|
||||||
throw new SecurityException("Could not perform select", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren