fix(alarm): 修复告警详情接口500错误
- 更新 get_alert 接口调用 _alarm_to_camel 的参数 - 使用 camera_info_map 替代 name_map - 正确传递 camera_service 参数
This commit is contained in:
@@ -203,12 +203,15 @@ async def get_alert(
|
|||||||
if not alarm_dict:
|
if not alarm_dict:
|
||||||
raise HTTPException(status_code=404, detail="告警不存在")
|
raise HTTPException(status_code=404, detail="告警不存在")
|
||||||
|
|
||||||
# 查询单个摄像头名称
|
# 查询单个摄像头信息
|
||||||
device_id = alarm_dict.get("device_id")
|
device_id = alarm_dict.get("device_id")
|
||||||
camera_service = get_camera_name_service()
|
camera_service = get_camera_name_service()
|
||||||
name_map = {device_id: await camera_service.get_display_name(device_id)} if device_id else {}
|
camera_info_map = {}
|
||||||
|
if device_id:
|
||||||
|
camera_info = await camera_service.get_camera_info(device_id)
|
||||||
|
camera_info_map[device_id] = camera_info
|
||||||
|
|
||||||
return YudaoResponse.success(await _alarm_to_camel(alarm_dict, name_map))
|
return YudaoResponse.success(await _alarm_to_camel(alarm_dict, camera_info_map, camera_service))
|
||||||
|
|
||||||
|
|
||||||
@router.put("/alert/handle")
|
@router.put("/alert/handle")
|
||||||
|
|||||||
Reference in New Issue
Block a user