Dieser Commit ist enthalten in:
Ursprung
480b3c91d5
Commit
3109d019df
63
SpigotCore_Main/src/de/steamwar/sql/TeamTeilnahme.java
Normale Datei
63
SpigotCore_Main/src/de/steamwar/sql/TeamTeilnahme.java
Normale Datei
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TeamTeilnahme {
|
||||
private TeamTeilnahme(){}
|
||||
|
||||
public static boolean nimmtTeil(int teamID, int eventID){
|
||||
try {
|
||||
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){
|
||||
try {
|
||||
ResultSet resultSet = SQL.select("SELECT * FROM TeamTeilnahme WHERE EventID = ?", eventID);
|
||||
Set<Team> teams = new HashSet<>();
|
||||
while (resultSet.next()) {
|
||||
teams.add(Team.get(resultSet.getInt("TeamID")));
|
||||
}
|
||||
return teams;
|
||||
} catch (SQLException e) {
|
||||
throw new SecurityException("Could not perform select", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<Event> getEvents(int teamID){
|
||||
try {
|
||||
ResultSet resultSet = SQL.select("SELECT * FROM TeamTeilnahme WHERE EventID = ?", teamID);
|
||||
Set<Event> events = new HashSet<>();
|
||||
while (resultSet.next()) {
|
||||
events.add(Event.get(resultSet.getInt("EventID")));
|
||||
}
|
||||
return events;
|
||||
} catch (SQLException e) {
|
||||
throw new SecurityException("Could not perform select", e);
|
||||
}
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren