forked from SteamWar/SteamWar
Refactor PersonalKitTable to use explicit ID column initialization and update create method to utilize insert operation.
Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
@@ -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.core.eq
|
||||||
import org.jetbrains.exposed.v1.dao.CompositeEntity
|
import org.jetbrains.exposed.v1.dao.CompositeEntity
|
||||||
import org.jetbrains.exposed.v1.dao.CompositeEntityClass
|
import org.jetbrains.exposed.v1.dao.CompositeEntityClass
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.insert
|
||||||
|
|
||||||
object PersonalKitTable: CompositeIdTable("PersonalKit") {
|
object PersonalKitTable: CompositeIdTable("PersonalKit") {
|
||||||
val userId = reference("UserId", SteamwarUserTable)
|
val userId = reference("UserId", SteamwarUserTable)
|
||||||
val gamemode = varchar("Gamemode", 64)
|
val gamemode = varchar("Gamemode", 64).entityId()
|
||||||
val kitName = varchar("Name", 64)
|
val kitName = varchar("Name", 64).entityId()
|
||||||
val inventory = text("Inventory")
|
val inventory = text("Inventory")
|
||||||
val armor = text("Armor")
|
val armor = text("Armor")
|
||||||
val inUse = bool("InUse")
|
val inUse = bool("InUse")
|
||||||
|
|
||||||
|
init {
|
||||||
|
addIdColumn(userId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||||
@@ -53,14 +58,15 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun create(userId: Int, gamemode: String, kitName: String, rawInventory: String, rawArmor: String) = useDb {
|
fun create(userId: Int, gamemode: String, kitName: String, rawInventory: String, rawArmor: String) = useDb {
|
||||||
new {
|
PersonalKitTable.insert {
|
||||||
this.userID = userId
|
it[this.userId] = EntityID(userId, SteamwarUserTable)
|
||||||
this.gamemode = gamemode
|
it[this.gamemode] = gamemode
|
||||||
this.name = kitName
|
it[this.kitName] = kitName
|
||||||
this.inUse = true
|
it[this.inventory] = rawInventory
|
||||||
this.rawInventory = rawInventory
|
it[this.armor] = rawArmor
|
||||||
this.rawArmor = rawArmor
|
it[this.inUse] = true
|
||||||
}
|
}
|
||||||
|
get(userId, gamemode, kitName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
Reference in New Issue
Block a user