From 36d3f893c841721648a774e6857be0248eda7228 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 11 Aug 2022 10:40:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=81=8A=E5=A4=A9=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/chat/api_getlist.go | 8 ++++---- modules/chat/modelChat.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/chat/api_getlist.go b/modules/chat/api_getlist.go index eda689c9d..4a5d5d895 100644 --- a/modules/chat/api_getlist.go +++ b/modules/chat/api_getlist.go @@ -24,13 +24,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) ) switch req.Channel { case pb.ChatChannel_World: - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil { code = pb.ErrorCode_DBError return } break case pb.ChatChannel_Union: - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil { code = pb.ErrorCode_DBError return } @@ -50,13 +50,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) code = pb.ErrorCode_ReqParameterError return } - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, req.ChannelId); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), 0, req.ChannelId); err != nil { code = pb.ErrorCode_DBError return } break case pb.ChatChannel_System: - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), 0, 0); err != nil { code = pb.ErrorCode_DBError return } diff --git a/modules/chat/modelChat.go b/modules/chat/modelChat.go index 64f91095b..d9d5c8672 100644 --- a/modules/chat/modelChat.go +++ b/modules/chat/modelChat.go @@ -63,7 +63,7 @@ func (this *modelChatComp) QueryUserMsg(uid string) (result []*pb.DBChat, err er } //查询用户未读消息 -func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, area int32) (result []*pb.DBChat, err error) { +func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union string, area int32) (result []*pb.DBChat, err error) { var ( key string find bson.M @@ -74,15 +74,15 @@ func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, area int3 ) switch channel { case pb.ChatChannel_World: - key = worldchatkey + key = fmt.Sprintf("%s-%s", worldchatkey, stag) find = bson.M{"channel": channel} break case pb.ChatChannel_Union: - key = unionchatkey + key = fmt.Sprintf("%s-%s", unionchatkey, union) find = bson.M{"channel": channel, "unionId": union} break case pb.ChatChannel_CrossServer: - key = fmt.Sprintf("%s:%d", crosschatkey, area) + key = fmt.Sprintf("%s-%d", crosschatkey, area) find = bson.M{"channel": channel, "areaId": area} break case pb.ChatChannel_System: @@ -138,7 +138,7 @@ func (this *modelChatComp) AddCrossChannelMember(session comm.IUserSession) (cha return } for { - key := fmt.Sprintf("%s:%d-member", crosschatkey, channel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) if count, err = this.Redis.Hlen(key); err != nil { this.module.Errorf("err:%v", err) return @@ -167,7 +167,7 @@ func (this *modelChatComp) ChanageChannel(session comm.IUserSession, channel int var ( maxnum int32 ) - key := fmt.Sprintf("%s:%d-member", crosschatkey, channel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) count := 0 if maxnum, err = this.module.configure.GetChanageChannelMax(); err != nil { return @@ -188,7 +188,7 @@ func (this *modelChatComp) ChanageChannel(session comm.IUserSession, channel int //读取跨服聊天频道下成员 func (this *modelChatComp) GetCrossChannelMember(channel int32) (result []*pb.CacheUser, err error) { - key := fmt.Sprintf("%s:%d-member", crosschatkey, channel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) result = make([]*pb.CacheUser, 0) if err = this.Redis.HGetAll(key, &result); err != nil { this.module.Errorf("err:%v", err) @@ -207,7 +207,7 @@ func (this *modelChatComp) RemoveCrossChannelMember(session comm.IUserSession) ( return } - key := fmt.Sprintf("%s:%d-member", crosschatkey, result.Chatchannel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, result.Chatchannel) if err = this.Redis.HDel(key, session.GetUserId()); err != nil { this.module.Errorf("err:%v", err) return