mq done, dao refactor, endpoints refactor
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
11
src/api/model/ApiObject.kt
Normal file
11
src/api/model/ApiObject.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.kmalbz.api.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.time.LocalDate
|
||||
|
||||
data class ApiObject(
|
||||
@SerializedName("tag") val tag: String,
|
||||
@SerializedName("date") val date: LocalDate,
|
||||
@SerializedName("decision") val decision: Boolean,
|
||||
@SerializedName("confidence") val confidence: Double
|
||||
)
|
||||
63
src/api/route/OutputServiceRDBServer.kt
Normal file
63
src/api/route/OutputServiceRDBServer.kt
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.kmalbz.api.route
|
||||
|
||||
import io.ktor.application.*
|
||||
import io.ktor.response.*
|
||||
import io.ktor.routing.*
|
||||
import io.ktor.http.*
|
||||
import com.kmalbz.database.service.ResultObjectService
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
/**
|
||||
* Output Service - RDB
|
||||
*
|
||||
* This is the output interface of the Birbnetes system.
|
||||
*/
|
||||
class OutputServiceRDBServer() {
|
||||
/**
|
||||
* output
|
||||
*/
|
||||
private val resultObjectService = ResultObjectService()
|
||||
fun Routing.registerOutput() {
|
||||
get("/output"){
|
||||
call.respond(resultObjectService.getAllResultObjects())
|
||||
}
|
||||
|
||||
get("/output/filter/negative") {
|
||||
val resultList = resultObjectService.getResultObjectbyDecision(false) ?: error(HttpStatusCode.NotFound)
|
||||
|
||||
call.respond(resultList)
|
||||
}
|
||||
|
||||
get("/output/filter/positive") {
|
||||
val resultList = resultObjectService.getResultObjectbyDecision(true) ?: error(HttpStatusCode.NotFound)
|
||||
|
||||
call.respond(resultList)
|
||||
}
|
||||
|
||||
get("/output/after/{dateAfter}") {
|
||||
val dateAfter = call.parameters["dateAfter"] ?: error(HttpStatusCode.NotAcceptable)
|
||||
val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE
|
||||
val localDateAfter : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter)
|
||||
val resultList = resultObjectService.getResultObjectbeforeDate(localDateAfter) ?: error(HttpStatusCode.NotFound)
|
||||
|
||||
call.respond(resultList)
|
||||
}
|
||||
|
||||
get("/output/before/{dateBefore}") {
|
||||
val dateAfter = call.parameters["dateBefore"] ?: error(HttpStatusCode.NotAcceptable)
|
||||
val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE
|
||||
val localDateBefore : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter)
|
||||
val resultList = resultObjectService.getResultObjectafterDate(localDateBefore) ?: error(HttpStatusCode.NotFound)
|
||||
|
||||
call.respond(resultList)
|
||||
}
|
||||
|
||||
get("/output/{tagID}") {
|
||||
val tagID = call.parameters["tagID"] ?: error(HttpStatusCode.NotAcceptable)
|
||||
val resultObject = resultObjectService.getResultObjectbyTag(tagID) ?: error(HttpStatusCode.NotFound)
|
||||
|
||||
call.respond(resultObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user