fix(aiot): 修复 backfill-device-id 被全局响应拦截器误转型导致 500

GlobalResponseAdvice:65 对 LinkedHashMap 中的 "status" 键强转 Integer,
但 backfill 端点放入的是字符串 "success",触发 ClassCastException。

- backfill 返回 Map 的键从 "status" 改为 "result" 避免冲突
- GlobalResponseAdvice 增加 instanceof Integer 类型检查,防止其他端点踩坑

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 17:28:39 +08:00
parent 1093c61ca5
commit e140d4ceeb
2 changed files with 3 additions and 2 deletions

View File

@@ -162,7 +162,7 @@ public class AiConfigController {
int updatedRois = roiMapper.updateAllDeviceId(targetDeviceId);
result.put("rois_updated", updatedRois);
result.put("status", "success");
result.put("result", "success");
result.put("device_id", targetDeviceId);
log.info("[AiConfig] 统一 device_id 完成: deviceId={}, deletedDevices={}, updatedRois={}",
targetDeviceId, deleted, updatedRois);

View File

@@ -62,7 +62,8 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> {
if (body instanceof LinkedHashMap) {
LinkedHashMap<String, Object> bodyMap = (LinkedHashMap<String, Object>) body;
if (bodyMap.get("status") != null && (Integer)bodyMap.get("status") != 200) {
Object statusVal = bodyMap.get("status");
if (statusVal instanceof Integer && (Integer) statusVal != 200) {
return body;
}
}