refactor: restrict default raw history protocols
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@ConditionalOnProperty(prefix = "lingniu.ingest.event-history", name = "enabled", havingValue = "true")
|
||||
@@ -41,6 +42,10 @@ public final class RawFrameHistoryController {
|
||||
private static final TypeReference<Map<String, Object>> MAP_TYPE = new TypeReference<>() {};
|
||||
private static final int LOCATION_ENRICH_LIMIT = 1;
|
||||
private static final int TELEMETRY_ENRICH_LIMIT = 500;
|
||||
private static final Set<String> DEFAULT_PRODUCTION_PROTOCOLS = Set.of(
|
||||
"GB32960",
|
||||
"JT808",
|
||||
"MQTT_YUTONG");
|
||||
|
||||
private final TdengineHistoryReader reader;
|
||||
|
||||
@@ -88,9 +93,14 @@ public final class RawFrameHistoryController {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
|
||||
"vehicleKey, vin, phone, messageId or parseStatus is required for raw frame query");
|
||||
}
|
||||
String normalizedProtocol = normalize(protocol).toUpperCase(Locale.ROOT);
|
||||
if (!DEFAULT_PRODUCTION_PROTOCOLS.contains(normalizedProtocol)) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
|
||||
"protocol must be one of GB32960, JT808, MQTT_YUTONG");
|
||||
}
|
||||
QueryTimeRange range = QueryTimeRange.parse(dateFrom, dateTo);
|
||||
TdenginePage<TdengineRawFrameRow> page = reader.queryRawFrames(new TdengineRawFrameQuery(
|
||||
normalize(protocol).toUpperCase(Locale.ROOT),
|
||||
normalizedProtocol,
|
||||
normalize(vehicleKey),
|
||||
normalize(vin),
|
||||
normalize(phone),
|
||||
|
||||
Reference in New Issue
Block a user