|
|
@@ -34,11 +34,19 @@ func (ps *PeerService) FindByUserIdAndUuid(uuid string,userId uint) *model.Peer
|
|
34
|
34
|
}
|
|
35
|
35
|
|
|
36
|
36
|
// UuidBindUserId 绑定用户id
|
|
37
|
|
-func (ps *PeerService) UuidBindUserId(uuid string, userId uint) {
|
|
|
37
|
+func (ps *PeerService) UuidBindUserId(deviceId string, uuid string, userId uint) {
|
|
38
|
38
|
peer := ps.FindByUuid(uuid)
|
|
|
39
|
+ // 如果存在则更新
|
|
39
|
40
|
if peer.RowId > 0 {
|
|
40
|
41
|
peer.UserId = userId
|
|
41
|
42
|
ps.Update(peer)
|
|
|
43
|
+ } else {
|
|
|
44
|
+ // 不存在则创建
|
|
|
45
|
+ global.DB.Create(&model.Peer{
|
|
|
46
|
+ Id: deviceId,
|
|
|
47
|
+ Uuid: uuid,
|
|
|
48
|
+ UserId: userId,
|
|
|
49
|
+ })
|
|
42
|
50
|
}
|
|
43
|
51
|
}
|
|
44
|
52
|
|