diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index b2d211f5e..7cf22888d 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -60,174 +60,174 @@ func main() { r.GET("/metrics", promePkg.PrometheusHandler()) } // user routing group, which handles user registration and login services - //userRouterGroup := r.Group("/user") - //{ - // userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1 - // userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt) - // userRouterGroup.POST("/get_users_info", user.GetUsersPublicInfo) //1 - // userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1 - // userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1 - // userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache) - // userRouterGroup.POST("/get_user_friend_from_cache", user.GetFriendIDListFromCache) - // userRouterGroup.POST("/get_black_list_from_cache", user.GetBlackIDListFromCache) - // userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1 - // userRouterGroup.POST("/account_check", manage.AccountCheck) //1 - // // userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1 - // userRouterGroup.POST("/get_users", user.GetUsers) - //} + userRouterGroup := r.Group("/user") + { + userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1 + userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt) + userRouterGroup.POST("/get_users_info", user.GetUsersPublicInfo) //1 + userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1 + userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1 + userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache) + userRouterGroup.POST("/get_user_friend_from_cache", user.GetFriendIDListFromCache) + userRouterGroup.POST("/get_black_list_from_cache", user.GetBlackIDListFromCache) + userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1 + userRouterGroup.POST("/account_check", manage.AccountCheck) //1 + // userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1 + userRouterGroup.POST("/get_users", user.GetUsers) + } ////friend routing group - //friendRouterGroup := r.Group("/friend") - //{ - // // friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo) - // friendRouterGroup.POST("/add_friend", friend.AddFriend) //1 - // friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) //1 - // friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList) //1 - // friendRouterGroup.POST("/get_self_friend_apply_list", friend.GetSelfFriendApplyList) //1 - // friendRouterGroup.POST("/get_friend_list", friend.GetFriendList) //1 - // friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1 - // friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1 - // - // friendRouterGroup.POST("/add_black", friend.AddBlack) //1 - // friendRouterGroup.POST("/get_black_list", friend.GetBlacklist) //1 - // friendRouterGroup.POST("/remove_black", friend.RemoveBlack) //1 - // - // friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1 - // friendRouterGroup.POST("/is_friend", friend.IsFriend) //1 - //} + friendRouterGroup := r.Group("/friend") + { + // friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo) + friendRouterGroup.POST("/add_friend", friend.AddFriend) //1 + friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) //1 + friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList) //1 + friendRouterGroup.POST("/get_self_friend_apply_list", friend.GetSelfFriendApplyList) //1 + friendRouterGroup.POST("/get_friend_list", friend.GetFriendList) //1 + friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1 + friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1 + + friendRouterGroup.POST("/add_black", friend.AddBlack) //1 + friendRouterGroup.POST("/get_black_list", friend.GetBlacklist) //1 + friendRouterGroup.POST("/remove_black", friend.RemoveBlack) //1 + + friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1 + friendRouterGroup.POST("/is_friend", friend.IsFriend) //1 + } //group related routing group groupRouterGroup := r.Group("/group") { - groupRouterGroup.POST("/create_group", group.NewCreateGroup) //1 - groupRouterGroup.POST("/set_group_info", group.NewSetGroupInfo) //1 - //groupRouterGroup.POST("/join_group", group.JoinGroup) //1 - //groupRouterGroup.POST("/quit_group", group.QuitGroup) //1 - //groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1 - //groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1 - //groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1 - //groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList) - //groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 - //groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 - //// groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use - //groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1 - //groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1 - //groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1 - //groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) - //groupRouterGroup.POST("/dismiss_group", group.DismissGroup) // - //groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember) - //groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup - //groupRouterGroup.POST("/mute_group", group.MuteGroup) - //groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup) - //groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname) - //groupRouterGroup.POST("/set_group_member_info", group.SetGroupMemberInfo) - //groupRouterGroup.POST("/get_group_abstract_info", group.GetGroupAbstractInfo) + groupRouterGroup.POST("/create_group", group.NewCreateGroup) //1 + groupRouterGroup.POST("/set_group_info", group.NewSetGroupInfo) //1 + groupRouterGroup.POST("/join_group", group.JoinGroup) //1 + groupRouterGroup.POST("/quit_group", group.QuitGroup) //1 + groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1 + groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1 + groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1 + groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList) + groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 + groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 + // groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use + groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1 + groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1 + groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1 + groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) + groupRouterGroup.POST("/dismiss_group", group.DismissGroup) // + groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember) + groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup + groupRouterGroup.POST("/mute_group", group.MuteGroup) + groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup) + groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname) + groupRouterGroup.POST("/set_group_member_info", group.SetGroupMemberInfo) + groupRouterGroup.POST("/get_group_abstract_info", group.GetGroupAbstractInfo) //groupRouterGroup.POST("/get_group_all_member_list_by_split", group.GetGroupAllMemberListBySplit) } - //superGroupRouterGroup := r.Group("/super_group") - //{ - // superGroupRouterGroup.POST("/get_joined_group_list", group.GetJoinedSuperGroupList) - // superGroupRouterGroup.POST("/get_groups_info", group.GetSuperGroupsInfo) - //} + superGroupRouterGroup := r.Group("/super_group") + { + superGroupRouterGroup.POST("/get_joined_group_list", group.GetJoinedSuperGroupList) + superGroupRouterGroup.POST("/get_groups_info", group.GetSuperGroupsInfo) + } ////certificate - //authRouterGroup := r.Group("/auth") - //{ - // authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1 - // authRouterGroup.POST("/user_token", apiAuth.UserToken) //1 - // authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1 - // authRouterGroup.POST("/force_logout", apiAuth.ForceLogout) //1 - //} + authRouterGroup := r.Group("/auth") + { + authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1 + authRouterGroup.POST("/user_token", apiAuth.UserToken) //1 + authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1 + authRouterGroup.POST("/force_logout", apiAuth.ForceLogout) //1 + } ////Third service - //thirdGroup := r.Group("/third") - //{ - // thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential) - // thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential) - // thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential) - // thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile) - // thirdGroup.POST("/upload_update_app", apiThird.UploadUpdateApp) - // thirdGroup.POST("/get_download_url", apiThird.GetDownloadURL) - // thirdGroup.POST("/get_rtc_invitation_info", apiThird.GetRTCInvitationInfo) - // thirdGroup.POST("/get_rtc_invitation_start_app", apiThird.GetRTCInvitationInfoStartApp) - // thirdGroup.POST("/fcm_update_token", apiThird.FcmUpdateToken) - // thirdGroup.POST("/aws_storage_credential", apiThird.AwsStorageCredential) - // thirdGroup.POST("/set_app_badge", apiThird.SetAppBadge) - //} + thirdGroup := r.Group("/third") + { + thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential) + thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential) + thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential) + thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile) + thirdGroup.POST("/upload_update_app", apiThird.UploadUpdateApp) + thirdGroup.POST("/get_download_url", apiThird.GetDownloadURL) + thirdGroup.POST("/get_rtc_invitation_info", apiThird.GetRTCInvitationInfo) + thirdGroup.POST("/get_rtc_invitation_start_app", apiThird.GetRTCInvitationInfoStartApp) + thirdGroup.POST("/fcm_update_token", apiThird.FcmUpdateToken) + thirdGroup.POST("/aws_storage_credential", apiThird.AwsStorageCredential) + thirdGroup.POST("/set_app_badge", apiThird.SetAppBadge) + } ////Message - //chatGroup := r.Group("/msg") - //{ - // chatGroup.POST("/newest_seq", apiChat.GetSeq) - // chatGroup.POST("/send_msg", apiChat.SendMsg) - // chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList) - // chatGroup.POST("/del_msg", apiChat.DelMsg) - // chatGroup.POST("/del_super_group_msg", apiChat.DelSuperGroupMsg) - // chatGroup.POST("/clear_msg", apiChat.ClearMsg) - // chatGroup.POST("/manage_send_msg", manage.ManagementSendMsg) - // chatGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg) - // chatGroup.POST("/check_msg_is_send_success", manage.CheckMsgIsSendSuccess) - // chatGroup.POST("/set_msg_min_seq", apiChat.SetMsgMinSeq) - // - // chatGroup.POST("/set_message_reaction_extensions", apiChat.SetMessageReactionExtensions) - // chatGroup.POST("/get_message_list_reaction_extensions", apiChat.GetMessageListReactionExtensions) - // chatGroup.POST("/add_message_reaction_extensions", apiChat.AddMessageReactionExtensions) - // chatGroup.POST("/delete_message_reaction_extensions", apiChat.DeleteMessageReactionExtensions) - //} + chatGroup := r.Group("/msg") + { + chatGroup.POST("/newest_seq", apiChat.GetSeq) + chatGroup.POST("/send_msg", apiChat.SendMsg) + chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList) + chatGroup.POST("/del_msg", apiChat.DelMsg) + chatGroup.POST("/del_super_group_msg", apiChat.DelSuperGroupMsg) + chatGroup.POST("/clear_msg", apiChat.ClearMsg) + chatGroup.POST("/manage_send_msg", manage.ManagementSendMsg) + chatGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg) + chatGroup.POST("/check_msg_is_send_success", manage.CheckMsgIsSendSuccess) + chatGroup.POST("/set_msg_min_seq", apiChat.SetMsgMinSeq) + + chatGroup.POST("/set_message_reaction_extensions", apiChat.SetMessageReactionExtensions) + chatGroup.POST("/get_message_list_reaction_extensions", apiChat.GetMessageListReactionExtensions) + chatGroup.POST("/add_message_reaction_extensions", apiChat.AddMessageReactionExtensions) + chatGroup.POST("/delete_message_reaction_extensions", apiChat.DeleteMessageReactionExtensions) + } ////Conversation - //conversationGroup := r.Group("/conversation") - //{ //1 - // conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations) - // conversationGroup.POST("/get_conversation", conversation.GetConversation) - // conversationGroup.POST("/get_conversations", conversation.GetConversations) - // conversationGroup.POST("/set_conversation", conversation.SetConversation) - // conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations) - // conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt) - // conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField) - //} + conversationGroup := r.Group("/conversation") + { //1 + conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations) + conversationGroup.POST("/get_conversation", conversation.GetConversation) + conversationGroup.POST("/get_conversations", conversation.GetConversations) + conversationGroup.POST("/set_conversation", conversation.SetConversation) + conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations) + conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt) + conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField) + } //// office - //officeGroup := r.Group("/office") - //{ - // officeGroup.POST("/get_user_tags", office.GetUserTags) - // officeGroup.POST("/get_user_tag_by_id", office.GetUserTagByID) - // officeGroup.POST("/create_tag", office.CreateTag) - // officeGroup.POST("/delete_tag", office.DeleteTag) - // officeGroup.POST("/set_tag", office.SetTag) - // officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag) - // officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs) - // - // officeGroup.POST("/create_one_work_moment", office.CreateOneWorkMoment) - // officeGroup.POST("/delete_one_work_moment", office.DeleteOneWorkMoment) - // officeGroup.POST("/like_one_work_moment", office.LikeOneWorkMoment) - // officeGroup.POST("/comment_one_work_moment", office.CommentOneWorkMoment) - // officeGroup.POST("/get_work_moment_by_id", office.GetWorkMomentByID) - // officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments) - // officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments) - // officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel) - // officeGroup.POST("/delete_comment", office.DeleteComment) - //} - // - //organizationGroup := r.Group("/organization") - //{ - // organizationGroup.POST("/create_department", organization.CreateDepartment) - // organizationGroup.POST("/update_department", organization.UpdateDepartment) - // organizationGroup.POST("/get_sub_department", organization.GetSubDepartment) - // organizationGroup.POST("/delete_department", organization.DeleteDepartment) - // organizationGroup.POST("/get_all_department", organization.GetAllDepartment) - // - // organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser) - // organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser) - // organizationGroup.POST("/delete_organization_user", organization.DeleteOrganizationUser) - // - // organizationGroup.POST("/create_department_member", organization.CreateDepartmentMember) - // organizationGroup.POST("/get_user_in_department", organization.GetUserInDepartment) - // organizationGroup.POST("/update_user_in_department", organization.UpdateUserInDepartment) + officeGroup := r.Group("/office") + { + officeGroup.POST("/get_user_tags", office.GetUserTags) + officeGroup.POST("/get_user_tag_by_id", office.GetUserTagByID) + officeGroup.POST("/create_tag", office.CreateTag) + officeGroup.POST("/delete_tag", office.DeleteTag) + officeGroup.POST("/set_tag", office.SetTag) + officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag) + officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs) + + officeGroup.POST("/create_one_work_moment", office.CreateOneWorkMoment) + officeGroup.POST("/delete_one_work_moment", office.DeleteOneWorkMoment) + officeGroup.POST("/like_one_work_moment", office.LikeOneWorkMoment) + officeGroup.POST("/comment_one_work_moment", office.CommentOneWorkMoment) + officeGroup.POST("/get_work_moment_by_id", office.GetWorkMomentByID) + officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments) + officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments) + officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel) + officeGroup.POST("/delete_comment", office.DeleteComment) + } // - // organizationGroup.POST("/get_department_member", organization.GetDepartmentMember) - // organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment) - // organizationGroup.POST("/get_user_in_organization", organization.GetUserInOrganization) - //} + organizationGroup := r.Group("/organization") + { + organizationGroup.POST("/create_department", organization.CreateDepartment) + organizationGroup.POST("/update_department", organization.UpdateDepartment) + organizationGroup.POST("/get_sub_department", organization.GetSubDepartment) + organizationGroup.POST("/delete_department", organization.DeleteDepartment) + organizationGroup.POST("/get_all_department", organization.GetAllDepartment) + + organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser) + organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser) + organizationGroup.POST("/delete_organization_user", organization.DeleteOrganizationUser) + + organizationGroup.POST("/create_department_member", organization.CreateDepartmentMember) + organizationGroup.POST("/get_user_in_department", organization.GetUserInDepartment) + organizationGroup.POST("/update_user_in_department", organization.UpdateUserInDepartment) + + organizationGroup.POST("/get_department_member", organization.GetDepartmentMember) + organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment) + organizationGroup.POST("/get_user_in_organization", organization.GetUserInOrganization) + } // - //initGroup := r.Group("/init") - //{ - // initGroup.POST("/set_client_config", clientInit.SetClientInitConfig) - // initGroup.POST("/get_client_config", clientInit.GetClientInitConfig) - //} + initGroup := r.Group("/init") + { + initGroup.POST("/set_client_config", clientInit.SetClientInitConfig) + initGroup.POST("/get_client_config", clientInit.GetClientInitConfig) + } go utils.RegisterConf() go apiThird.MinioInit() defaultPorts := config.Config.Api.GinPort diff --git a/internal/api/group/group.go b/internal/api/group/group.go index be4596b6f..e255165d9 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -8,11 +8,10 @@ import ( "Open_IM/pkg/common/log" "Open_IM/pkg/common/token_verify" "Open_IM/pkg/common/trace_log" + "Open_IM/pkg/getcdv3" rpc "Open_IM/pkg/proto/group" - open_im_sdk "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" - "github.com/OpenIMSDK/getcdv3" "github.com/golang/protobuf/ptypes/wrappers" "google.golang.org/grpc" @@ -64,7 +63,7 @@ func KickGroupMember(c *gin.Context) { log.NewInfo(req.OperationID, "KickGroupMember args ", req.String()) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID) + etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID) if etcdConn == nil { errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil" log.NewError(req.OperationID, errMsg) @@ -80,8 +79,8 @@ func KickGroupMember(c *gin.Context) { } var memberListResp api.KickGroupMemberResp - memberListResp.ErrMsg = RpcResp.ErrMsg - memberListResp.ErrCode = RpcResp.ErrCode + memberListResp.ErrMsg = RpcResp.CommonResp.ErrMsg + memberListResp.ErrCode = RpcResp.CommonResp.ErrCode for _, v := range RpcResp.Id2ResultList { memberListResp.UserIDResultList = append(memberListResp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result}) } @@ -143,7 +142,7 @@ func GetGroupMembersInfo(c *gin.Context) { return } - memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList} + memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList} memberListResp.Data = jsonData.JsonDataList(RpcResp.MemberList) log.NewInfo(req.OperationID, "GetGroupMembersInfo api return ", memberListResp) c.JSON(http.StatusOK, memberListResp) @@ -187,7 +186,7 @@ func GetGroupMemberList(c *gin.Context) { return } - memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq} + memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq} memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList) log.NewInfo(req.OperationID, "GetGroupMemberList api return ", memberListResp) @@ -244,7 +243,7 @@ func GetGroupAllMemberList(c *gin.Context) { return } - memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList} + memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList} memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList) log.NewInfo(req.OperationID, "GetGroupAllMember api return ", len(memberListResp.MemberList)) c.JSON(http.StatusOK, memberListResp) @@ -299,7 +298,7 @@ func GetJoinedGroupList(c *gin.Context) { return } - GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupList} + GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupList} GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList) log.NewInfo(req.OperationID, "GetJoinedGroupList api return ", GroupListResp) c.JSON(http.StatusOK, GroupListResp) @@ -360,7 +359,7 @@ func InviteUserToGroup(c *gin.Context) { return } - resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} + resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} for _, v := range RpcResp.Id2ResultList { resp.UserIDResultList = append(resp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result}) } @@ -497,7 +496,7 @@ func GetRecvGroupApplicationList(c *gin.Context) { return } - resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList} + resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}, GroupRequestList: reply.GroupRequestList} resp.Data = jsonData.JsonDataList(resp.GroupRequestList) log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp) c.JSON(http.StatusOK, resp) @@ -568,7 +567,7 @@ func GetGroupsInfo(c *gin.Context) { return } - resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList} + resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList} resp.Data = jsonData.JsonDataList(resp.GroupInfoList) log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp) c.JSON(http.StatusOK, resp) @@ -1010,18 +1009,14 @@ func CancelMuteGroupMember(c *gin.Context) { req := &rpc.CancelMuteGroupMemberReq{} utils.CopyStructFields(req, ¶ms) - var err error - if err, req.OpUserID, _ = token_verify.ParseUserIDFromToken(c.Request.Header.Get("token"), req.OperationID); err != nil { - trace_log.WriteErrorResponse(nCtx, "ParseUserIDFromToken", err) - return - } + //var err error + //if err, req.OpUserID, _ = token_verify.ParseUserIDFromToken(c.Request.Header.Get("token"), req.OperationID); err != nil { + // trace_log.WriteErrorResponse(nCtx, "ParseUserIDFromToken", err) + // return + //} trace_log.SetContextInfo(nCtx, "ParseUserIDFromToken", nil, "token", c.Request.Header.Get("token"), "OpUserID", req.OpUserID) - etcdConn, err := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID) - if err != nil { - trace_log.WriteErrorResponse(nCtx, "GetDefaultConn", err) - return - } + etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID) client := rpc.NewGroupClient(etcdConn) reply, err := client.CancelMuteGroupMember(nCtx, req) diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index 9b3475248..2430972ee 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -172,7 +172,7 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) { log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList) } if len(pushToUserIDList) == 0 { - userIDList, err := utils2.GetGroupMemberUserIDList(pushMsg.MsgData.GroupID, pushMsg.OperationID) + userIDList, err := utils2.GetGroupMemberUserIDList(context.Background(), pushMsg.MsgData.GroupID, pushMsg.OperationID) if err != nil { log.Error(pushMsg.OperationID, "GetGroupMemberUserIDList failed ", err.Error(), pushMsg.MsgData.GroupID) return diff --git a/internal/rpc/msg/extend_msg.notification.go b/internal/rpc/msg/extend_msg.notification.go index 971f2f797..9c2e47f09 100644 --- a/internal/rpc/msg/extend_msg.notification.go +++ b/internal/rpc/msg/extend_msg.notification.go @@ -5,12 +5,10 @@ import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" - "Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/proto/msg" open_im_sdk "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" - "strings" ) func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32, @@ -89,10 +87,8 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT case constant.GroupChatType, constant.SuperGroupChatType: pbData.MsgData.GroupID = sourceID } - etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, operationID) - if etcdConn == nil { - errMsg := operationID + "getcdv3.GetDefaultConn == nil" - log.NewError(operationID, errMsg) + etcdConn, err := utils.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName) + if err != nil { return } client := msg.NewMsgClient(etcdConn) @@ -102,5 +98,4 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT } else if reply.ErrCode != 0 { log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), reply.ErrCode, reply.ErrMsg) } - } diff --git a/internal/rpc/msg/rpcChat.go b/internal/rpc/msg/rpcChat.go index 470325deb..699f539a5 100644 --- a/internal/rpc/msg/rpcChat.go +++ b/internal/rpc/msg/rpcChat.go @@ -7,9 +7,9 @@ import ( "Open_IM/pkg/common/kafka" "Open_IM/pkg/common/log" promePkg "Open_IM/pkg/common/prometheus" - "Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/proto/msg" "Open_IM/pkg/utils" + "github.com/OpenIMSDK/getcdv3" "net" "strconv" "strings" @@ -124,7 +124,7 @@ func (rpc *rpcChat) Run() { log.Error("", "GetLocalIP failed ", err.Error()) } } - err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10) + err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10, "") if err != nil { log.Error("", "register rpcChat to etcd failed ", err.Error()) panic(utils.Wrap(err, "register chat module rpc to etcd err")) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index b3a3cb745..68f752638 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -8,7 +8,6 @@ import ( rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/log" "Open_IM/pkg/common/token_verify" - "Open_IM/pkg/grpc-etcdv3/getcdv3" cacheRpc "Open_IM/pkg/proto/cache" pbConversation "Open_IM/pkg/proto/conversation" pbChat "Open_IM/pkg/proto/msg" @@ -96,8 +95,8 @@ func isMessageHasReadEnabled(pb *pbChat.SendMsgReq) (bool, int32, string) { return true, 0, "" } -func userIsMuteAndIsAdminInGroup(groupID, userID string) (isMute bool, isAdmin bool, err error) { - groupMemberInfo, err := rocksCache.GetGroupMemberInfoFromCache(groupID, userID) +func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (isMute bool, isAdmin bool, err error) { + groupMemberInfo, err := rocksCache.GetGroupMemberInfoFromCache(ctx, groupID, userID) if err != nil { return false, false, utils.Wrap(err, "") } @@ -108,8 +107,8 @@ func userIsMuteAndIsAdminInGroup(groupID, userID string) (isMute bool, isAdmin b return false, groupMemberInfo.RoleLevel > constant.GroupOrdinaryUsers, nil } -func groupIsMuted(groupID string) (bool, error) { - groupInfo, err := rocksCache.GetGroupInfoFromCache(groupID) +func groupIsMuted(ctx context.Context, groupID string) (bool, error) { + groupInfo, err := rocksCache.GetGroupInfoFromCache(ctx, groupID) if err != nil { return false, utils.Wrap(err, "GetGroupInfoFromCache failed") } @@ -119,7 +118,7 @@ func groupIsMuted(groupID string) (bool, error) { return false, nil } -func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string) { +func (rpc *rpcChat) messageVerification(ctx context.Context, data *pbChat.SendMsgReq) (bool, int32, string, []string) { switch data.MsgData.SessionType { case constant.SingleChatType: if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { @@ -130,8 +129,8 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s } log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify) reqGetBlackIDListFromCache := &cacheRpc.GetBlackIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} - etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID) - if etcdConn == nil { + etcdConn, err := utils.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImCacheName) + if err != nil { errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil" log.NewError(data.OperationID, errMsg) return true, 0, "", nil @@ -153,8 +152,8 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify) if *config.Config.MessageVerify.FriendVerify { reqGetFriendIDListFromCache := &cacheRpc.GetFriendIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} - etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID) - if etcdConn == nil { + etcdConn, err := utils.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImCacheName) + if err != nil { errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil" log.NewError(data.OperationID, errMsg) return true, 0, "", nil @@ -194,7 +193,7 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s return false, 202, "you are not in group", nil } } - isMute, isAdmin, err := userIsMuteAndIsAdminInGroup(data.MsgData.GroupID, data.MsgData.SendID) + isMute, isAdmin, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { errMsg := data.OperationID + err.Error() return false, 223, errMsg, nil @@ -205,7 +204,7 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s if isAdmin { return true, 0, "", userIDList } - isMute, err = groupIsMuted(data.MsgData.GroupID) + isMute, err = groupIsMuted(ctx, data.MsgData.GroupID) if err != nil { errMsg := data.OperationID + err.Error() return false, 223, errMsg, nil @@ -215,7 +214,7 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s } return true, 0, "", userIDList case constant.SuperGroupChatType: - groupInfo, err := rocksCache.GetGroupInfoFromCache(data.MsgData.GroupID) + groupInfo, err := rocksCache.GetGroupInfoFromCache(ctx, data.MsgData.GroupID) if err != nil { return false, 201, err.Error(), nil } @@ -268,7 +267,7 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s return false, 202, "you are not in group", nil } } - isMute, isAdmin, err := userIsMuteAndIsAdminInGroup(data.MsgData.GroupID, data.MsgData.SendID) + isMute, isAdmin, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { errMsg := data.OperationID + err.Error() return false, 223, errMsg, nil @@ -279,7 +278,7 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s if isAdmin { return true, 0, "", userIDList } - isMute, err = groupIsMuted(data.MsgData.GroupID) + isMute, err = groupIsMuted(ctx, data.MsgData.GroupID) if err != nil { errMsg := data.OperationID + err.Error() return false, 223, errMsg, nil @@ -342,7 +341,7 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) { utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false) } } -func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) { +func (rpc *rpcChat) SendMsg(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) { replay := pbChat.SendMsgResp{} log.Info(pb.OperationID, "rpc sendMsg come here ", pb.String()) flag, errCode, errMsg := isMessageHasReadEnabled(pb) @@ -387,7 +386,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) } t1 = time.Now() - flag, errCode, errMsg, _ = rpc.messageVerification(pb) + flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb) log.Debug(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1)) if !flag { return returnMsg(&replay, pb, errCode, errMsg, "", 0) @@ -399,7 +398,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S msgToMQSingle.MsgData = pb.MsgData log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) t1 = time.Now() - err1 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) + err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) if err1 != nil { log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error()) @@ -409,7 +408,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S } if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself t1 = time.Now() - err2 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) + err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) if err2 != nil { log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) @@ -442,7 +441,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) } var memberUserIDList []string - if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(pb); !flag { + if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(ctx, pb); !flag { promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) return returnMsg(&replay, pb, errCode, errMsg, "", 0) } @@ -539,8 +538,8 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S conversationReq.UserIDList = pb.MsgData.AtUserIDList conversation.GroupAtType = constant.AtMe } - etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID) - if etcdConn == nil { + etcdConn, err := utils.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName) + if err != nil { errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" log.NewError(pb.OperationID, errMsg) return @@ -579,14 +578,14 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S t1 = time.Now() msgToMQSingle.MsgData = pb.MsgData log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) - err1 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) + err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) if err1 != nil { log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String()) return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) } if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself - err2 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) + err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) if err2 != nil { log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) @@ -610,7 +609,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg result", "end rpc and return", callbackResp) return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) } - if flag, errCode, errMsg, _ = rpc.messageVerification(pb); !flag { + if flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb); !flag { promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) return returnMsg(&replay, pb, errCode, errMsg, "", 0) } @@ -635,18 +634,17 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S } } -func (rpc *rpcChat) sendMsgToWriter(m *pbChat.MsgDataToMQ, key string, status string) error { +func (rpc *rpcChat) sendMsgToWriter(ctx context.Context, m *pbChat.MsgDataToMQ, key string, status string) error { switch status { case constant.OnlineStatus: if m.MsgData.ContentType == constant.SignalingNotification { rpcPushMsg := pbPush.PushMsgReq{OperationID: m.OperationID, MsgData: m.MsgData, PushToUserID: key} - grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName, m.OperationID) - if grpcConn == nil { - log.Error(rpcPushMsg.OperationID, "rpc dial failed", "push data", rpcPushMsg.String()) - return errors.New("grpcConn is nil") + grpcConn, err := utils.GetConn(ctx, config.Config.RpcRegisterName.OpenImPushName) + if err != nil { + return err } msgClient := pbPush.NewPushMsgServiceClient(grpcConn) - _, err := msgClient.PushMsg(context.Background(), &rpcPushMsg) + _, err = msgClient.PushMsg(context.Background(), &rpcPushMsg) if err != nil { log.Error(rpcPushMsg.OperationID, "rpc send failed", rpcPushMsg.OperationID, "push data", rpcPushMsg.String(), "err", err.Error()) return err diff --git a/internal/rpc/msg/tag_send_msg.go b/internal/rpc/msg/tag_send_msg.go index c4e2843fe..2a8283478 100644 --- a/internal/rpc/msg/tag_send_msg.go +++ b/internal/rpc/msg/tag_send_msg.go @@ -5,7 +5,7 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/log" - "Open_IM/pkg/grpc-etcdv3/getcdv3" + "Open_IM/pkg/getcdv3" pbChat "Open_IM/pkg/proto/msg" pbCommon "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" diff --git a/internal/rpc/office/office.go b/internal/rpc/office/office.go index f0d204ea1..d4f3683fe 100644 --- a/internal/rpc/office/office.go +++ b/internal/rpc/office/office.go @@ -10,12 +10,12 @@ import ( rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/log" promePkg "Open_IM/pkg/common/prometheus" - "Open_IM/pkg/grpc-etcdv3/getcdv3" pbCache "Open_IM/pkg/proto/cache" pbOffice "Open_IM/pkg/proto/office" pbCommon "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" + "github.com/OpenIMSDK/getcdv3" "net" "strconv" "strings" diff --git a/internal/utils/local_cache.go b/internal/utils/local_cache.go index b37692d2a..8b21d4416 100644 --- a/internal/utils/local_cache.go +++ b/internal/utils/local_cache.go @@ -4,12 +4,10 @@ import ( "Open_IM/pkg/common/config" rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/log" - "Open_IM/pkg/grpc-etcdv3/getcdv3" pbCache "Open_IM/pkg/proto/cache" "Open_IM/pkg/utils" "context" "errors" - "strings" "sync" ) @@ -21,8 +19,8 @@ type GroupMemberUserIDListHash struct { var CacheGroupMemberUserIDList = make(map[string]*GroupMemberUserIDListHash, 0) var CacheGroupMtx sync.RWMutex -func GetGroupMemberUserIDList(groupID string, operationID string) ([]string, error) { - groupHashRemote, err := GetGroupMemberUserIDListHashFromRemote(groupID) +func GetGroupMemberUserIDList(ctx context.Context, groupID string, operationID string) ([]string, error) { + groupHashRemote, err := GetGroupMemberUserIDListHashFromRemote(ctx, groupID) if err != nil { CacheGroupMtx.Lock() defer CacheGroupMtx.Unlock() @@ -55,17 +53,15 @@ func GetGroupMemberUserIDList(groupID string, operationID string) ([]string, err return memberUserIDListRemote, nil } -func GetGroupMemberUserIDListHashFromRemote(groupID string) (uint64, error) { - return rocksCache.GetGroupMemberListHashFromCache(groupID) +func GetGroupMemberUserIDListHashFromRemote(ctx context.Context, groupID string) (uint64, error) { + return rocksCache.GetGroupMemberListHashFromCache(ctx, groupID) } func GetGroupMemberUserIDListFromRemote(groupID string, operationID string) ([]string, error) { getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: operationID, GroupID: groupID} - etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, operationID) - if etcdConn == nil { - errMsg := operationID + "getcdv3.GetDefaultConn == nil" - log.NewError(operationID, errMsg) - return nil, errors.New("errMsg") + etcdConn, err := utils.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImCacheName) + if err != nil { + return nil, err } client := pbCache.NewCacheClient(etcdConn) cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq) diff --git a/pkg/common/constant/error.go b/pkg/common/constant/error.go index 94b4270b0..aef210995 100644 --- a/pkg/common/constant/error.go +++ b/pkg/common/constant/error.go @@ -63,6 +63,8 @@ var ( ErrTokenNotExist = ErrInfo{TokenNotExistError, "TokenNotExistError", ""} //在redis中不存在 ErrTokenDifferentPlatformID = ErrInfo{TokenDifferentPlatformIDError, "TokenDifferentPlatformIDError", ""} ErrTokenDifferentUserID = ErrInfo{TokenDifferentUserIDError, "TokenDifferentUserIDError", ""} + + ErrMessageHasReadDisable = ErrInfo{MessageHasReadDisable, "MessageHasReadDisable", ""} ) func NewErrNetwork(err error) error { @@ -202,3 +204,8 @@ const ( TokenDifferentUserIDError = 95008 TokenNotExistError = 95009 ) + +// 消息错误码 +const ( + MessageHasReadDisable = 96001 +) diff --git a/pkg/common/db/mysql.go b/pkg/common/db/mysql.go index 5ecdc302d..f7cd28db0 100644 --- a/pkg/common/db/mysql.go +++ b/pkg/common/db/mysql.go @@ -69,15 +69,14 @@ func initMysqlDB() { sqlDB.SetMaxIdleConns(config.Config.Mysql.DBMaxIdleConns) db.AutoMigrate( - &im_mysql_model.Register{}, &im_mysql_model.Friend{}, &im_mysql_model.FriendRequest{}, &im_mysql_model.Group{}, &im_mysql_model.GroupMember{}, &im_mysql_model.GroupRequest{}, &im_mysql_model.User{}, - &im_mysql_model.Black{}, &im_mysql_model.ChatLog{}, &im_mysql_model.Register{}, &im_mysql_model.Conversation{}, &im_mysql_model.AppVersion{}, &im_mysql_model.Department{}, &im_mysql_model.BlackList{}, &im_mysql_model.IpLimit{}, &im_mysql_model.UserIpLimit{}, &im_mysql_model.Invitation{}, &im_mysql_model.RegisterAddFriend{}, - &im_mysql_model.ClientInitConfig{}, &im_mysql_model.UserIpRecord{}) + &im_mysql_model.Black{}, &im_mysql_model.ChatLog{}, &im_mysql_model.Conversation{}, &im_mysql_model.AppVersion{}, &im_mysql_model.BlackList{}, + ) db.Set("gorm:table_options", "CHARSET=utf8") db.Set("gorm:table_options", "collation=utf8_unicode_ci") diff --git a/pkg/common/db/mysql_model/im_mysql_model/friend_model_k.go b/pkg/common/db/mysql_model/im_mysql_model/friend_model_k.go index 9959ac5f0..0151e2d59 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/friend_model_k.go +++ b/pkg/common/db/mysql_model/im_mysql_model/friend_model_k.go @@ -5,9 +5,12 @@ import ( "Open_IM/pkg/common/trace_log" "Open_IM/pkg/utils" "context" + "gorm.io/gorm" "time" ) +var FriendDB *gorm.DB + type Friend struct { OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"` FriendUserID string `gorm:"column:friend_user_id;primary_key;size:64"` diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go index 5a299f6c3..bccaf8c6e 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go @@ -1,12 +1,5 @@ package im_mysql_model -import ( - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db" - "Open_IM/pkg/utils" - "time" -) - //type GroupMember struct { // GroupID string `gorm:"column:group_id;primaryKey;"` // UserID string `gorm:"column:user_id;primaryKey;"` @@ -32,96 +25,96 @@ import ( // return nil //} -func BatchInsertIntoGroupMember(toInsertInfoList []*GroupMember) error { - for _, toInsertInfo := range toInsertInfoList { - toInsertInfo.JoinTime = time.Now() - if toInsertInfo.RoleLevel == 0 { - toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers - } - toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) - } - return db.DB.MysqlDB.DefaultGormDB().Create(toInsertInfoList).Error - -} - -func GetGroupMemberListByUserID(userID string) ([]GroupMember, error) { - var groupMemberList []GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error - if err != nil { - return nil, err - } - return groupMemberList, nil -} - -func GetGroupMemberListByGroupID(groupID string) ([]GroupMember, error) { - var groupMemberList []GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error - if err != nil { - return nil, err - } - return groupMemberList, nil -} - -func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) { - var groupMemberIDList []string - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error - if err != nil { - return nil, err - } - return groupMemberIDList, nil -} - -func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]GroupMember, error) { - var groupMemberList []GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error - if err != nil { - return nil, err - } - return groupMemberList, nil -} - -func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMember, error) { - var groupMember GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error - if err != nil { - return nil, err - } - return &groupMember, nil -} - -func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMember{}).Error -} - -func DeleteGroupMemberByGroupID(groupID string) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? ", groupID).Delete(GroupMember{}).Error -} - -func UpdateGroupMemberInfo(groupMemberInfo GroupMember) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error -} - -func UpdateGroupMemberInfoByMap(groupMemberInfo GroupMember, m map[string]interface{}) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error -} - -func GetOwnerManagerByGroupID(groupID string) ([]GroupMember, error) { - var groupMemberList []GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and role_level>?", groupID, constant.GroupOrdinaryUsers).Find(&groupMemberList).Error - if err != nil { - return nil, err - } - return groupMemberList, nil -} - -func GetGroupMemberNumByGroupID(groupID string) (int64, error) { - var number int64 - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Count(&number).Error - if err != nil { - return 0, utils.Wrap(err, "") - } - return number, nil -} +//func BatchInsertIntoGroupMember(toInsertInfoList []*GroupMember) error { +// for _, toInsertInfo := range toInsertInfoList { +// toInsertInfo.JoinTime = time.Now() +// if toInsertInfo.RoleLevel == 0 { +// toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers +// } +// toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) +// } +// return db.DB.MysqlDB.DefaultGormDB().Create(toInsertInfoList).Error +// +//} +// +//func GetGroupMemberListByUserID(userID string) ([]GroupMember, error) { +// var groupMemberList []GroupMember +// err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error +// if err != nil { +// return nil, err +// } +// return groupMemberList, nil +//} +// +//func GetGroupMemberListByGroupID(groupID string) ([]GroupMember, error) { +// var groupMemberList []GroupMember +// err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error +// if err != nil { +// return nil, err +// } +// return groupMemberList, nil +//} +// +//func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) { +// var groupMemberIDList []string +// err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error +// if err != nil { +// return nil, err +// } +// return groupMemberIDList, nil +//} +// +//func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]GroupMember, error) { +// var groupMemberList []GroupMember +// err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error +// if err != nil { +// return nil, err +// } +// return groupMemberList, nil +//} +// +//func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMember, error) { +// var groupMember GroupMember +// err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error +// if err != nil { +// return nil, err +// } +// return &groupMember, nil +//} +// +//func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error { +// return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMember{}).Error +//} +// +//func DeleteGroupMemberByGroupID(groupID string) error { +// return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? ", groupID).Delete(GroupMember{}).Error +//} +// +//func UpdateGroupMemberInfo(groupMemberInfo GroupMember) error { +// return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error +//} +// +//func UpdateGroupMemberInfoByMap(groupMemberInfo GroupMember, m map[string]interface{}) error { +// return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error +//} +// +//func GetOwnerManagerByGroupID(groupID string) ([]GroupMember, error) { +// var groupMemberList []GroupMember +// err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and role_level>?", groupID, constant.GroupOrdinaryUsers).Find(&groupMemberList).Error +// if err != nil { +// return nil, err +// } +// return groupMemberList, nil +//} +// +//func GetGroupMemberNumByGroupID(groupID string) (int64, error) { +// var number int64 +// err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Count(&number).Error +// if err != nil { +// return 0, utils.Wrap(err, "") +// } +// return number, nil +//} //func GetGroupOwnerInfoByGroupID(groupID string) (*GroupMember, error) { // omList, err := GetOwnerManagerByGroupID(groupID) diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_member_model_k.go b/pkg/common/db/mysql_model/im_mysql_model/group_member_model_k.go index 7739e13b2..10e68e5ed 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_member_model_k.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_member_model_k.go @@ -7,6 +7,7 @@ import ( "Open_IM/pkg/utils" "context" "fmt" + "gorm.io/gorm" "time" ) @@ -22,6 +23,8 @@ import ( // Ex string `gorm:"column:ex"` //} +var GroupMemberDB *gorm.DB + type GroupMember struct { GroupID string `gorm:"column:group_id;primary_key;size:64"` UserID string `gorm:"column:user_id;primary_key;size:64"` @@ -34,35 +37,36 @@ type GroupMember struct { OperatorUserID string `gorm:"column:operator_user_id;size:64"` MuteEndTime time.Time `gorm:"column:mute_end_time"` Ex string `gorm:"column:ex;size:1024"` + DB *gorm.DB } -func (*GroupMember) Create(ctx context.Context, groupMemberList []*GroupMember) (err error) { +func (g *GroupMember) Create(ctx context.Context, groupMemberList []*GroupMember) (err error) { defer func() { trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupMemberList", groupMemberList) }() - return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Create(&groupMemberList).Error, "") + return utils.Wrap(g.DB.Create(&groupMemberList).Error, "") } -func (*GroupMember) Delete(ctx context.Context, groupMembers []*GroupMember) (err error) { +func (g *GroupMember) Delete(ctx context.Context, groupMembers []*GroupMember) (err error) { defer func() { trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) }() - return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Delete(groupMembers).Error, "") + return utils.Wrap(g.DB.Delete(groupMembers).Error, "") } -func (*GroupMember) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}) (err error) { +func (g *GroupMember) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}) (err error) { defer func() { trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args) }() - return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Model(&GroupMember{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "") + return utils.Wrap(g.DB.Model(&GroupMember{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "") } -func (*GroupMember) Update(ctx context.Context, groupMembers []*GroupMember) (err error) { +func (g *GroupMember) Update(ctx context.Context, groupMembers []*GroupMember) (err error) { defer func() { trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) }() - return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Updates(&groupMembers).Error, "") + return utils.Wrap(g.DB.Updates(&groupMembers).Error, "") } -func (*GroupMember) Find(ctx context.Context, groupMembers []*GroupMember) (groupList []*GroupMember, err error) { +func (g *GroupMember) Find(ctx context.Context, groupMembers []*GroupMember) (groupList []*GroupMember, err error) { defer func() { trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers, "groupList", groupList) }() @@ -70,24 +74,24 @@ func (*GroupMember) Find(ctx context.Context, groupMembers []*GroupMember) (grou for _, groupMember := range groupMembers { where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID}) } - err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "") + err = utils.Wrap(g.DB.Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "") return groupList, err } -func (*GroupMember) Take(ctx context.Context, groupID string, userID string) (groupMember *GroupMember, err error) { +func (g *GroupMember) Take(ctx context.Context, groupID string, userID string) (groupMember *GroupMember, err error) { defer func() { trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember) }() groupMember = &GroupMember{} - return groupMember, utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "") + return groupMember, utils.Wrap(g.DB.Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "") } -func (*GroupMember) TakeOwnerInfo(ctx context.Context, groupID string) (groupMember *GroupMember, err error) { +func (g *GroupMember) TakeOwnerInfo(ctx context.Context, groupID string) (groupMember *GroupMember, err error) { defer func() { trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember) }() groupMember = &GroupMember{} - err = db.DB.MysqlDB.DefaultGormDB().Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error + err = g.DB.Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error return groupMember, utils.Wrap(err, "") } @@ -97,7 +101,7 @@ func InsertIntoGroupMember(toInsertInfo GroupMember) error { toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers } toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Create(toInsertInfo).Error + err := GroupMemberDB.Table("group_members").Create(toInsertInfo).Error if err != nil { return err } @@ -112,13 +116,13 @@ func BatchInsertIntoGroupMember(toInsertInfoList []*GroupMember) error { } toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) } - return db.DB.MysqlDB.DefaultGormDB().Create(toInsertInfoList).Error + return GroupMemberDB.Create(toInsertInfoList).Error } func GetGroupMemberListByUserID(userID string) ([]GroupMember, error) { var groupMemberList []GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error + err := GroupMemberDB.Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error if err != nil { return nil, err } @@ -127,7 +131,7 @@ func GetGroupMemberListByUserID(userID string) ([]GroupMember, error) { func GetGroupMemberListByGroupID(groupID string) ([]GroupMember, error) { var groupMemberList []GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error + err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error if err != nil { return nil, err } @@ -136,7 +140,7 @@ func GetGroupMemberListByGroupID(groupID string) ([]GroupMember, error) { func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) { var groupMemberIDList []string - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error + err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error if err != nil { return nil, err } @@ -145,7 +149,7 @@ func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) { func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]GroupMember, error) { var groupMemberList []GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error + err := GroupMemberDB.Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error if err != nil { return nil, err } @@ -154,7 +158,7 @@ func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([ func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMember, error) { var groupMember GroupMember - err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error + err := GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error if err != nil { return nil, err } @@ -162,19 +166,19 @@ func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMember, } func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMember{}).Error + return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMember{}).Error } func DeleteGroupMemberByGroupID(groupID string) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? ", groupID).Delete(GroupMember{}).Error + return GroupMemberDB.Table("group_members").Where("group_id=? ", groupID).Delete(GroupMember{}).Error } func UpdateGroupMemberInfo(groupMemberInfo GroupMember) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error + return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error } func UpdateGroupMemberInfoByMap(groupMemberInfo GroupMember, m map[string]interface{}) error { - return db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error + return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error } func GetOwnerManagerByGroupID(groupID string) ([]GroupMember, error) { diff --git a/pkg/getcdv3/temp.go b/pkg/getcdv3/temp.go new file mode 100644 index 000000000..2ef601137 --- /dev/null +++ b/pkg/getcdv3/temp.go @@ -0,0 +1,7 @@ +package getcdv3 + +import "google.golang.org/grpc" + +func GetDefaultConn(arg1, arg2, arg3, arg4 string) *grpc.ClientConn { + return nil +}