New endpoints for latest data
This commit is contained in:
@@ -27,6 +27,8 @@ public class Constants {
|
|||||||
public static final String GET_DEVICE_SENSORS = API_PREFIX + "/devices/:deviceId/sensors";
|
public static final String GET_DEVICE_SENSORS = API_PREFIX + "/devices/:deviceId/sensors";
|
||||||
public static final String POST_DEVICES = API_PREFIX + "/devices";
|
public static final String POST_DEVICES = API_PREFIX + "/devices";
|
||||||
public static final String PUT_DEVICE_BY_ID = API_PREFIX + "/devices/:deviceId";
|
public static final String PUT_DEVICE_BY_ID = API_PREFIX + "/devices/:deviceId";
|
||||||
|
public static final String GET_DEVICE_ACTUATORS = API_PREFIX + "/devices/:deviceId/actuators";
|
||||||
|
public static final String GET_DEVICE_LATEST_VALUES = API_PREFIX + "/devices/:deviceId/latest";
|
||||||
|
|
||||||
public static final String GET_SENSORS = API_PREFIX + "/sensors";
|
public static final String GET_SENSORS = API_PREFIX + "/sensors";
|
||||||
public static final String GET_SENSOR_BY_ID = API_PREFIX + "/sensors/:sensorId";
|
public static final String GET_SENSOR_BY_ID = API_PREFIX + "/sensors/:sensorId";
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public class ApiVerticle extends AbstractVerticle {
|
|||||||
router.route(HttpMethod.GET, Constants.GET_DEVICES).handler(this::getDevicesHandler);
|
router.route(HttpMethod.GET, Constants.GET_DEVICES).handler(this::getDevicesHandler);
|
||||||
router.route(HttpMethod.GET, Constants.GET_DEVICE_BY_ID).handler(this::getDeviceByIdHandler);
|
router.route(HttpMethod.GET, Constants.GET_DEVICE_BY_ID).handler(this::getDeviceByIdHandler);
|
||||||
router.route(HttpMethod.GET, Constants.GET_DEVICE_SENSORS).handler(this::getDeviceSensorsHandler);
|
router.route(HttpMethod.GET, Constants.GET_DEVICE_SENSORS).handler(this::getDeviceSensorsHandler);
|
||||||
|
router.route(HttpMethod.GET, Constants.GET_DEVICE_ACTUATORS).handler(this::getDeviceActuatorsHandler);
|
||||||
|
router.route(HttpMethod.GET, Constants.GET_DEVICE_LATEST_VALUES).handler(this::getDeviceLatestValuesHandler);
|
||||||
router.route(HttpMethod.POST, Constants.POST_DEVICES).handler(this::postDeviceHandler);
|
router.route(HttpMethod.POST, Constants.POST_DEVICES).handler(this::postDeviceHandler);
|
||||||
router.route(HttpMethod.PUT, Constants.PUT_DEVICE_BY_ID).handler(this::putDeviceByIdHandler);
|
router.route(HttpMethod.PUT, Constants.PUT_DEVICE_BY_ID).handler(this::putDeviceByIdHandler);
|
||||||
|
|
||||||
@@ -182,6 +184,26 @@ public class ApiVerticle extends AbstractVerticle {
|
|||||||
.build();
|
.build();
|
||||||
sendQuery(query, context);
|
sendQuery(query, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getDeviceActuatorsHandler(RoutingContext context) {
|
||||||
|
String deviceId = context.request().getParam("deviceId");
|
||||||
|
String query = QueryBuilder
|
||||||
|
.select("*")
|
||||||
|
.from("actuators")
|
||||||
|
.where("deviceId = ?", deviceId)
|
||||||
|
.build();
|
||||||
|
sendQuery(query, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getDeviceLatestValuesHandler(RoutingContext context) {
|
||||||
|
String deviceId = context.request().getParam("deviceId");
|
||||||
|
String query = QueryBuilder
|
||||||
|
.select("*")
|
||||||
|
.from("v_latest_values")
|
||||||
|
.where("deviceId = ?", deviceId)
|
||||||
|
.build();
|
||||||
|
sendQuery(query, context);
|
||||||
|
}
|
||||||
|
|
||||||
private void postDeviceHandler(RoutingContext context) {
|
private void postDeviceHandler(RoutingContext context) {
|
||||||
JsonObject body = context.body().asJsonObject();
|
JsonObject body = context.body().asJsonObject();
|
||||||
|
|||||||
@@ -7,9 +7,32 @@
|
|||||||
},
|
},
|
||||||
"appConfig": {
|
"appConfig": {
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"baseUrl": "http://localhost:80/api/v1",
|
"BASE_URL": "http://localhost:8081/api/v1",
|
||||||
"sensors": "sensors",
|
"GET_GROUPS": "/groups",
|
||||||
"sensor": "sensors/sensor"
|
"GET_GROUP_BY_ID": "/groups/{0}",
|
||||||
|
"GET_GROUP_DEVICES": "/groups/{0}/devices",
|
||||||
|
"POST_GROUPS": "/groups",
|
||||||
|
"PUT_GROUP_BY_ID": "/groups/{0}",
|
||||||
|
"GET_DEVICES": "/devices",
|
||||||
|
"GET_DEVICE_BY_ID": "/devices/{0}",
|
||||||
|
"GET_DEVICE_SENSORS": "/devices/{0}/sensors",
|
||||||
|
"POST_DEVICES": "/devices",
|
||||||
|
"PUT_DEVICE_BY_ID": "/devices/{0}",
|
||||||
|
"GET_SENSORS": "/sensors",
|
||||||
|
"GET_SENSOR_BY_ID": "/sensors/{0}",
|
||||||
|
"GET_SENSOR_VALUES": "/sensors/{0}/values",
|
||||||
|
"POST_SENSORS": "/sensors",
|
||||||
|
"PUT_SENSOR_BY_ID": "/sensors/{0}",
|
||||||
|
"GET_ACTUATORS": "/actuators",
|
||||||
|
"GET_ACTUATOR_BY_ID": "/actuators/{0}",
|
||||||
|
"POST_ACTUATORS": "/actuators",
|
||||||
|
"PUT_ACTUATOR_BY_ID": "/actuators/{0}",
|
||||||
|
"GET_GPS_VALUES": "/gps-values",
|
||||||
|
"GET_GPS_VALUE_BY_ID": "/gps-values/{0}",
|
||||||
|
"POST_GPS_VALUES": "/gps-values",
|
||||||
|
"GET_AIR_VALUES": "/air-values",
|
||||||
|
"GET_AIR_VALUE_BY_ID": "/air-values/{0}",
|
||||||
|
"POST_AIR_VALUES": "/air-values"
|
||||||
},
|
},
|
||||||
"historyChartConfig": {
|
"historyChartConfig": {
|
||||||
"chartOptionsDark": {
|
"chartOptionsDark": {
|
||||||
|
|||||||
Reference in New Issue
Block a user