From 975ebf4f3370d449d4c7df058519e0d4dd6345ed Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 14 Jan 2023 11:59:49 +0100 Subject: [PATCH] Add Mod Routes --- src/de/steamwar/sql/Mod.java | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/de/steamwar/sql/Mod.java diff --git a/src/de/steamwar/sql/Mod.java b/src/de/steamwar/sql/Mod.java new file mode 100644 index 0000000..8b32e6d --- /dev/null +++ b/src/de/steamwar/sql/Mod.java @@ -0,0 +1,62 @@ +package de.steamwar.sql; + +import de.steamwar.sql.internal.*; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +@AllArgsConstructor +@Getter +public class Mod { + + static { + SqlTypeMapper.ordinalEnumMapper(Platform.class); + SqlTypeMapper.ordinalEnumMapper(ModType.class); + } + + private static final Table table = new Table<>(Mod.class, "Mods"); + + private static final SelectStatement select = table.select(Table.PRIMARY); + private static final SelectStatement all = new SelectStatement(table, "SELECT * FROM Mods"); + private static final SelectStatement allUnklassified = new SelectStatement(table, "SELECT * FROM Mods WHERE modType = 0"); + private static final Statement update = table.update(Table.PRIMARY, "modType"); + + public static Mod get(Platform platform, String name) { + return select.select(platform, name); + } + + public static List getAll() { + return all.listSelect(); + } + + public static List getAllUnklassified() { + return allUnklassified.listSelect(); + } + + @Field(keys = {Table.PRIMARY}) + private final Platform platform; + @Field(keys = {Table.PRIMARY}) + private final String modName; + @Field(def = "0") + private ModType modType; + + public void setModType(ModType modType) { + this.modType = modType; + update.update(modType, platform, modName); + } + + public enum Platform { + FORGE, + LABYMOD, + FABRIC + } + + public enum ModType { + UNKLASSIFIED, + GREEN, + YELLOW, + RED, + YOUTUBER_ONLY; + } +}