fix api
continuous-integration/drone/push Build is passing Details

pull/8/head
Arthur VALIN 1 year ago
parent 52d19d6fd9
commit 408370dc2b

@ -54,9 +54,7 @@ private fun Application.extracted() {
}
}
}
install(ContentNegotiation) {
json()
}
install(ContentNegotiation) { json() }
BasicRouting()
UserRouter()

@ -23,10 +23,51 @@ class PostgresDataSource : AllInDataSource() {
password = dbPassword
)
database.Execute("CREATE TABLE IF not exists utilisateur ( id uuid PRIMARY KEY, username VARCHAR(255), password VARCHAR(255),coins double precision,email VARCHAR(255))")
database.Execute("CREATE TABLE IF not exists bet ( id uuid PRIMARY KEY, theme VARCHAR(255), endregistration timestamp,endbet timestamp,sentencebet varchar(500),isprivate boolean, createdby varchar(250))")
database.Execute("CREATE TABLE IF NOT EXISTS participation (id uuid PRIMARY KEY,bet uuid,username varchar(250),answer varchar(250),stake int);")
database.Execute("CREATE TABLE IF NOT EXISTS response (id UUID,response VARCHAR(250),CONSTRAINT pk_response_id PRIMARY KEY (id,response));")
database.Execute(
"""
CREATE TABLE IF not exists utilisateur (
id uuid PRIMARY KEY,
username VARCHAR(255),
password VARCHAR(255),
coins double precision,
email VARCHAR(255)
)""".trimIndent()
)
database.Execute(
"""
CREATE TABLE IF not exists bet (
id uuid PRIMARY KEY,
theme VARCHAR(255),
endregistration timestamp,
endbet timestamp,
sentencebet varchar(500),
isprivate boolean,
createdby varchar(250),
status varchar(20),
type varchar(20)
)""".trimIndent()
)
database.Execute(
"""
CREATE TABLE IF NOT EXISTS participation (
id uuid PRIMARY KEY,
bet uuid,
username varchar(250),
answer varchar(250),
stake int
)""".trimIndent()
)
database.Execute(
"""
CREATE TABLE IF NOT EXISTS response (
id UUID,
response VARCHAR(250),
CONSTRAINT pk_response_id PRIMARY KEY (id,response)
)""".trimIndent()
)
}
override val userDataSource: UserDataSource = PostgresUserDataSource(database)

@ -4,7 +4,6 @@ import allin.data.UserDataSource
import allin.dto.UserDTO
import allin.entities.UsersEntity
import allin.model.User
import allin.utils.Execute
import org.ktorm.database.Database
import org.ktorm.dsl.*
import java.util.*
@ -52,7 +51,9 @@ class PostgresUserDataSource(private val database: Database) : UserDataSource {
}
override fun modifyUserCoins(username: String, amount: Int) {
val request = "UPDATE utilisateur SET coins = coins - $amount WHERE username = '$username';"
database.Execute(request)
database.update(UsersEntity) {
set(UsersEntity.nbCoins, UsersEntity.nbCoins - amount)
where { UsersEntity.username eq username }
}
}
}
Loading…
Cancel
Save