ljw 1 год назад
Родитель
Сommit
1a1856257d
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      http/controller/api/index.go

+ 7 - 2
http/controller/api/index.go

@@ -3,6 +3,7 @@ package api
3
 import (
3
 import (
4
 	requstform "Gwen/http/request/api"
4
 	requstform "Gwen/http/request/api"
5
 	"Gwen/http/response"
5
 	"Gwen/http/response"
6
+	"Gwen/model"
6
 	"Gwen/service"
7
 	"Gwen/service"
7
 	"github.com/gin-gonic/gin"
8
 	"github.com/gin-gonic/gin"
8
 	"net/http"
9
 	"net/http"
@@ -53,7 +54,11 @@ func (i *Index) Heartbeat(c *gin.Context) {
53
 		c.JSON(http.StatusOK, gin.H{})
54
 		c.JSON(http.StatusOK, gin.H{})
54
 		return
55
 		return
55
 	}
56
 	}
56
-	peer.LastOnlineTime = time.Now().Unix()
57
-	service.AllService.PeerService.Update(peer)
57
+	//如果在一分钟以内则不更新
58
+	if time.Now().Unix()-peer.LastOnlineTime > 60 {
59
+		peer.LastOnlineTime = time.Now().Unix()
60
+		upp := &model.Peer{RowId: peer.RowId, LastOnlineTime: peer.LastOnlineTime}
61
+		service.AllService.PeerService.Update(upp)
62
+	}
58
 	c.JSON(http.StatusOK, gin.H{})
63
 	c.JSON(http.StatusOK, gin.H{})
59
 }
64
 }