api done
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-08-11 15:06:09 +02:00
parent 26acf2085c
commit b04ddf66c6
5 changed files with 19 additions and 59 deletions

View File

@@ -4,7 +4,6 @@ import com.google.gson.annotations.SerializedName
import java.time.LocalDate
data class ApiObject(
@SerializedName("id") val id: Int,
@SerializedName("tag") val tag: String,
@SerializedName("device_id") val device_id: Int,
@SerializedName("device_date") val device_date: LocalDate

View File

@@ -11,39 +11,21 @@ import java.time.LocalDate
import java.time.format.DateTimeFormatter
/**
* Output Service - RDB
* Sample Service
*
* This is the output interface of the Birbnetes system.
* This is the sample interface of the Birbnetes system.
*/
class OutputServiceRDBServer {
/**
* output
* sample
*/
fun Routing.registerOutput() {
val resultObjectService by inject<ISampleObjectService>()
get("/output"){
get("/sample"){
call.respond(resultObjectService.getAllSampleObjects())
}
get("/output/filter/negative") {
val resultList = resultObjectService.getSampleObjecLessthanId(0.5) ?: call.respond(HttpStatusCode.NotFound)
call.respond(resultList)
}
get("/output/filter/positive") {
val resultList = resultObjectService.getSampleObjecGreaterthanId(0.5) ?: call.respond(HttpStatusCode.NotFound)
call.respond(resultList)
}
get("/output/filter/undecided") {
val resultList = resultObjectService.getSampleObjecEqualsId(0.5) ?: call.respond(HttpStatusCode.NotFound)
call.respond(resultList)
}
get("/output/after/{dateAfter}") {
get("/sample/after/{dateAfter}") {
val dateAfter = call.parameters["dateAfter"] ?: error(HttpStatusCode.NotAcceptable)
val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE
val localDateAfter : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter)
@@ -52,7 +34,7 @@ class OutputServiceRDBServer {
call.respond(resultList)
}
get("/output/before/{dateBefore}") {
get("/sample/before/{dateBefore}") {
val dateAfter = call.parameters["dateBefore"] ?: error(HttpStatusCode.NotAcceptable)
val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE
val localDateBefore : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter)
@@ -61,7 +43,7 @@ class OutputServiceRDBServer {
call.respond(resultList)
}
get("/output/{tagID}") {
get("/sample/{tagID}") {
val tagID = call.parameters["tagID"] ?: error(HttpStatusCode.NotAcceptable)
val resultObject = resultObjectService.getSampleObjectbyTag(tagID) ?: call.respond(HttpStatusCode.NotFound)