Browse Source

fix:彭博接口返回数据兼容null的情况,不能使服务崩溃

Roc 1 month ago
parent
commit
5d1e05b78d
1 changed files with 9 additions and 0 deletions
  1. 9 0
      services/base_from_pb.go

+ 9 - 0
services/base_from_pb.go

@@ -45,6 +45,10 @@ func GetEdbDataFromPb(edbCode, startDate, endDate, edbTerminalCode string) (item
 		utils.FileLog.Info("GetEdbDataByPb Unmarshal Err:" + err.Error())
 		return
 	}
+	if item == nil {
+		err = fmt.Errorf("彭博数据转结构体失败,body:" + string(body))
+		return
+	}
 	edbCode, _ = url.QueryUnescape(edbCode)
 	return
 }
@@ -86,6 +90,11 @@ func GetEdbDataFromPbFinance(companyCode, edbCode, startDate, endDate, edbTermin
 		utils.FileLog.Info("GetEdbDataByPb Unmarshal Err:" + err.Error())
 		return
 	}
+	if item == nil {
+		err = fmt.Errorf("彭博财务数据转结构体失败,body:" + string(body))
+		return
+	}
+
 	edbCode, _ = url.QueryUnescape(edbCode)
 	return
 }