Dieser Commit ist enthalten in:
Ursprung
bf480f6e6f
Commit
eef38de3c0
@ -21,46 +21,65 @@ package de.steamwar.sql;
|
|||||||
|
|
||||||
import de.steamwar.sql.internal.Field;
|
import de.steamwar.sql.internal.Field;
|
||||||
import de.steamwar.sql.internal.SelectStatement;
|
import de.steamwar.sql.internal.SelectStatement;
|
||||||
|
import de.steamwar.sql.internal.Statement;
|
||||||
import de.steamwar.sql.internal.Table;
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Event {
|
public class Event {
|
||||||
|
|
||||||
private static final Table<Event> table = new Table<>(Event.class);
|
private static final Table<Event> table = new Table<>(Event.class);
|
||||||
private static final SelectStatement<Event> byId = table.select(Table.PRIMARY);
|
private static final SelectStatement<Event> byId = table.select(Table.PRIMARY);
|
||||||
|
private static final SelectStatement<Event> allShort = new SelectStatement<>(table, "SELECT * FROM Event");
|
||||||
|
private static final Statement create = table.insertFields(true, "eventName", "deadline", "start", "end", "maximumTeamMembers", "publicSchemsOnly", "spectateSystem");
|
||||||
|
private static final Statement update = table.update(Table.PRIMARY, "eventName", "deadline", "start", "end", "schemType", "maximumTeamMembers", "publicSchemsOnly", "spectateSystem");
|
||||||
|
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||||
|
|
||||||
|
|
||||||
public static Event get(int eventID){
|
public static Event get(int eventID){
|
||||||
return byId.select(eventID);
|
return byId.select(eventID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Event> getAllShort(){
|
||||||
|
return allShort.listSelect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Event create(String eventName, Timestamp start, Timestamp end){
|
||||||
|
return get(create.insertGetKey(eventName, start, start, end, 5, false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void delete(int eventID){
|
||||||
|
delete.update(eventID);
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||||
private final int eventID;
|
private final int eventID;
|
||||||
@Getter
|
@Getter
|
||||||
@Field(keys = {"eventName"})
|
@Field(keys = {"eventName"})
|
||||||
private final String eventName;
|
private String eventName;
|
||||||
@Getter
|
@Getter
|
||||||
@Field
|
@Field
|
||||||
private final Timestamp deadline;
|
private Timestamp deadline;
|
||||||
@Getter
|
@Getter
|
||||||
@Field
|
@Field
|
||||||
private final Timestamp start;
|
private Timestamp start;
|
||||||
@Getter
|
@Getter
|
||||||
@Field
|
@Field
|
||||||
private final Timestamp end;
|
private Timestamp end;
|
||||||
@Getter
|
@Getter
|
||||||
@Field
|
@Field
|
||||||
private final int maximumTeamMembers;
|
private int maximumTeamMembers;
|
||||||
@Field(nullable = true)
|
@Field(nullable = true)
|
||||||
private final SchematicType schemType;
|
private SchematicType schemType;
|
||||||
@Field
|
@Field
|
||||||
private final boolean publicSchemsOnly;
|
private boolean publicSchemsOnly;
|
||||||
@Field
|
@Field
|
||||||
private final boolean spectateSystem;
|
private boolean spectateSystem;
|
||||||
|
|
||||||
public boolean publicSchemsOnly() {
|
public boolean publicSchemsOnly() {
|
||||||
return publicSchemsOnly;
|
return publicSchemsOnly;
|
||||||
@ -72,4 +91,40 @@ public class Event {
|
|||||||
public SchematicType getSchematicType() {
|
public SchematicType getSchematicType() {
|
||||||
return schemType;
|
return schemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEventName(String eventName) {
|
||||||
|
this.eventName = eventName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadline(Timestamp deadline) {
|
||||||
|
this.deadline = deadline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStart(Timestamp start) {
|
||||||
|
this.start = start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnd(Timestamp end) {
|
||||||
|
this.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaximumTeamMembers(int maximumTeamMembers) {
|
||||||
|
this.maximumTeamMembers = maximumTeamMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicSchemsOnly(boolean publicSchemsOnly) {
|
||||||
|
this.publicSchemsOnly = publicSchemsOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpectateSystem(boolean spectateSystem) {
|
||||||
|
this.spectateSystem = spectateSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSchemType(SchematicType schemType) {
|
||||||
|
this.schemType = schemType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(){
|
||||||
|
update.update(eventName, deadline, start, end, schemType, maximumTeamMembers, publicSchemsOnly, spectateSystem, eventID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,10 @@ import de.steamwar.sql.internal.Statement;
|
|||||||
import de.steamwar.sql.internal.Table;
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class EventFight {
|
public class EventFight {
|
||||||
@ -33,26 +37,52 @@ public class EventFight {
|
|||||||
private static final SelectStatement<EventFight> byId = table.select(Table.PRIMARY);
|
private static final SelectStatement<EventFight> byId = table.select(Table.PRIMARY);
|
||||||
private static final Statement setResult = table.update(Table.PRIMARY, "Ergebnis");
|
private static final Statement setResult = table.update(Table.PRIMARY, "Ergebnis");
|
||||||
private static final Statement setFight = table.update(Table.PRIMARY, "Fight");
|
private static final Statement setFight = table.update(Table.PRIMARY, "Fight");
|
||||||
|
private static final SelectStatement<EventFight> byEvent = table.selectFields("eventID");
|
||||||
|
private static final Statement update = table.update(Table.PRIMARY, "startTime", "spielModus", "map", "teamBlue", "teamRed", "kampfleiter");
|
||||||
|
private static final Statement create = table.insertFields(true, "eventID", "startTime", "spielModus", "map", "teamBlue", "teamRed", "kampfleiter");
|
||||||
|
|
||||||
public static EventFight get(int fightID) {
|
public static EventFight get(int fightID) {
|
||||||
return byId.select(fightID);
|
return byId.select(fightID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EventFight create(int eventID, Timestamp startTime, String spielModus, String map, int teamBlue, int teamRed) {
|
||||||
|
return EventFight.get(create.insertGetKey(eventID, startTime, spielModus, map, teamBlue, teamRed, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<EventFight> getFromEvent(int eventID) {
|
||||||
|
return byEvent.listSelect(eventID);
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Field
|
@Field
|
||||||
private final int eventID;
|
private int eventID;
|
||||||
@Getter
|
@Getter
|
||||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||||
private final int fightID;
|
private int fightID;
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
@Field
|
@Field
|
||||||
private final int teamBlue;
|
private Timestamp startTime;
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
@Field
|
@Field
|
||||||
private final int teamRed;
|
private String spielModus;
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
@Field
|
@Field
|
||||||
private final int kampfleiter;
|
private String map;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Field
|
||||||
|
private int teamBlue;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Field
|
||||||
|
private int teamRed;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Field
|
||||||
|
private int kampfleiter;
|
||||||
@Getter
|
@Getter
|
||||||
@Field(def = "0")
|
@Field(def = "0")
|
||||||
private int ergebnis;
|
private int ergebnis;
|
||||||
@ -69,4 +99,8 @@ public class EventFight {
|
|||||||
this.fight = fight;
|
this.fight = fight;
|
||||||
setFight.update(fight, fightID);
|
setFight.update(fight, fightID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
update.update(startTime, spielModus, map, teamBlue, teamRed, kampfleiter, fightID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ public class SteamwarUser {
|
|||||||
private static final SelectStatement<SteamwarUser> byDiscord = table.selectFields("DiscordId");
|
private static final SelectStatement<SteamwarUser> byDiscord = table.selectFields("DiscordId");
|
||||||
private static final SelectStatement<SteamwarUser> byTeam = table.selectFields("Team");
|
private static final SelectStatement<SteamwarUser> byTeam = table.selectFields("Team");
|
||||||
private static final SelectStatement<SteamwarUser> getServerTeam = new SelectStatement<>(table, "SELECT * FROM UserData WHERE UserGroup != 'Member' AND UserGroup != 'YouTuber'");
|
private static final SelectStatement<SteamwarUser> getServerTeam = new SelectStatement<>(table, "SELECT * FROM UserData WHERE UserGroup != 'Member' AND UserGroup != 'YouTuber'");
|
||||||
|
|
||||||
|
private static final SelectStatement<SteamwarUser> getAll = new SelectStatement<>(table, "SELECT * FROM UserData");
|
||||||
private static final Statement updateName = table.update(Table.PRIMARY, "UserName");
|
private static final Statement updateName = table.update(Table.PRIMARY, "UserName");
|
||||||
private static final Statement updateLocale = table.update(Table.PRIMARY, "Locale", "ManualLocale");
|
private static final Statement updateLocale = table.update(Table.PRIMARY, "Locale", "ManualLocale");
|
||||||
private static final Statement updateTeam = table.update(Table.PRIMARY, "Team");
|
private static final Statement updateTeam = table.update(Table.PRIMARY, "Team");
|
||||||
@ -157,6 +159,10 @@ public class SteamwarUser {
|
|||||||
return byDiscord.select(discordId);
|
return byDiscord.select(discordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<SteamwarUser> getAll() {
|
||||||
|
return getAll.listSelect();
|
||||||
|
}
|
||||||
|
|
||||||
public static void createOrUpdateUsername(UUID uuid, String userName) {
|
public static void createOrUpdateUsername(UUID uuid, String userName) {
|
||||||
insert.update(uuid, userName);
|
insert.update(uuid, userName);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ public class Team {
|
|||||||
|
|
||||||
private static final Table<Team> table = new Table<>(Team.class);
|
private static final Table<Team> table = new Table<>(Team.class);
|
||||||
private static final SelectStatement<Team> select = table.select(Table.PRIMARY);
|
private static final SelectStatement<Team> select = table.select(Table.PRIMARY);
|
||||||
|
private static final SelectStatement<Team> all = new SelectStatement(table, "SELECT * FROM Team");
|
||||||
|
|
||||||
@Field(keys = {Table.PRIMARY})
|
@Field(keys = {Table.PRIMARY})
|
||||||
@Getter
|
@Getter
|
||||||
@ -55,6 +56,10 @@ public class Team {
|
|||||||
return select.select(id);
|
return select.select(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Team> getAll() {
|
||||||
|
return all.listSelect();
|
||||||
|
}
|
||||||
|
|
||||||
public List<Integer> getMembers(){
|
public List<Integer> getMembers(){
|
||||||
return SteamwarUser.getTeam(teamId).stream().map(SteamwarUser::getId).collect(Collectors.toList());
|
return SteamwarUser.getTeam(teamId).stream().map(SteamwarUser::getId).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren