Merge remote-tracking branch 'origin/daily_gift' into daily_gift
continuous-integration/drone/push Build is passing Details

# Conflicts:
#	Sources/src/main/kotlin/allin/entities/UserEntity.kt
pull/7/head
luevard 10 months ago
commit 27892f9d83

@ -10,7 +10,6 @@ import org.ktorm.dsl.*
import org.ktorm.entity.*
import org.ktorm.schema.*
import java.time.Instant.now
import java.util.*
import java.util.UUID.fromString
interface UserEntity : Entity<UserEntity> {
@ -27,15 +26,16 @@ object UsersEntity : Table<UserEntity>("utilisateur") {
val email = varchar("email")
val lastGift = timestamp("lastgift")
fun getUserToUserDTO(): MutableList<UserDTO> {
return database.from(UsersEntity).select().map {
row -> UserDTO(
row[id].toString(),
row[username].toString(),
row[email].toString(),
row[nbCoins]?:0,
null
)
row -> UserDTO(
row[id].toString(),
row[username].toString(),
row[email].toString(),
row[nbCoins]?:0,
null
)
}.toMutableList()
}
@ -47,7 +47,13 @@ object UsersEntity : Table<UserEntity>("utilisateur") {
fun modifyCoins(user: String, cost : Int){
val request = "UPDATE utilisateur SET coins = coins - $cost WHERE username = '$user';"
database.Execute(request)
}
fun addCoinByUsername(username: String, coins : Int){
database.update(UsersEntity){
set(nbCoins,coins+ nbCoins)
where {it.username eq username}
}
}
fun getUserByUsernameAndPassword(login: String): Pair<UserDTO?, String?> {
@ -108,3 +114,4 @@ object UsersEntity : Table<UserEntity>("utilisateur") {
}

Loading…
Cancel
Save