Skip to content

Commit

Permalink
fix #55
Browse files Browse the repository at this point in the history
  • Loading branch information
lejianwen committed Nov 9, 2024
1 parent bb8a936 commit 30d254e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions service/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (ps *PeerService) InfoByRowId(id uint) *model.Peer {
}

// FindByUserIdAndUuid 根据用户id和uuid查找peer
func (ps *PeerService) FindByUserIdAndUuid(uuid string,userId uint) *model.Peer {
func (ps *PeerService) FindByUserIdAndUuid(uuid string, userId uint) *model.Peer {
p := &model.Peer{}
global.DB.Where("uuid = ? and user_id = ?", uuid, userId).First(p)
return p
Expand All @@ -42,11 +42,13 @@ func (ps *PeerService) UuidBindUserId(deviceId string, uuid string, userId uint)
ps.Update(peer)
} else {
// 不存在则创建
global.DB.Create(&model.Peer{
Id: deviceId,
Uuid: uuid,
UserId: userId,
})
/*if deviceId != "" {
global.DB.Create(&model.Peer{
Id: deviceId,
Uuid: uuid,
UserId: userId,
})
}*/
}
}

Expand Down Expand Up @@ -143,4 +145,3 @@ func (ps *PeerService) BatchDelete(ids []uint) error {
func (ps *PeerService) Update(u *model.Peer) error {
return global.DB.Model(u).Updates(u).Error
}

0 comments on commit 30d254e

Please sign in to comment.