Просмотр исходного кода

feat(video): 录像查询失败使用专用类别

Kazerin 3 недель назад
Родитель
Сommit
1cbd539045

+ 11 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitVideoControllerTest.java

@@ -171,6 +171,17 @@ class CockpitVideoControllerTest {
                 .andExpect(jsonPath("$.data.records").isEmpty());
     }
 
+    @Test
+    void aFailedRecordingQueryIsItsOwnCategoryNotAGenericVideoRead() throws Exception {
+        when(collector.get(RECORD_QUERY, Map.of("deviceId", GB, "channelId", CHANNEL,
+                "startTime", "2026-11-10 00:00:00", "endTime", "2026-11-10 12:00:00", "type", "all")))
+                .thenThrow(new ServiceException("查询录像失败"));
+        mvc.perform(get(ROOT + "/records").param("deviceCode", CODE)
+                        .param("startTime", "2026-11-10 00:00:00").param("endTime", "2026-11-10 12:00:00"))
+                .andExpect(status().isBadGateway())
+                .andExpect(jsonPath("$.data.category").value("VIDEO_RECORDS_FAILED"));
+    }
+
     @Test
     void recordingRangeOverSevenDaysIsRejectedBeforeTouchingTheDevice() throws Exception {
         mvc.perform(get(ROOT + "/records").param("deviceCode", CODE)

+ 1 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/video/CockpitVideoService.java

@@ -61,7 +61,7 @@ public class CockpitVideoService {
         } catch (RuntimeException failure) {
             if (invalidRange(failure))
                 throw new CockpitVideoException(400, "INVALID_REQUEST", "录像时间格式为 yyyy-MM-dd HH:mm:ss,结束时间须晚于开始时间且范围不超过 7 天");
-            throw new CockpitVideoException(502, "VIDEO_READ_FAILED", "录像查询失败,请稍后重试");
+            throw new CockpitVideoException(502, "VIDEO_RECORDS_FAILED", "录像查询失败,请稍后重试");
         }
         List<Map<String, Object>> items = recordItems(raw);
         Map<String, Object> data = new LinkedHashMap<>();