1
0

Big changes on API and Frontend

This commit is contained in:
Jose
2025-03-11 23:58:11 +01:00
parent 0e5e93cb73
commit 6cc3c6525e
19 changed files with 389 additions and 142 deletions

View File

@@ -29,7 +29,9 @@ public class Constants {
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_DEVICE_POLLUTION_MAP = API_PREFIX + "/devices/:deviceId/pollution-map";
public static final String GET_DEVICE_HISTORY = API_PREFIX + "/devices/:deviceId/history";
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_VALUES = API_PREFIX + "/sensors/:sensorId/values";
@@ -40,14 +42,7 @@ public class Constants {
public static final String GET_ACTUATOR_BY_ID = API_PREFIX + "/actuators/:actuatorId";
public static final String POST_ACTUATORS = API_PREFIX + "/actuators";
public static final String PUT_ACTUATOR_BY_ID = API_PREFIX + "/actuators/:actuatorId";
public static final String GET_GPS_VALUES = API_PREFIX + "/gps-values";
public static final String GET_GPS_VALUE_BY_ID = API_PREFIX + "/gps-values/:valueId";
public static final String POST_GPS_VALUES = API_PREFIX + "/gps-values";
public static final String GET_AIR_VALUES = API_PREFIX + "/air-values";
public static final String GET_AIR_VALUE_BY_ID = API_PREFIX + "/air-values/:valueId";
public static final String POST_AIR_VALUES = API_PREFIX + "/air-values";
private Constants() {
throw new AssertionError("Utility class cannot be instantiated.");

View File

@@ -50,6 +50,8 @@ public class ApiVerticle extends AbstractVerticle {
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.PUT, Constants.PUT_DEVICE_BY_ID).handler(this::putDeviceByIdHandler);
router.route(HttpMethod.GET, Constants.GET_DEVICE_POLLUTION_MAP).handler(this::getPollutionMapHandler);
router.route(HttpMethod.GET, Constants.GET_DEVICE_HISTORY).handler(this::getDeviceHistoryHandler);
// Sensor Routes
router.route(HttpMethod.GET, Constants.GET_SENSORS).handler(this::getSensorsHandler);
@@ -245,6 +247,26 @@ public class ApiVerticle extends AbstractVerticle {
sendQuery(query, context);
}
private void getPollutionMapHandler(RoutingContext context) {
String deviceId = context.request().getParam("deviceId");
String query = QueryBuilder
.select("*")
.from("v_pollution_map")
.where("deviceId = ?", deviceId)
.build();
sendQuery(query, context);
}
private void getDeviceHistoryHandler(RoutingContext context) {
String deviceId = context.request().getParam("deviceId");
String query = QueryBuilder
.select("*")
.from("v_sensor_history_by_device")
.where("deviceId = ?", deviceId)
.build();
sendQuery(query, context);
}
// Sensor Handlers
private void getSensorsHandler(RoutingContext context) {

View File

@@ -14,7 +14,7 @@ public class MainVerticle extends AbstractVerticle {
getVertx().deployVerticle(new DatabaseVerticle(), options);
getVertx().deployVerticle(new ApiVerticle(), options);
getVertx().deployVerticle(new HttpServerVerticle());
//getVertx().deployVerticle(new HttpServerVerticle());
}
@Override