From 808ce8f0bfa59f6333c27391b6983bdd67fd0bd6 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 16 四月 2024 14:37:18 +0800
Subject: [PATCH] 调整缓存的数据

---
 repository/captureRepo.go |   28 ++++++----------------------
 1 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/repository/captureRepo.go b/repository/captureRepo.go
index 56a1caf..3654d8c 100644
--- a/repository/captureRepo.go
+++ b/repository/captureRepo.go
@@ -23,7 +23,7 @@
 
 func (c CaptureRepository) FaceForward(faceList []vo.FaceObject) {
 	if faceList == nil || len(faceList) == 0 {
-		logger.Warn("faceList is nil")
+		logger.Warn("FaceList is nil")
 		return
 	}
 
@@ -58,11 +58,12 @@
 				return
 			}
 
-			if !c.SendData(payload, config.ForwardConf.SyncServer) {
-				c.CacheData(payload)
-				logger.Warn("鏁版嵁杞彂澶辫触, 娣诲姞缂撳瓨")
+			if !util.SendData(payload, config.ForwardConf.SyncServer) {
+				cacheItem, _ := json.Marshal(pd)
+				c.CacheData(cacheItem)
+				logger.Warn("The data forwarding failed, adding to local cache.")
 			} else {
-				logger.Debug("鏁版嵁杞彂鎴愬姛")
+				logger.Debug("The data forwarding successful. deviceId:%s", deviceId)
 			}
 		}
 	}
@@ -157,23 +158,6 @@
 	}
 
 	return pd
-}
-
-func (c CaptureRepository) SendData(payload []byte, url string) bool {
-	body, err := util.HttpPost(url, nil, payload)
-	if err != nil {
-		logger.Error("Post request failure, url:%s, err:%s", err.Error())
-		return false
-	}
-
-	var rsp vo.SyncServerResponse
-	err = json.Unmarshal(body, &rsp)
-	if err != nil {
-		logger.Error("Can't parse response, url:%s, rsp: %v", url, body)
-		return false
-	}
-
-	return rsp.Success
 }
 
 func (c CaptureRepository) CacheData(payload []byte) {

--
Gitblit v1.8.0