add last online ip #24
This commit is contained in:
@@ -101,7 +101,7 @@ func main() {
|
||||
}
|
||||
|
||||
func DatabaseAutoUpdate() {
|
||||
version := 240
|
||||
version := 241
|
||||
|
||||
db := global.DB
|
||||
|
||||
|
||||
@@ -54,10 +54,9 @@ func (i *Index) Heartbeat(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{})
|
||||
return
|
||||
}
|
||||
//如果在一分钟以内则不更新
|
||||
if time.Now().Unix()-peer.LastOnlineTime > 60 {
|
||||
peer.LastOnlineTime = time.Now().Unix()
|
||||
upp := &model.Peer{RowId: peer.RowId, LastOnlineTime: peer.LastOnlineTime}
|
||||
//如果在40s以内则不更新
|
||||
if time.Now().Unix()-peer.LastOnlineTime > 40 {
|
||||
upp := &model.Peer{RowId: peer.RowId, LastOnlineTime: time.Now().Unix(), LastOnlineIp: c.ClientIP()}
|
||||
service.AllService.PeerService.Update(upp)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{})
|
||||
|
||||
@@ -13,6 +13,7 @@ type Peer struct {
|
||||
UserId uint `json:"user_id" gorm:"default:0;not null;index"`
|
||||
User *User `json:"user,omitempty"`
|
||||
LastOnlineTime int64 `json:"last_online_time" gorm:"default:0;not null;"`
|
||||
LastOnlineIp string `json:"last_online_ip" gorm:"default:'';not null;"`
|
||||
TimeModel
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user