From 747b963bd4c5bbe65112acaeee5ef486ff6bcae2 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Sat, 7 May 2022 11:14:29 +0800 Subject: [PATCH 1/8] cache --- config/config.yaml | 4 +- internal/msg_gateway/gate/validate.go | 137 ------------------------- internal/rpc/group/group.go | 138 +++++++++++++++++++++----- internal/rpc/msg/callback.go | 1 + pkg/common/config/config.go | 2 +- 5 files changed, 118 insertions(+), 164 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 61cef4251..dcd0f4212 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -143,8 +143,8 @@ rpcregistername: #rpc注册服务名,默认即可 openImOnlineMessageRelayName: OnlineMessageRelay openImGroupName: Group openImAuthName: Auth - OpenImStatisticsName: Statistics - OpenImMessageCMSName: MessageCMS + openImStatisticsName: Statistics + openImMessageCMSName: MessageCMS openImAdminCMSName: AdminCMS openImOfficeName: Office openImOrganizationName: Organization diff --git a/internal/msg_gateway/gate/validate.go b/internal/msg_gateway/gate/validate.go index 329f93655..35bc34f0e 100644 --- a/internal/msg_gateway/gate/validate.go +++ b/internal/msg_gateway/gate/validate.go @@ -114,140 +114,3 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er //} else } - -//func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) { -// var msg open_im_sdk.MsgData -// var resp open_im_sdk.SignalResp -// media := open_im_media.NewMedia() -// msg.MsgFrom = constant.UserMsgType -// msg.ContentType = constant.SignalingNotification -// reqData, e := proto.Marshal(s) -// if e != nil { -// return false, 201, e.Error(), nil, nil -// } -// msg.Content = reqData -// msg.CreateTime = utils.GetCurrentTimestampByMill() -// options := make(map[string]bool, 6) -// utils.SetSwitchFromOptions(options, constant.IsHistory, false) -// utils.SetSwitchFromOptions(options, constant.IsPersistent, false) -// utils.SetSwitchFromOptions(options, constant.IsSenderSync, true) -// utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false) -// utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false) -// utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false) -// utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true) -// msg.Options = options -// switch payload := s.Payload.(type) { -// case *open_im_sdk.SignalReq_Invite: -// token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant) -// if err2 != nil { -// return false, 202, err2.Error(), nil, nil -// } -// invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{ -// Token: token, -// RoomID: payload.Invite.Invitation.RoomID, -// LiveURL: liveURL, -// }} -// resp.Payload = &invite -// msg.SenderPlatformID = payload.Invite.Invitation.PlatformID -// msg.SessionType = payload.Invite.Invitation.SessionType -// msg.OfflinePushInfo = payload.Invite.OfflinePushInfo -// msg.SendID = payload.Invite.Invitation.InviterUserID -// if len(payload.Invite.Invitation.InviteeUserIDList) > 0 { -// msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0] -// } else { -// return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID) -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_InviteInGroup: -// token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant) -// if err2 != nil { -// return false, 204, err2.Error(), nil, nil -// } -// inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{ -// RoomID: payload.InviteInGroup.Invitation.RoomID, -// Token: token, -// LiveURL: liveURL, -// }} -// resp.Payload = &inviteGroup -// msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID -// msg.SessionType = payload.InviteInGroup.Invitation.SessionType -// msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo -// msg.SendID = payload.InviteInGroup.Invitation.InviterUserID -// if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 { -// msg.GroupID = payload.InviteInGroup.Invitation.GroupID -// } else { -// return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID) -// -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_Cancel: -// cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}} -// resp.Payload = &cancel -// msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo -// msg.SendID = payload.Cancel.Invitation.InviterUserID -// msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID -// msg.SessionType = payload.Cancel.Invitation.SessionType -// if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 { -// switch payload.Cancel.Invitation.SessionType { -// case constant.SingleChatType: -// msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0] -// case constant.GroupChatType: -// msg.GroupID = payload.Cancel.Invitation.GroupID -// } -// } else { -// return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID) -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_Accept: -// token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant) -// if err2 != nil { -// return false, 207, err2.Error(), nil, nil -// } -// accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{ -// Token: token, -// LiveURL: liveURL, -// RoomID: payload.Accept.Invitation.RoomID, -// }} -// resp.Payload = &accept -// msg.OfflinePushInfo = payload.Accept.OfflinePushInfo -// msg.SendID = payload.Accept.OpUserID -// msg.SenderPlatformID = payload.Accept.Invitation.PlatformID -// msg.SessionType = payload.Accept.Invitation.SessionType -// if len(payload.Accept.Invitation.InviteeUserIDList) > 0 { -// switch payload.Accept.Invitation.SessionType { -// case constant.SingleChatType: -// msg.RecvID = payload.Accept.Invitation.InviterUserID -// case constant.GroupChatType: -// msg.GroupID = payload.Accept.Invitation.GroupID -// } -// } else { -// return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID) -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_HungUp: -// case *open_im_sdk.SignalReq_Reject: -// reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}} -// resp.Payload = &reject -// msg.OfflinePushInfo = payload.Reject.OfflinePushInfo -// msg.SendID = payload.Reject.OpUserID -// msg.SenderPlatformID = payload.Reject.Invitation.PlatformID -// msg.SessionType = payload.Reject.Invitation.SessionType -// if len(payload.Reject.Invitation.InviteeUserIDList) > 0 { -// switch payload.Reject.Invitation.SessionType { -// case constant.SingleChatType: -// msg.RecvID = payload.Reject.Invitation.InviterUserID -// case constant.GroupChatType: -// msg.GroupID = payload.Reject.Invitation.GroupID -// } -// } else { -// return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID) -// return true, 0, "", &resp, &msg -// } -// return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil -//} diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 7d59640d5..c8beb8a00 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -11,6 +11,7 @@ import ( "Open_IM/pkg/common/token_verify" cp "Open_IM/pkg/common/utils" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbCache "Open_IM/pkg/proto/cache" pbGroup "Open_IM/pkg/proto/group" open_im_sdk "Open_IM/pkg/proto/sdk_ws" pbUser "Open_IM/pkg/proto/user" @@ -136,12 +137,12 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } okUserIDList = append(okUserIDList, user.UserID) - err = db.DB.AddGroupMember(groupId, user.UserID) - if err != nil { - log.NewError(req.OperationID, "add mongo group member failed, db.DB.AddGroupMember failed ", err.Error()) - } + // mongoDB method + //err = db.DB.AddGroupMember(groupId, user.UserID) + //if err != nil { + // log.NewError(req.OperationID, "add mongo group member failed, db.DB.AddGroupMember failed ", err.Error()) + //} } - resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}} group, err := imdb.GetGroupInfoByGroupID(groupId) if err != nil { @@ -160,8 +161,24 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } resp.GroupInfo.OwnerUserID = req.OwnerUserID - log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String()) + addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{ + UserIDList: okUserIDList, + GroupID: req.GroupInfo.GroupID, + OperationID: req.OperationID, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) + if err != nil { + log.NewError(req.OperationID, "AddBlackUserToCache rpc call failed ", err.Error()) + return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "AddBlackUserToCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String()) chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList) return resp, nil } @@ -307,6 +324,24 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v) } } + + addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{ + UserIDList: okUserIDList, + GroupID: req.GroupID, + OperationID: req.OperationID, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) + if err != nil { + log.NewError(req.OperationID, "AddBlackUserToCache rpc call failed ", err.Error()) + return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "AddBlackUserToCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, req.Reason, okUserIDList) resp.ErrCode = 0 log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp.String()) @@ -450,6 +485,24 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v) } } + + reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ + UserIDList: okUserIDList, + GroupID: req.GroupID, + OperationID: req.OperationID, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) + if err != nil { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error()) + return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + chat.MemberKickedNotification(req, okUserIDList) log.NewInfo(req.OperationID, "GetGroupMemberList rpc return ", resp.String()) return &resp, nil @@ -691,22 +744,24 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) } else { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String()) } - //reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ - // UserIDList: []string{req.OpUserID}, - // GroupID: req.GroupID, - // OperationID: req.OperationID, - //} - //etcdConn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) - //cacheClient := pbCache.NewCacheClient(etcdConn) - //respCachePb, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) - //if err != nil { - // log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error(), reduceGroupMemberFromCacheReq.String()) - // return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrServer.ErrCode, ErrMsg: constant.ErrServer.ErrMsg}}, nil - //} - //if respPb.CommonResp.ErrCode != 0 { - // log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", reduceGroupMemberFromCacheReq.String()) - // return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode:respCachePb.CommonResp.ErrCode, ErrMsg: respCachePb.CommonResp.ErrMsg}}, nil - //} + + reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ + UserIDList: []string{req.OpUserID}, + GroupID: req.GroupID, + OperationID: req.OperationID, + } + etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConnCache) + cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) + if err != nil { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error()) + return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil + } + chat.MemberQuitNotification(req) log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}) return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil @@ -1047,9 +1102,26 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v) } } + + reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ + UserIDList: resp.Success, + GroupID: req.GroupId, + OperationID: req.OperationID, + } + etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConnCache) + cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) + if err != nil { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error()) + return resp, http.WrapError(constant.ErrDB) + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String()) + return resp, http.WrapError(constant.ErrDB) + } + chat.MemberKickedNotification(reqKick, resp.Success) - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "success: ", resp.Success) - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "failed: ", resp.Failed) + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp) return resp, nil } @@ -1086,6 +1158,24 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou resp.Success = append(resp.Success, userId) } } + + addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{ + UserIDList: resp.Success, + GroupID: req.GroupId, + OperationID: req.OperationId, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) + if err != nil { + log.NewError(req.OperationId, "AddBlackUserToCache rpc call failed ", err.Error()) + return resp, http.WrapError(constant.ErrDB) + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationId, "AddBlackUserToCache rpc logic call failed ", cacheResp.String()) + return resp, http.WrapError(constant.ErrDB) + } + chat.MemberInvitedNotification(req.OperationId, req.GroupId, req.OpUserId, "admin add you to group", resp.Success) return resp, nil } diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index bb8ccd700..452846799 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -31,6 +31,7 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (canSend bool, err erro if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable { return true, nil } + log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) commonCallbackReq := copyCallbackCommonReqStruct(msg) commonCallbackReq.CallbackCommand = constant.CallbackBeforeSendSingleMsgCommand diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index bd4998335..5b8dff44b 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -106,7 +106,7 @@ type config struct { RpcGetTokenPort []int `yaml:"rpcGetTokenPort"` } RpcRegisterName struct { - OpenImStatisticsName string `yaml:"OpenImStatisticsName"` + OpenImStatisticsName string `yaml:"openImStatisticsName"` OpenImUserName string `yaml:"openImUserName"` OpenImFriendName string `yaml:"openImFriendName"` OpenImOfflineMessageName string `yaml:"openImOfflineMessageName"` From bbc3f5c19ac3e816659add49ac3c2337b249ae6b Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Sat, 7 May 2022 11:39:27 +0800 Subject: [PATCH 2/8] cache --- internal/rpc/msg/send_msg.go | 46 +++++++++++++++++++++--------------- pkg/common/db/redisModel.go | 4 ++-- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 013a32bd3..1c297c3e5 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -7,6 +7,7 @@ import ( "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" cacheRpc "Open_IM/pkg/proto/cache" + pbCache "Open_IM/pkg/proto/cache" pbChat "Open_IM/pkg/proto/chat" pbConversation "Open_IM/pkg/proto/conversation" pbGroup "Open_IM/pkg/proto/group" @@ -216,28 +217,35 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg result", canSend, "end rpc and return") return returnMsg(&replay, pb, 201, "callbackBeforeSendGroupMsg result stop rpc and return", "", 0) } - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) - client := pbGroup.NewGroupClient(etcdConn) - req := &pbGroup.GetGroupAllMemberReq{ - GroupID: pb.MsgData.GroupID, - OperationID: pb.OperationID, - } - reply, err := client.GetGroupAllMember(context.Background(), req) + //etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + //client := pbGroup.NewGroupClient(etcdConn) + //req := &pbGroup.GetGroupAllMemberReq{ + // GroupID: pb.MsgData.GroupID, + // OperationID: pb.OperationID, + //} + //reply, err := client.GetGroupAllMember(context.Background(), req) + //if err != nil { + // log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error()) + // return returnMsg(&replay, pb, 201, err.Error(), "", 0) + //} + //if reply.ErrCode != 0 { + // log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrMsg) + // return returnMsg(&replay, pb, reply.ErrCode, reply.ErrMsg, "", 0) + //} + getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pb.OperationID, GroupID: pb.MsgData.GroupID} + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + client := pbCache.NewCacheClient(etcdConn) + cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq) if err != nil { - log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error()) - return returnMsg(&replay, pb, 201, err.Error(), "", 0) + log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error()) + return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache failed", "", 0) } - if reply.ErrCode != 0 { - log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrMsg) - return returnMsg(&replay, pb, reply.ErrCode, reply.ErrMsg, "", 0) + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String()) + return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache logic failed", "", 0) } - memberUserIDList := func(all []*sdk_ws.GroupMemberFullInfo) (result []string) { - for _, v := range all { - result = append(result, v.UserID) - } - return result - }(reply.MemberList) - log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList) + memberUserIDList := cacheResp.UserIDList + log.Debug(pb.OperationID, "GetGroupAllMember userID list", cacheResp.UserIDList) var addUidList []string switch pb.MsgData.ContentType { case constant.MemberKickedNotification: diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index d39e2a57d..9996ea356 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -233,7 +233,7 @@ func (d *DataBases) AddGroupMemberToCache(groupID string, userIDList ...string) for _, id := range userIDList { IDList = append(IDList, id) } - _, err := d.Exec("SADD", blackListCache+groupID, IDList...) + _, err := d.Exec("SADD", groupCache+groupID, IDList...) return err } @@ -242,7 +242,7 @@ func (d *DataBases) ReduceGroupMemberFromCache(groupID string, userIDList ...str for _, id := range userIDList { IDList = append(IDList, id) } - _, err := d.Exec("SREM", blackListCache+groupID, IDList...) + _, err := d.Exec("SREM", groupCache+groupID, IDList...) return err } From 65a4b38ee52014bcab65b92c8318c0bc80546802 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Sat, 7 May 2022 11:42:47 +0800 Subject: [PATCH 3/8] cache --- internal/rpc/group/group.go | 8 ++++---- internal/rpc/msg/send_msg.go | 16 ---------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index c8beb8a00..4266631f8 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -170,11 +170,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR cacheClient := pbCache.NewCacheClient(etcdConn) cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) if err != nil { - log.NewError(req.OperationID, "AddBlackUserToCache rpc call failed ", err.Error()) + log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error()) return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil } if cacheResp.CommonResp.ErrCode != 0 { - log.NewError(req.OperationID, "AddBlackUserToCache rpc logic call failed ", cacheResp.String()) + log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String()) return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil } @@ -334,11 +334,11 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite cacheClient := pbCache.NewCacheClient(etcdConn) cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) if err != nil { - log.NewError(req.OperationID, "AddBlackUserToCache rpc call failed ", err.Error()) + log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error()) return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil } if cacheResp.CommonResp.ErrCode != 0 { - log.NewError(req.OperationID, "AddBlackUserToCache rpc logic call failed ", cacheResp.String()) + log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String()) return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil } diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 1c297c3e5..b8af3b145 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -10,7 +10,6 @@ import ( pbCache "Open_IM/pkg/proto/cache" pbChat "Open_IM/pkg/proto/chat" pbConversation "Open_IM/pkg/proto/conversation" - pbGroup "Open_IM/pkg/proto/group" sdk_ws "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" @@ -217,21 +216,6 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg result", canSend, "end rpc and return") return returnMsg(&replay, pb, 201, "callbackBeforeSendGroupMsg result stop rpc and return", "", 0) } - //etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) - //client := pbGroup.NewGroupClient(etcdConn) - //req := &pbGroup.GetGroupAllMemberReq{ - // GroupID: pb.MsgData.GroupID, - // OperationID: pb.OperationID, - //} - //reply, err := client.GetGroupAllMember(context.Background(), req) - //if err != nil { - // log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error()) - // return returnMsg(&replay, pb, 201, err.Error(), "", 0) - //} - //if reply.ErrCode != 0 { - // log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrMsg) - // return returnMsg(&replay, pb, reply.ErrCode, reply.ErrMsg, "", 0) - //} getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pb.OperationID, GroupID: pb.MsgData.GroupID} etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) client := pbCache.NewCacheClient(etcdConn) From bb07c3ab459f2a941f7421854104f1d99416554c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Sat, 7 May 2022 11:55:19 +0800 Subject: [PATCH 4/8] add err log --- internal/api/auth/auth.go | 4 +- internal/api/friend/friend.go | 150 +++++++------- internal/api/group/group.go | 190 ++++++++++++------ internal/api/manage/management_user.go | 39 ++-- internal/api/office/tag.go | 84 ++++++-- internal/api/office/work_moments.go | 106 +++++++--- .../api/third/minio_storage_credential.go | 22 +- .../third/tencent_cloud_storage_credential.go | 12 +- internal/api/user/user.go | 69 +++++-- pkg/common/token_verify/jwt_token.go | 6 +- 10 files changed, 458 insertions(+), 224 deletions(-) diff --git a/internal/api/auth/auth.go b/internal/api/auth/auth.go index 682ba4c30..ea01a6944 100644 --- a/internal/api/auth/auth.go +++ b/internal/api/auth/auth.go @@ -38,13 +38,13 @@ func UserRegister(c *gin.Context) { client := rpc.NewAuthClient(etcdConn) reply, err := client.UserRegister(context.Background(), req) if err != nil { - errMsg := req.OperationID + " " + "client.UserRegister failed " + err.Error() + req.String() + errMsg := req.OperationID + " " + "UserRegister failed " + err.Error() + req.String() log.NewError(req.OperationID, errMsg) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } if reply.CommonResp.ErrCode != 0 { - errMsg := req.OperationID + " " + " client.UserRegister failed " + reply.CommonResp.ErrMsg + req.String() + errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String() log.NewError(req.OperationID, errMsg) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return diff --git a/internal/api/friend/friend.go b/internal/api/friend/friend.go index 054878c0c..58cf37f7f 100644 --- a/internal/api/friend/friend.go +++ b/internal/api/friend/friend.go @@ -26,10 +26,12 @@ func AddBlack(c *gin.Context) { req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } log.NewInfo(params.OperationID, "AddBlacklist args ", req.String()) @@ -57,12 +59,15 @@ func ImportFriend(c *gin.Context) { req := &rpc.ImportFriendReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "ImportFriend args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -96,13 +101,17 @@ func AddFriend(c *gin.Context) { req := &rpc.AddFriendReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) req.ReqMsg = params.ReqMsg + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -130,13 +139,17 @@ func AddFriendResponse(c *gin.Context) { utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) req.HandleMsg = params.HandleMsg req.HandleResult = params.Flag + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + utils.CopyStructFields(req, ¶ms) log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String()) @@ -163,13 +176,17 @@ func DeleteFriend(c *gin.Context) { } req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -195,13 +212,17 @@ func GetBlacklist(c *gin.Context) { } req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -234,13 +255,17 @@ func SetFriendRemark(c *gin.Context) { req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) req.Remark = params.Remark + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -266,11 +291,14 @@ func RemoveBlack(c *gin.Context) { } req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } @@ -297,13 +325,17 @@ func IsFriend(c *gin.Context) { } req := &rpc.IsFriendReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -321,40 +353,6 @@ func IsFriend(c *gin.Context) { c.JSON(http.StatusOK, resp) } -// -//func GetFriendsInfo(c *gin.Context) { -// params := api.GetFriendsInfoReq{} -// if err := c.BindJSON(¶ms); err != nil { -// log.NewError("0", "BindJSON failed ", err.Error()) -// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) -// return -// } -// req := &rpc.GetFriendsInfoReq{} -// utils.CopyStructFields(req.CommID, params) -// var ok bool -// ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) -// if !ok { -// log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) -// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) -// return -// } -// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String()) -// -// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) -// client := rpc.NewFriendClient(etcdConn) -// RpcResp, err := client.GetFriendsInfo(context.Background(), req) -// if err != nil { -// log.NewError(req.CommID.OperationID, "GetFriendsInfo failed ", err.Error(), req.String()) -// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"}) -// return -// } -// -// resp := api.GetFriendsInfoResp{CommResp:api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} -// utils.CopyStructFields(&resp, RpcResp) -// c.JSON(http.StatusOK, resp) -// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo api return ", resp) -//} - func GetFriendList(c *gin.Context) { params := api.GetFriendListReq{} if err := c.BindJSON(¶ms); err != nil { @@ -364,13 +362,17 @@ func GetFriendList(c *gin.Context) { } req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -398,13 +400,17 @@ func GetFriendApplyList(c *gin.Context) { } req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) @@ -432,13 +438,17 @@ func GetSelfFriendApplyList(c *gin.Context) { } req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) + var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) + var errInfo string + ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { - log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.CommID.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) diff --git a/internal/api/group/group.go b/internal/api/group/group.go index aee3c4b58..598f3f473 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -29,11 +29,14 @@ func KickGroupMember(c *gin.Context) { req := &rpc.KickGroupMemberReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } @@ -71,14 +74,17 @@ func GetGroupMembersInfo(c *gin.Context) { } req := &rpc.GetGroupMembersInfoReq{} utils.CopyStructFields(req, params) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - //c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) - api.SetErrCodeMsg(c, http.StatusInternalServerError) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -106,13 +112,17 @@ func GetGroupMemberList(c *gin.Context) { } req := &rpc.GetGroupMemberListReq{} utils.CopyStructFields(req, params) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -141,13 +151,17 @@ func GetGroupAllMemberList(c *gin.Context) { } req := &rpc.GetGroupAllMemberReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -174,13 +188,17 @@ func GetJoinedGroupList(c *gin.Context) { } req := &rpc.GetJoinedGroupListReq{} utils.CopyStructFields(req, params) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -207,13 +225,17 @@ func InviteUserToGroup(c *gin.Context) { } req := &rpc.InviteUserToGroupReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -252,13 +274,17 @@ func CreateGroup(c *gin.Context) { for _, v := range params.MemberList { req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel}) } + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + req.OwnerUserID = params.OwnerUserID req.OperationID = params.OperationID log.NewInfo(req.OperationID, "CreateGroup args ", req.String()) @@ -355,13 +381,17 @@ func GetGroupsInfo(c *gin.Context) { } req := &rpc.GetGroupsInfoReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) client := rpc.NewGroupClient(etcdConn) @@ -388,13 +418,17 @@ func ApplicationGroupResponse(c *gin.Context) { } req := &rpc.GroupApplicationResponseReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -420,13 +454,17 @@ func JoinGroup(c *gin.Context) { } req := &rpc.JoinGroupReq{} utils.CopyStructFields(req, params) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "JoinGroup args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) client := rpc.NewGroupClient(etcdConn) @@ -451,13 +489,17 @@ func QuitGroup(c *gin.Context) { } req := &rpc.QuitGroupReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "QuitGroup args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -483,13 +525,17 @@ func SetGroupInfo(c *gin.Context) { req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}} utils.CopyStructFields(req.GroupInfo, ¶ms) req.OperationID = params.OperationID + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -514,13 +560,17 @@ func TransferGroupOwner(c *gin.Context) { } req := &rpc.TransferGroupOwnerReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -546,13 +596,17 @@ func DismissGroup(c *gin.Context) { } req := &rpc.DismissGroupReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -578,13 +632,17 @@ func MuteGroupMember(c *gin.Context) { } req := &rpc.MuteGroupMemberReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -610,13 +668,17 @@ func CancelMuteGroupMember(c *gin.Context) { } req := &rpc.CancelMuteGroupMemberReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -642,13 +704,17 @@ func MuteGroup(c *gin.Context) { } req := &rpc.MuteGroupReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -674,13 +740,17 @@ func CancelMuteGroup(c *gin.Context) { } req := &rpc.CancelMuteGroupReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) @@ -708,13 +778,17 @@ func SetGroupMemberNickname(c *gin.Context) { } req := &rpc.SetGroupMemberNicknameReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) diff --git a/internal/api/manage/management_user.go b/internal/api/manage/management_user.go index 6fca39732..6fc9d161d 100644 --- a/internal/api/manage/management_user.go +++ b/internal/api/manage/management_user.go @@ -30,13 +30,17 @@ func DeleteUser(c *gin.Context) { } req := &rpc.DeleteUsersReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(params.OperationID, "DeleteUser args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) client := rpc.NewUserClient(etcdConn) @@ -62,13 +66,17 @@ func GetAllUsersUid(c *gin.Context) { } req := &rpc.GetAllUserIDReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) client := rpc.NewUserClient(etcdConn) @@ -94,13 +102,17 @@ func AccountCheck(c *gin.Context) { } req := &rpc.AccountCheckReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(params.OperationID, "AccountCheck args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) client := rpc.NewUserClient(etcdConn) @@ -127,11 +139,14 @@ func GetUsersOnlineStatus(c *gin.Context) { } req := &pbRelay.GetUsersOnlineStatusReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } diff --git a/internal/api/office/tag.go b/internal/api/office/tag.go index 2471ddd87..630517593 100644 --- a/internal/api/office/tag.go +++ b/internal/api/office/tag.go @@ -27,12 +27,18 @@ func GetUserTags(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) return } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.UserID = userID reqPb.OperationID = req.OperationID etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) @@ -69,12 +75,18 @@ func CreateTag(c *gin.Context) { if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.UserID = userID etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) client := pbOffice.NewOfficeServiceClient(etcdConn) @@ -105,12 +117,18 @@ func DeleteTag(c *gin.Context) { if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.UserID = userID etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) client := pbOffice.NewOfficeServiceClient(etcdConn) @@ -141,12 +159,18 @@ func SetTag(c *gin.Context) { if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.UserID = userID etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) client := pbOffice.NewOfficeServiceClient(etcdConn) @@ -177,12 +201,18 @@ func SendMsg2Tag(c *gin.Context) { if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.SendID = userID etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) client := pbOffice.NewOfficeServiceClient(etcdConn) @@ -210,12 +240,18 @@ func GetTagSendLogs(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) return } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.UserID = userID reqPb.OperationID = req.OperationID reqPb.Pagination = &pbCommon.RequestPagination{ @@ -255,12 +291,18 @@ func GetUserTagByID(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) return } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.UserID = userID reqPb.OperationID = req.OperationID reqPb.TagID = req.TagID diff --git a/internal/api/office/work_moments.go b/internal/api/office/work_moments.go index 46d5eb9dd..82716a4f8 100644 --- a/internal/api/office/work_moments.go +++ b/internal/api/office/work_moments.go @@ -28,12 +28,18 @@ func CreateOneWorkMoment(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } @@ -67,12 +73,18 @@ func DeleteOneWorkMoment(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } @@ -105,12 +117,18 @@ func LikeOneWorkMoment(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } @@ -143,12 +161,18 @@ func CommentOneWorkMoment(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } @@ -184,13 +208,17 @@ func DeleteComment(c *gin.Context) { if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), err.Error()) } + var ok bool - ok, reqPb.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) client := pbOffice.NewOfficeServiceClient(etcdConn) respPb, err := client.DeleteComment(context.Background(), &reqPb) @@ -219,12 +247,18 @@ func GetWorkMomentByID(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.OperationID = req.OperationID reqPb.OpUserID = userID reqPb.WorkMomentID = req.WorkMomentID @@ -261,12 +295,18 @@ func GetUserWorkMoments(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, opUserID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var opUserID string + ok, opUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.OperationID = req.OperationID reqPb.Pagination = &pbCommon.RequestPagination{ PageNumber: req.PageNumber, @@ -353,12 +393,18 @@ func GetUserFriendWorkMoments(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + reqPb.OperationID = req.OperationID reqPb.Pagination = &pbCommon.RequestPagination{ PageNumber: req.PageNumber, @@ -444,12 +490,18 @@ func SetUserWorkMomentsLevel(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + var userID string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + if err := utils.CopyStructFields(&reqPb, req); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } diff --git a/internal/api/third/minio_storage_credential.go b/internal/api/third/minio_storage_credential.go index f9f4c078d..3df001e18 100644 --- a/internal/api/third/minio_storage_credential.go +++ b/internal/api/third/minio_storage_credential.go @@ -33,12 +33,17 @@ func MinioUploadFile(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req) switch req.FileType { // videoType upload snapShot @@ -101,12 +106,17 @@ func MinioStorageCredential(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var errInfo string + ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + var stsOpts cr.STSAssumeRoleOptions stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey diff --git a/internal/api/third/tencent_cloud_storage_credential.go b/internal/api/third/tencent_cloud_storage_credential.go index ed293791e..871d92ae0 100644 --- a/internal/api/third/tencent_cloud_storage_credential.go +++ b/internal/api/third/tencent_cloud_storage_credential.go @@ -22,12 +22,18 @@ func TencentCloudStorageCredential(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var userID string + var errInfo string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID) cli := sts.NewClient( diff --git a/internal/api/user/user.go b/internal/api/user/user.go index 41042099e..f9bb9cdae 100644 --- a/internal/api/user/user.go +++ b/internal/api/user/user.go @@ -28,13 +28,17 @@ func GetUsersInfoFromCache(c *gin.Context) { } req := &rpc.GetUserInfoReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(params.OperationID, "GetUserInfo args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) @@ -174,13 +178,17 @@ func GetFriendIDListFromCache(c *gin.Context) { return } reqPb.OperationID = req.OperationID + var ok bool - ok, reqPb.UserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) client := cacheRpc.NewCacheClient(etcdConn) respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb) @@ -207,13 +215,17 @@ func GetBlackIDListFromCache(c *gin.Context) { return } reqPb.OperationID = req.OperationID + var ok bool - ok, reqPb.UserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) client := cacheRpc.NewCacheClient(etcdConn) respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb) @@ -236,13 +248,17 @@ func GetUsersInfo(c *gin.Context) { } req := &rpc.GetUserInfoReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(params.OperationID, "GetUserInfo args ", req.String()) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) @@ -274,13 +290,14 @@ func UpdateUserInfo(c *gin.Context) { } req := &rpc.UpdateUserInfoReq{UserInfo: &open_im_sdk.UserInfo{}} utils.CopyStructFields(req.UserInfo, ¶ms) - req.OperationID = params.OperationID var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String()) @@ -308,13 +325,17 @@ func GetSelfUserInfo(c *gin.Context) { req := &rpc.GetUserInfoReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + req.UserIDList = append(req.UserIDList, req.OpUserID) log.NewInfo(params.OperationID, "GetUserInfo args ", req.String()) @@ -347,13 +368,17 @@ func GetUsersOnlineStatus(c *gin.Context) { } req := &pbRelay.GetUsersOnlineStatusReq{} utils.CopyStructFields(req, ¶ms) + var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + var errInfo string + ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + if len(config.Config.Manager.AppManagerUid) == 0 { log.NewError(req.OperationID, "Manager == 0") c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"}) diff --git a/pkg/common/token_verify/jwt_token.go b/pkg/common/token_verify/jwt_token.go index 876f4e847..162283f87 100644 --- a/pkg/common/token_verify/jwt_token.go +++ b/pkg/common/token_verify/jwt_token.go @@ -129,13 +129,13 @@ func CheckAccess(OpUserID string, OwnerUserID string) bool { return false } -func GetUserIDFromToken(token string, operationID string) (bool, string) { +func GetUserIDFromToken(token string, operationID string) (bool, string, string) { claims, err := ParseToken(token, operationID) if err != nil { log.Error(operationID, "ParseToken failed, ", err.Error(), token) - return false, "" + return false, "", err.Error() } - return true, claims.UID + return true, claims.UID, "" } func ParseTokenGetUserID(token string, operationID string) (error, string) { From f2c91d015edcd1c8f77d8fb531cc16f06475457f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Sat, 7 May 2022 12:01:01 +0800 Subject: [PATCH 5/8] add err log --- internal/api/third/ali_oss_credential.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/api/third/ali_oss_credential.go b/internal/api/third/ali_oss_credential.go index 6f5bc7c04..0602143e8 100644 --- a/internal/api/third/ali_oss_credential.go +++ b/internal/api/third/ali_oss_credential.go @@ -54,12 +54,18 @@ func AliOSSCredential(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + + var ok bool + var userID string + var errInfo string + ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { - log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) return } + log.NewInfo(req.OperationID, "AliOSSCredential args ", userID) stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{ From fed369ad5dd7b1a74b394af1c964aed0ee10889d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Sat, 7 May 2022 12:04:07 +0800 Subject: [PATCH 6/8] add err log --- internal/cms_api/middleware/jwt_auth.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/cms_api/middleware/jwt_auth.go b/internal/cms_api/middleware/jwt_auth.go index a6f1af993..255e3eaaf 100644 --- a/internal/cms_api/middleware/jwt_auth.go +++ b/internal/cms_api/middleware/jwt_auth.go @@ -11,14 +11,16 @@ import ( func JWTAuth() gin.HandlerFunc { return func(c *gin.Context) { - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "") + ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "") log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID) c.Set("userID", userID) if !ok { - log.NewError("","GetUserIDFromToken false ", c.Request.Header.Get("token")) + log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.Abort() http.RespHttp200(c, constant.ErrParseToken, nil) return + } else { + log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo) } } } From 4ac863fa6a8d2f245bdfa77c117af27f95598a64 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Sat, 7 May 2022 13:21:05 +0800 Subject: [PATCH 7/8] cache --- internal/rpc/group/group.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 4266631f8..48916fb5a 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -161,9 +161,10 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } resp.GroupInfo.OwnerUserID = req.OwnerUserID + okUserIDList = append(okUserIDList, req.OwnerUserID) addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{ UserIDList: okUserIDList, - GroupID: req.GroupInfo.GroupID, + GroupID: groupId, OperationID: req.OperationID, } etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) From 685fc1a37b572856c0f9cd9ecdfb541042e9c375 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Sat, 7 May 2022 14:13:47 +0800 Subject: [PATCH 8/8] cache --- internal/rpc/cache/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rpc/cache/cache.go b/internal/rpc/cache/cache.go index 5fb32a2d3..b787459eb 100644 --- a/internal/rpc/cache/cache.go +++ b/internal/rpc/cache/cache.go @@ -327,7 +327,7 @@ func (s *cacheServer) AddGroupMemberToCache(_ context.Context, req *pbCache.AddG func (s *cacheServer) ReduceGroupMemberFromCache(_ context.Context, req *pbCache.ReduceGroupMemberFromCacheReq) (resp *pbCache.ReduceGroupMemberFromCacheResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) - resp = &pbCache.ReduceGroupMemberFromCacheResp{} + resp = &pbCache.ReduceGroupMemberFromCacheResp{CommonResp: &pbCache.CommonResp{}} if err := db.DB.ReduceGroupMemberFromCache(req.GroupID, req.UserIDList...); err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "ReduceGroupMemberFromCache failed", err.Error()) resp.CommonResp.ErrCode = constant.ErrDB.ErrCode