feat: Temperature Sensor + removeSensor
Dieser Commit ist enthalten in:
Ursprung
a5cff9cf7b
Commit
f98e6425be
3 geänderte Dateien mit 46 neuen und 5 gelöschten Zeilen
|
@ -33,4 +33,9 @@ public class LightSensorController {
|
|||
return currentMaxId++;
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public Float removeSensor(@PathVariable("id") Integer id) {
|
||||
return sensorValues.remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package fr.insa.arm.TemperatureSensorService.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/temperatureSensor")
|
||||
public class TemperatureSensorController {
|
||||
|
||||
private final Map<Integer, Float> sensorValues = new HashMap<>();
|
||||
private int currentMaxId = 0;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Float getSensorValue(@PathVariable("id") Integer id) {
|
||||
return sensorValues.getOrDefault(id, null);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public Float setSensorValue(@PathVariable("id") Integer id, @RequestBody Float value) {
|
||||
return sensorValues.replace(id, value);
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public int addSensor() {
|
||||
sensorValues.put(currentMaxId, null);
|
||||
return currentMaxId++;
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public Float removeSensor(@PathVariable("id") Integer id) {
|
||||
return sensorValues.remove(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package fr.insa.arm.TemperatureSensorService.model;
|
||||
|
||||
public class TemperatureSensor {
|
||||
|
||||
}
|
Laden …
In neuem Issue referenzieren