更新点赞

This commit is contained in:
wh_zcy 2022-08-18 20:09:22 +08:00
parent 4de5172db3
commit d45f5fdc8a
5 changed files with 42 additions and 26 deletions

View File

@ -78,9 +78,13 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR
//将目标加入黑名单 //将目标加入黑名单
self.BlackIds = append(self.BlackIds, req.FriendId) self.BlackIds = append(self.BlackIds, req.FriendId)
//更新黑名单 // 将目标从好友列表中移除
friendIds := utils.DeleteString(self.FriendIds, req.FriendId)
//更新
err = this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{ err = this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
"blackIds": self.BlackIds, "blackIds": self.BlackIds,
"friendIds": friendIds,
}) })
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError

View File

@ -46,6 +46,7 @@ func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackLis
list = append(list, &pb.FriendBase{ list = append(list, &pb.FriendBase{
UserId: userId, UserId: userId,
NickName: user.Name, NickName: user.Name,
Level: user.Lv,
}) })
} }

View File

@ -62,13 +62,12 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (cod
base.OfflineTime = user.Offlinetime //离线时间 base.OfflineTime = user.Offlinetime //离线时间
} }
// 判断是否在自己的申请列表中
if _, ok := utils.Findx(self.ApplyIds, userId); ok {
base.IsApplied = true
}
// 判断是否已点赞 // 判断是否已点赞
if _, ok := utils.Findx(self.ZanIds, userId); ok { target := this.moduleFriend.modelFriend.GetFriend(userId)
if target == nil {
continue
}
if _, ok := utils.Findx(target.ZanIds, self.Uid); ok {
base.IsZaned = true base.IsZaned = true
} }

View File

@ -37,18 +37,30 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendRandlistR
if _, ok := utils.Findx(self.FriendIds, v.Uid); ok { if _, ok := utils.Findx(self.FriendIds, v.Uid); ok {
continue continue
} }
if _, ok := utils.Findx(self.ApplyIds, v.Uid); ok { // if _, ok := utils.Findx(self.ApplyIds, v.Uid); ok {
continue // continue
} // }
user := this.moduleFriend.ModuleUser.GetUser(v.Uid) user := this.moduleFriend.ModuleUser.GetUser(v.Uid)
if user == nil { if user == nil {
continue continue
} }
userList = append(userList, &pb.FriendBase{
base := &pb.FriendBase{
UserId: user.Uid, UserId: user.Uid,
NickName: user.Name, NickName: user.Name,
Level: user.Lv, Level: user.Lv,
}) }
// 判断是否在自己的申请列表中
target := this.moduleFriend.modelFriend.GetFriend(v.Uid)
if target == nil {
continue
}
if _, ok := utils.Findx(target.ApplyIds, self.Uid); ok {
base.IsApplied = true
}
userList = append(userList, base)
} }
rsp := &pb.FriendRandlistResp{ rsp := &pb.FriendRandlistResp{

View File

@ -38,8 +38,7 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
} }
var ( var (
pointTotal int32 //友情值累加 pointTotal int32 //友情值累加
optIds []string //本次操作的有效id
) )
// 是否已给好友点赞 // 是否已给好友点赞
for _, v := range req.FriendIds { for _, v := range req.FriendIds {
@ -48,18 +47,19 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return
} }
if _, ok := utils.Find(target.ZanIds, selfId); !ok {
optIds = append(optIds, v)
pointTotal += 1
}
}
//设置被点赞玩家 if _, ok := utils.Find(target.ZanIds, selfId); !ok {
if err = this.moduleFriend.modelFriend.Change(target.GetUid(), map[string]interface{}{
"zanIds": optIds, pointTotal += 1
}); err != nil { target.ZanIds = append(target.ZanIds, selfId)
code = pb.ErrorCode_DBError //设置被点赞玩家
return if err = this.moduleFriend.modelFriend.Change(target.GetUid(), map[string]interface{}{
"zanIds": target.ZanIds,
}); err != nil {
code = pb.ErrorCode_DBError
return
}
}
} }
//设置友情值 //设置友情值