diff --git a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt index 76702804..5e369415 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt @@ -27,14 +27,19 @@ import org.jetbrains.exposed.v1.core.dao.id.EntityID import org.jetbrains.exposed.v1.core.eq import org.jetbrains.exposed.v1.dao.CompositeEntity import org.jetbrains.exposed.v1.dao.CompositeEntityClass +import org.jetbrains.exposed.v1.jdbc.insert object PersonalKitTable: CompositeIdTable("PersonalKit") { val userId = reference("UserId", SteamwarUserTable) - val gamemode = varchar("Gamemode", 64) - val kitName = varchar("Name", 64) + val gamemode = varchar("Gamemode", 64).entityId() + val kitName = varchar("Name", 64).entityId() val inventory = text("Inventory") val armor = text("Armor") val inUse = bool("InUse") + + init { + addIdColumn(userId) + } } class InternalKit(id: EntityID): CompositeEntity(id) { @@ -53,14 +58,15 @@ class InternalKit(id: EntityID): CompositeEntity(id) { @JvmStatic fun create(userId: Int, gamemode: String, kitName: String, rawInventory: String, rawArmor: String) = useDb { - new { - this.userID = userId - this.gamemode = gamemode - this.name = kitName - this.inUse = true - this.rawInventory = rawInventory - this.rawArmor = rawArmor + PersonalKitTable.insert { + it[this.userId] = EntityID(userId, SteamwarUserTable) + it[this.gamemode] = gamemode + it[this.kitName] = kitName + it[this.inventory] = rawInventory + it[this.armor] = rawArmor + it[this.inUse] = true } + get(userId, gamemode, kitName) } @JvmStatic