ljw 1 год назад
Родитель
Сommit
4915cfa9ba
1 измененных файлов с 8 добавлено и 7 удалено
  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 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 31
 	p := &model.Peer{}
32 32
 	global.DB.Where("uuid = ? and user_id = ?", uuid, userId).First(p)
33 33
 	return p
@@ -42,11 +42,13 @@ func (ps *PeerService) UuidBindUserId(deviceId string, uuid string, userId uint)
42 42
 		ps.Update(peer)
43 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 145
 func (ps *PeerService) Update(u *model.Peer) error {
144 146
 	return global.DB.Model(u).Updates(u).Error
145 147
 }
146
-