fix: 修复告警历史记录函数中的空返回情况
This commit is contained in:
@@ -15,6 +15,7 @@ func AlarmHistory(neInfo model.NeInfo) ([]map[string]any, error) {
|
||||
// 网元参数配置信息
|
||||
neUrl := fmt.Sprintf("http://%s:%d/api/rest/faultManagement/v1/elementType/%s/objectType/alarms", neInfo.IP, neInfo.Port, strings.ToLower(neInfo.NeType))
|
||||
resBytes, err := fetch.Get(neUrl, nil, 60_000)
|
||||
var resData []map[string]any
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
logger.Warnf("AlarmHistory Get \"%s\"", neUrl)
|
||||
@@ -24,8 +25,11 @@ func AlarmHistory(neInfo model.NeInfo) ([]map[string]any, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(resBytes) == 0 {
|
||||
return resData, nil
|
||||
}
|
||||
|
||||
// 序列化结果
|
||||
var resData []map[string]any
|
||||
err = json.Unmarshal(resBytes, &resData)
|
||||
if err != nil {
|
||||
logger.Errorf("AlarmHistory Unmarshal %s", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user