好友申请 如果在好友列表中就删除申请列表中的数据

This commit is contained in:
meixiongfeng 2023-08-25 12:02:19 +08:00
parent cda331e3f1
commit 906cb85fc3

View File

@ -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) {
var (
self *pb.DBFriend
list []*pb.FriendBase
self *pb.DBFriend
list []*pb.FriendBase
bChange bool
bUpdate bool
)
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 {
base := this.setDefaultFriendUserBaseInfo(userId)
if base != nil {
list = append(list, base)
bChange = false
// 如果在还好有列表就删除
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
}
}