add MeasurementController
This commit is contained in:
32
http/measurement.http
Normal file
32
http/measurement.http
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
### add measurement for all
|
||||||
|
POST {{hostname}}/client-00000000-0000-7000-0001-000000000001
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"tags": {
|
||||||
|
"device": "00000000-0000-7000-0002-000000000001",
|
||||||
|
"node": "00000000-0000-7000-0003-000000000001"
|
||||||
|
},
|
||||||
|
"fields": {
|
||||||
|
"button0": 1,
|
||||||
|
"button1": 0,
|
||||||
|
"button2": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
### add measurement for one
|
||||||
|
POST {{hostname}}/client-00000000-0000-7000-0001-000000000001
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"tags": {
|
||||||
|
"device": "00000000-0000-7000-0002-000000000001",
|
||||||
|
"node": "00000000-0000-7000-0003-000000000001"
|
||||||
|
},
|
||||||
|
"fields": {
|
||||||
|
"button1": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
### add measurement
|
||||||
|
GET {{hostname}}/client-00000000-0000-7000-0001-000000000001/node-00000000-0000-7000-0003-000000000001
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package ltd.hlaeja.controller
|
||||||
|
|
||||||
|
import java.util.UUID
|
||||||
|
import ltd.hlaeja.library.deviceData.MeasurementData
|
||||||
|
import ltd.hlaeja.service.MeasurementService
|
||||||
|
import org.springframework.http.HttpStatus.CREATED
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus
|
||||||
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
class MeasurementController(
|
||||||
|
private val service: MeasurementService,
|
||||||
|
) {
|
||||||
|
|
||||||
|
@PostMapping("/client-{client}")
|
||||||
|
@ResponseStatus(CREATED)
|
||||||
|
suspend fun addMeasurement(
|
||||||
|
@PathVariable client: UUID,
|
||||||
|
@RequestBody measurement: MeasurementData.Request,
|
||||||
|
) = service.addMeasurement(client, measurement)
|
||||||
|
|
||||||
|
@GetMapping("/client-{client}/node-{node}")
|
||||||
|
suspend fun getLastDeviceMeasurement(
|
||||||
|
@PathVariable client: UUID,
|
||||||
|
@PathVariable node: UUID,
|
||||||
|
): MeasurementData.Response = service.getNodeMeasurement(client, node)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user