好友申请 如果在好友列表中就删除申请列表中的数据
This commit is contained in:
parent
cda331e3f1
commit
906cb85fc3
@ -13,8 +13,10 @@ func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.FriendApp
|
|||||||
|
|
||||||
func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyListReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyListReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
list []*pb.FriendBase
|
list []*pb.FriendBase
|
||||||
|
bChange bool
|
||||||
|
bUpdate bool
|
||||||
)
|
)
|
||||||
|
|
||||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
@ -27,9 +29,34 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, userId := range self.ApplyIds {
|
for _, userId := range self.ApplyIds {
|
||||||
base := this.setDefaultFriendUserBaseInfo(userId)
|
bChange = false
|
||||||
if base != nil {
|
// 如果在还好有列表就删除
|
||||||
list = append(list, base)
|
for pos, v := range self.FriendIds {
|
||||||
|
if v == userId { // 找到了
|
||||||
|
self.FriendIds = append(self.FriendIds[:pos], self.FriendIds[pos+1:]...)
|
||||||
|
bChange = true
|
||||||
|
bUpdate = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !bChange {
|
||||||
|
base := this.setDefaultFriendUserBaseInfo(userId)
|
||||||
|
if base != nil {
|
||||||
|
list = append(list, base)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if bUpdate { // 更新数据
|
||||||
|
if err := this.module.modelFriend.Change(self.Uid, map[string]interface{}{
|
||||||
|
"friendIds": self.FriendIds,
|
||||||
|
}); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user