From ea36295be108433cc3d377cb04205d43960bc95e Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期二, 28 五月 2019 18:28:41 +0800
Subject: [PATCH] fix source[] nil

---
 esutil/EsClient.go |   38 ++++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/esutil/EsClient.go b/esutil/EsClient.go
index be812d8..f7fb363 100644
--- a/esutil/EsClient.go
+++ b/esutil/EsClient.go
@@ -133,20 +133,42 @@
 func getSourceBaseInfo(source map[string]interface{}) (baseInfoJson string) {
 	sdkType := source["sdkType"].(string)
 	if sdkType == "浜鸿劯" {
+		likePer,baseName,personId,idCard,personPicUrl,gender,content :="","","","","","",""
+		if source["likePer"] !=nil {
+			likePer = source["likePer"].(string)
+		}
+		if source["BaseName"] !=nil {
+			baseName = source["BaseName"].(string)
+		}
+		if source["personId"] !=nil {
+			personId = source["personId"].(string)
+		}
+		if source["idcard"] !=nil {
+			idCard = source["idcard"].(string)
+		}
+		if source["personPicUrl"] !=nil {
+			personPicUrl = source["personPicUrl"].(string)
+		}
+		if source["Gender"] !=nil {
+			gender = source["Gender"].(string)
+		}
+		if source["content"] !=nil {
+			content = source["content"].(string)
+		}
 		var baseInfo = BaseInfo{
 			TaskId:"",//2.0鏂板瓧娈�
 			TaskName:"",//2.0鏂板瓧娈�
-			LikePer:source["likePer"].(string),
+			LikePer:likePer,
 			TableId:"",//2.0鏂板瓧娈�
-			TableName:source["BaseName"].(string),
-			PersonId:source["personId"].(string),
-			PersonName:source["idcard"].(string),//浜哄憳濮撳悕锛屼粠绠$悊骞冲彴鑾峰彇
-			PersonPicUrl:source["personPicUrl"].(string),
-			Gender:source["Gender"].(string),
+			TableName:baseName,
+			PersonId:personId,
+			PersonName:idCard,//浜哄憳濮撳悕锛屼粠绠$悊骞冲彴鑾峰彇
+			PersonPicUrl:personPicUrl,
+			Gender:gender,
 			PhoneNum:"",//鎵嬫満鍙凤紝浠庣鐞嗗钩鍙拌幏鍙�
-			IDCard:source["idcard"].(string),
+			IDCard:idCard,
 			MonitorLevel:"",//2.0鏂板瓧娈�
-			Content:source["content"].(string),
+			Content:content,
 		}
 		bytes, err := json.Marshal(baseInfo)
 		if err !=nil {

--
Gitblit v1.8.0