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.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<CompositeID>): CompositeEntity(id) {
|
||||
@@ -53,14 +58,15 @@ class InternalKit(id: EntityID<CompositeID>): 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
|
||||
|
||||
Reference in New Issue
Block a user