add MeasurementController

This commit is contained in:
2024-11-12 23:33:12 +01:00
parent 6297fbe542
commit 8d4a23f633
2 changed files with 63 additions and 0 deletions

View File

@@ -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)
}