Просмотр исходного кода

fix!: Update peer to use ID instead of UUID

lejianwen месяцев назад: 5
Родитель
Сommit
9b769b99dc
3 измененных файлов с 7 добавлено и 7 удалено
  1. 1 1
      http/controller/api/index.go
  2. 3 3
      http/controller/api/peer.go
  3. 3 3
      service/user.go

+ 1 - 1
http/controller/api/index.go

@@ -49,7 +49,7 @@ func (i *Index) Heartbeat(c *gin.Context) {
49
 		c.JSON(http.StatusOK, gin.H{})
49
 		c.JSON(http.StatusOK, gin.H{})
50
 		return
50
 		return
51
 	}
51
 	}
52
-	peer := service.AllService.PeerService.FindByUuid(info.Uuid)
52
+	peer := service.AllService.PeerService.FindById(info.Id)
53
 	if peer == nil || peer.RowId == 0 {
53
 	if peer == nil || peer.RowId == 0 {
54
 		c.JSON(http.StatusOK, gin.H{})
54
 		c.JSON(http.StatusOK, gin.H{})
55
 		return
55
 		return

+ 3 - 3
http/controller/api/peer.go

@@ -31,10 +31,10 @@ func (p *Peer) SysInfo(c *gin.Context) {
31
 		return
31
 		return
32
 	}
32
 	}
33
 	fpe := f.ToPeer()
33
 	fpe := f.ToPeer()
34
-	pe := service.AllService.PeerService.FindByUuid(f.Uuid)
34
+	pe := service.AllService.PeerService.FindById(f.Id)
35
 	if pe.RowId == 0 {
35
 	if pe.RowId == 0 {
36
 		pe = f.ToPeer()
36
 		pe = f.ToPeer()
37
-		pe.UserId = service.AllService.UserService.FindLatestUserIdFromLoginLogByUuid(pe.Uuid)
37
+		pe.UserId = service.AllService.UserService.FindLatestUserIdFromLoginLogByUuid(pe.Uuid, pe.Id)
38
 		err = service.AllService.PeerService.Create(pe)
38
 		err = service.AllService.PeerService.Create(pe)
39
 		if err != nil {
39
 		if err != nil {
40
 			response.Error(c, response.TranslateMsg(c, "OperationFailed")+err.Error())
40
 			response.Error(c, response.TranslateMsg(c, "OperationFailed")+err.Error())
@@ -42,7 +42,7 @@ func (p *Peer) SysInfo(c *gin.Context) {
42
 		}
42
 		}
43
 	} else {
43
 	} else {
44
 		if pe.UserId == 0 {
44
 		if pe.UserId == 0 {
45
-			pe.UserId = service.AllService.UserService.FindLatestUserIdFromLoginLogByUuid(pe.Uuid)
45
+			pe.UserId = service.AllService.UserService.FindLatestUserIdFromLoginLogByUuid(pe.Uuid, pe.Id)
46
 		}
46
 		}
47
 		fpe.RowId = pe.RowId
47
 		fpe.RowId = pe.RowId
48
 		fpe.UserId = pe.UserId
48
 		fpe.UserId = pe.UserId

+ 3 - 3
service/user.go

@@ -395,10 +395,10 @@ func (us *UserService) UserThirdInfo(userId uint, op string) *model.UserThird {
395
 	return ut
395
 	return ut
396
 }
396
 }
397
 
397
 
398
-// FindLatestUserIdFromLoginLogByUuid 根据uuid查找最后登录的用户id
399
-func (us *UserService) FindLatestUserIdFromLoginLogByUuid(uuid string) uint {
398
+// FindLatestUserIdFromLoginLogByUuid 根据uuid和设备id查找最后登录的用户id
399
+func (us *UserService) FindLatestUserIdFromLoginLogByUuid(uuid string, deviceId string) uint {
400
 	llog := &model.LoginLog{}
400
 	llog := &model.LoginLog{}
401
-	DB.Where("uuid = ?", uuid).Order("id desc").First(llog)
401
+	DB.Where("uuid = ? and device_id = ?", uuid, deviceId).Order("id desc").First(llog)
402
 	return llog.UserId
402
 	return llog.UserId
403
 }
403
 }
404
 
404