ljw 1 year ago
parent
commit
4915cfa9ba
1 changed files with 8 additions and 7 deletions
  1. 8 7
      service/peer.go

+ 8 - 7
service/peer.go

@@ -27,7 +27,7 @@ func (ps *PeerService) InfoByRowId(id uint) *model.Peer {
27
 }
27
 }
28
 
28
 
29
 // FindByUserIdAndUuid 根据用户id和uuid查找peer
29
 // FindByUserIdAndUuid 根据用户id和uuid查找peer
30
-func (ps *PeerService) FindByUserIdAndUuid(uuid string,userId uint) *model.Peer {
30
+func (ps *PeerService) FindByUserIdAndUuid(uuid string, userId uint) *model.Peer {
31
 	p := &model.Peer{}
31
 	p := &model.Peer{}
32
 	global.DB.Where("uuid = ? and user_id = ?", uuid, userId).First(p)
32
 	global.DB.Where("uuid = ? and user_id = ?", uuid, userId).First(p)
33
 	return p
33
 	return p
@@ -42,11 +42,13 @@ func (ps *PeerService) UuidBindUserId(deviceId string, uuid string, userId uint)
42
 		ps.Update(peer)
42
 		ps.Update(peer)
43
 	} else {
43
 	} else {
44
 		// 不存在则创建
44
 		// 不存在则创建
45
-		global.DB.Create(&model.Peer{
46
-			Id: 		deviceId,
47
-			Uuid:     	uuid,
48
-			UserId:   	userId,
49
-		})
45
+		/*if deviceId != "" {
46
+			global.DB.Create(&model.Peer{
47
+				Id:     deviceId,
48
+				Uuid:   uuid,
49
+				UserId: userId,
50
+			})
51
+		}*/
50
 	}
52
 	}
51
 }
53
 }
52
 
54
 
@@ -143,4 +145,3 @@ func (ps *PeerService) BatchDelete(ids []uint) error {
143
 func (ps *PeerService) Update(u *model.Peer) error {
145
 func (ps *PeerService) Update(u *model.Peer) error {
144
 	return global.DB.Model(u).Updates(u).Error
146
 	return global.DB.Model(u).Updates(u).Error
145
 }
147
 }
146
-