use string instead of uuid
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-05-29 13:27:53 +02:00
parent 8d7f05d122
commit 2b89400168
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
5 changed files with 5 additions and 7 deletions

View File

@ -4,6 +4,6 @@ import com.google.gson.annotations.SerializedName
import java.util.*
data class ApiObject(
@SerializedName("tag") val tag: UUID,
@SerializedName("tag") val tag: String,
@SerializedName("probability") val probability: Double
)

View File

@ -9,7 +9,6 @@ import io.ktor.routing.get
import org.koin.ktor.ext.inject
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.util.*
/**
* Output Service - RDB
@ -64,7 +63,7 @@ class OutputServiceRDBServer {
get("/output/{tagID}") {
val tagID = call.parameters["tagID"] ?: error(HttpStatusCode.NotAcceptable)
val resultObject = resultObjectService.getResultObjectbyTag(UUID.fromString(tagID)) ?: call.respond(HttpStatusCode.NotFound)
val resultObject = resultObjectService.getResultObjectbyTag(tagID) ?: call.respond(HttpStatusCode.NotFound)
call.respond(resultObject)
}

View File

@ -4,10 +4,9 @@ import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.`java-time`.date
import java.time.LocalDate
import java.util.*
object ResultObjects : IntIdTable() {
val tag: Column<UUID> = uuid("tag")
val tag: Column<String> = varchar("tag", 32)
val date: Column<LocalDate> = date("date").default(LocalDate.now())
val probability: Column<Double> = double("probability")
override val primaryKey = PrimaryKey(id, name = "PK_ResultObject_Id")

View File

@ -7,7 +7,7 @@ import java.util.*
interface IResultObjectService{
fun addOne(apiObject: ApiObject)
suspend fun getAllResultObjects(): List<ApiObject>
suspend fun getResultObjectbyTag(tag: UUID): ApiObject?
suspend fun getResultObjectbyTag(tag: String): ApiObject?
suspend fun getResultObjectbyDate(date: LocalDate): List<ApiObject>?
suspend fun getResultObjectbeforeDate(date: LocalDate): List<ApiObject>?
suspend fun getResultObjectafterDate(date: LocalDate): List<ApiObject>?

View File

@ -27,7 +27,7 @@ class ResultObjectService : IResultObjectService {
ResultObjects.selectAll().map { toResultObject(it) }
}
override suspend fun getResultObjectbyTag(tag: UUID): ApiObject? = dbQuery {
override suspend fun getResultObjectbyTag(tag: String): ApiObject? = dbQuery {
ResultObjects.select {
(ResultObjects.tag eq tag)
}.mapNotNull { toResultObject(it) }