dont send date
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-05-22 00:39:25 +02:00
parent 53b6b23ccc
commit a6bb5c8cc8
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
4 changed files with 4 additions and 8 deletions

View File

@ -23,7 +23,6 @@ fun Application.module() {
install(ContentNegotiation) { install(ContentNegotiation) {
gson { gson {
setPrettyPrinting() setPrettyPrinting()
setDateFormat("yyyy-MM-dd HH:mm:ss")
} }
} }

View File

@ -1,9 +1,7 @@
package com.kmalbz.api.model package com.kmalbz.api.model
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName
import java.time.LocalDate
data class SampleObject( data class SampleObject(
@SerializedName("date") val date: LocalDate,
@SerializedName("device_id") val device_id: String @SerializedName("device_id") val device_id: String
) )

View File

@ -1,6 +1,5 @@
package com.kmalbz.api.route package com.kmalbz.api.route
import com.google.gson.Gson
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import com.kmalbz.api.model.ApiObject import com.kmalbz.api.model.ApiObject
import com.kmalbz.api.model.SampleObject import com.kmalbz.api.model.SampleObject
@ -33,6 +32,7 @@ import org.koin.ktor.ext.inject
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
import java.io.OutputStream import java.io.OutputStream
import java.time.LocalDate
import java.util.* import java.util.*
import javax.activation.MimetypesFileTypeMap import javax.activation.MimetypesFileTypeMap
@ -65,7 +65,7 @@ class InputServiceServer {
val queueName = channel.queueDeclare().queue val queueName = channel.queueDeclare().queue
channel.queueBind(queueName, rabbitExchangeName, "") channel.queueBind(queueName, rabbitExchangeName, "")
val gson = GsonBuilder().setDateFormat("yyyy-MM-dd").setPrettyPrinting().create() val gson = GsonBuilder().setPrettyPrinting().create()
get("/sample"){ get("/sample"){
call.respond(resultObjectService.getAllInputObjects()) call.respond(resultObjectService.getAllInputObjects())
@ -100,7 +100,7 @@ class InputServiceServer {
val tag = UUID.randomUUID().toString() val tag = UUID.randomUUID().toString()
val currentApiObject = ApiObject(tag = tag, date = description!!.date, device_id = description!!.device_id) val currentApiObject = ApiObject(tag = tag, date = LocalDate.now(), device_id = description!!.device_id)
transaction { transaction {
resultObjectService.addOne(currentApiObject) resultObjectService.addOne(currentApiObject)

View File

@ -2,7 +2,6 @@
import requests import requests
import os.path import os.path
import json import json
import datetime
URL = "http://127.0.0.1:8080/sample" URL = "http://127.0.0.1:8080/sample"
@ -10,7 +9,7 @@ FILE = 'CommonStarling_102761_45.wav'
files = { files = {
"file": (os.path.basename(FILE), open(FILE,'rb').read(), 'audio/wave', {'Content-length' : os.path.getsize(FILE)}), "file": (os.path.basename(FILE), open(FILE,'rb').read(), 'audio/wave', {'Content-length' : os.path.getsize(FILE)}),
"description" : (None, json.dumps({"date" : datetime.date.today().strftime("%Y-%m-%d"), "device_id" : "123"}), "application/json") "description" : (None, json.dumps({"device_id" : "123"}), "application/json")
} }
r = requests.post(URL,files=files) r = requests.post(URL,files=files)