logout should unbind uuid and uid of peer
This commit is contained in:
@@ -26,6 +26,13 @@ func (ps *PeerService) InfoByRowId(id uint) *model.Peer {
|
||||
return p
|
||||
}
|
||||
|
||||
// FindByUserIdAndUuid 根据用户id和uuid查找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
|
||||
}
|
||||
|
||||
// UuidBindUserId 绑定用户id
|
||||
func (ps *PeerService) UuidBindUserId(uuid string, userId uint) {
|
||||
peer := ps.FindByUuid(uuid)
|
||||
@@ -35,6 +42,14 @@ func (ps *PeerService) UuidBindUserId(uuid string, userId uint) {
|
||||
}
|
||||
}
|
||||
|
||||
// UuidUnbindUserId 解绑用户id, 用于用户注销
|
||||
func (ps *PeerService) UuidUnbindUserId(uuid string, userId uint) {
|
||||
peer := ps.FindByUserIdAndUuid(uuid, userId)
|
||||
if peer.RowId > 0 {
|
||||
global.DB.Model(peer).Update("user_id", 0)
|
||||
}
|
||||
}
|
||||
|
||||
// ListByUserIds 根据用户id取列表
|
||||
func (ps *PeerService) ListByUserIds(userIds []uint, page, pageSize uint) (res *model.PeerList) {
|
||||
res = &model.PeerList{}
|
||||
|
||||
Reference in New Issue
Block a user