use uuid class
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-05-22 00:52:31 +02:00
parent 938348cb60
commit 5e443345af
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
3 changed files with 5 additions and 3 deletions

View File

@ -117,7 +117,7 @@ class InputServiceServer {
get("/sample/{tagID}") {
val tagID = call.parameters["tagID"] ?: error(HttpStatusCode.NotAcceptable)
val resultObject = resultObjectService.getInputObjectbyTag(tagID) ?: call.respond(HttpStatusCode.NotFound)
val resultObject = resultObjectService.getInputObjectbyTag(UUID.fromString(tagID)) ?: call.respond(HttpStatusCode.NotFound)
call.respond(resultObject)
}

View File

@ -2,9 +2,10 @@ package com.kmalbz.database.service
import com.kmalbz.api.model.ApiObject
import java.time.LocalDate
import java.util.*
interface IInputObjectService{
fun addOne(apiObject: ApiObject)
suspend fun getAllInputObjects(): List<ApiObject>
suspend fun getInputObjectbyTag(tag: String): ApiObject?
suspend fun getInputObjectbyTag(tag: UUID): ApiObject?
}

View File

@ -9,6 +9,7 @@ import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import java.time.LocalDate
import java.util.*
class InputObjectService : IInputObjectService {
@ -26,7 +27,7 @@ class InputObjectService : IInputObjectService {
InputObjects.selectAll().map { toInputObject(it) }
}
override suspend fun getInputObjectbyTag(tag: String): ApiObject? = dbQuery {
override suspend fun getInputObjectbyTag(tag: UUID): ApiObject? = dbQuery {
InputObjects.select {
(InputObjects.tag eq tag)
}.mapNotNull { toInputObject(it) }