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))
|
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)
|
resBytes, err := fetch.Get(neUrl, nil, 60_000)
|
||||||
|
var resData []map[string]any
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errStr := err.Error()
|
errStr := err.Error()
|
||||||
logger.Warnf("AlarmHistory Get \"%s\"", neUrl)
|
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)
|
err = json.Unmarshal(resBytes, &resData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("AlarmHistory Unmarshal %s", err.Error())
|
logger.Errorf("AlarmHistory Unmarshal %s", err.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user