This commit is contained in:
parent
938348cb60
commit
5e443345af
@ -117,7 +117,7 @@ class InputServiceServer {
|
|||||||
|
|
||||||
get("/sample/{tagID}") {
|
get("/sample/{tagID}") {
|
||||||
val tagID = call.parameters["tagID"] ?: error(HttpStatusCode.NotAcceptable)
|
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)
|
call.respond(resultObject)
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ package com.kmalbz.database.service
|
|||||||
|
|
||||||
import com.kmalbz.api.model.ApiObject
|
import com.kmalbz.api.model.ApiObject
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
interface IInputObjectService{
|
interface IInputObjectService{
|
||||||
fun addOne(apiObject: ApiObject)
|
fun addOne(apiObject: ApiObject)
|
||||||
suspend fun getAllInputObjects(): List<ApiObject>
|
suspend fun getAllInputObjects(): List<ApiObject>
|
||||||
suspend fun getInputObjectbyTag(tag: String): ApiObject?
|
suspend fun getInputObjectbyTag(tag: UUID): ApiObject?
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ import org.jetbrains.exposed.sql.select
|
|||||||
import org.jetbrains.exposed.sql.selectAll
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class InputObjectService : IInputObjectService {
|
class InputObjectService : IInputObjectService {
|
||||||
@ -26,7 +27,7 @@ class InputObjectService : IInputObjectService {
|
|||||||
InputObjects.selectAll().map { toInputObject(it) }
|
InputObjects.selectAll().map { toInputObject(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getInputObjectbyTag(tag: String): ApiObject? = dbQuery {
|
override suspend fun getInputObjectbyTag(tag: UUID): ApiObject? = dbQuery {
|
||||||
InputObjects.select {
|
InputObjects.select {
|
||||||
(InputObjects.tag eq tag)
|
(InputObjects.tag eq tag)
|
||||||
}.mapNotNull { toInputObject(it) }
|
}.mapNotNull { toInputObject(it) }
|
||||||
|
Loading…
Reference in New Issue
Block a user