From 7ccabe8dcc9efe52a79849d130ac02f334f2a065 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 8 Mar 2024 09:52:53 +0100 Subject: [PATCH] Add referee table for multiple referees per event(fight) --- src/de/steamwar/sql/Referee.java | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/de/steamwar/sql/Referee.java diff --git a/src/de/steamwar/sql/Referee.java b/src/de/steamwar/sql/Referee.java new file mode 100644 index 0000000..2f606a9 --- /dev/null +++ b/src/de/steamwar/sql/Referee.java @@ -0,0 +1,44 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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 . + */ + +package de.steamwar.sql; + +import de.steamwar.sql.internal.Field; +import de.steamwar.sql.internal.SelectStatement; +import de.steamwar.sql.internal.Table; +import lombok.AllArgsConstructor; + +import java.util.Set; +import java.util.stream.Collectors; + +@AllArgsConstructor +public class Referee { + + private static final Table table = new Table<>(Referee.class); + private static final SelectStatement byEvent = table.select("eventID"); + + public static Set get(int eventID) { + return byEvent.listSelect(eventID).stream().map(referee -> referee.userID).collect(Collectors.toSet()); + } + + @Field(keys = {"eventReferee"}) + private final int eventID; + @Field(keys = {"eventReferee"}) + private final int userID; +}