mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
conn
This commit is contained in:
parent
84afa86db2
commit
5e634ac91f
@ -26,8 +26,8 @@ type Auth struct {
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (o *Auth) Client(ctx context.Context) (auth.AuthClient, error) {
|
||||
return o.client, nil
|
||||
func (o *Auth) Client() auth.AuthClient {
|
||||
return o.client
|
||||
}
|
||||
|
||||
func (o *Auth) UserToken(c *gin.Context) {
|
||||
|
@ -12,56 +12,54 @@ import (
|
||||
)
|
||||
|
||||
func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversation {
|
||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
return &Conversation{discov: discov}
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := conversation.NewConversationClient(conn)
|
||||
return &Conversation{discov: discov, conn: conn, client: client}
|
||||
}
|
||||
|
||||
type Conversation struct {
|
||||
client conversation.ConversationClient
|
||||
conn *grpc.ClientConn
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (o *Conversation) client(ctx context.Context) (conversation.ConversationClient, error) {
|
||||
c, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return conversation.NewConversationClient(c), nil
|
||||
func (o *Conversation) Client() conversation.ConversationClient {
|
||||
return o.client
|
||||
}
|
||||
|
||||
func (o *Conversation) GetAllConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.GetAllConversations, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.GetAllConversations, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Conversation) GetConversation(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.GetConversation, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.GetConversation, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Conversation) GetConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.GetConversations, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.GetConversations, o.Client, c)
|
||||
}
|
||||
|
||||
// deprecated
|
||||
func (o *Conversation) SetConversation(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.SetConversation, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.SetConversation, o.Client, c)
|
||||
}
|
||||
|
||||
// deprecated
|
||||
func (o *Conversation) BatchSetConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.BatchSetConversations, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.BatchSetConversations, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Conversation) SetRecvMsgOpt(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.SetRecvMsgOpt, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.SetRecvMsgOpt, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Conversation) ModifyConversationField(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.ModifyConversationField, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.ModifyConversationField, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Conversation) SetConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.SetConversations, o.client, c)
|
||||
a2r.Call(conversation.ConversationClient.SetConversations, o.Client, c)
|
||||
}
|
||||
|
@ -13,70 +13,68 @@ import (
|
||||
)
|
||||
|
||||
func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
|
||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
return &Friend{discov: discov}
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := friend.NewFriendClient(conn)
|
||||
return &Friend{discov: discov, conn: conn, client: client}
|
||||
}
|
||||
|
||||
type Friend struct {
|
||||
conn *grpc.ClientConn
|
||||
client friend.FriendClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (o *Friend) client(ctx context.Context) (friend.FriendClient, error) {
|
||||
c, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImFriendName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return friend.NewFriendClient(c), nil
|
||||
func (o *Friend) Client() friend.FriendClient {
|
||||
return friend.NewFriendClient(o.conn)
|
||||
}
|
||||
|
||||
func (o *Friend) ApplyToAddFriend(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.ApplyToAddFriend, o.client, c)
|
||||
a2r.Call(friend.FriendClient.ApplyToAddFriend, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) RespondFriendApply(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.RespondFriendApply, o.client, c)
|
||||
a2r.Call(friend.FriendClient.RespondFriendApply, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) DeleteFriend(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.DeleteFriend, o.client, c)
|
||||
a2r.Call(friend.FriendClient.DeleteFriend, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) GetFriendApplyList(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyTo, o.client, c)
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyTo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) GetSelfApplyList(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.client, c)
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) GetFriendList(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriends, o.client, c)
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriends, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) SetFriendRemark(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.SetFriendRemark, o.client, c)
|
||||
a2r.Call(friend.FriendClient.SetFriendRemark, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) AddBlack(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.AddBlack, o.client, c)
|
||||
a2r.Call(friend.FriendClient.AddBlack, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) GetPaginationBlacks(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationBlacks, o.client, c)
|
||||
a2r.Call(friend.FriendClient.GetPaginationBlacks, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) RemoveBlack(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.RemoveBlack, o.client, c)
|
||||
a2r.Call(friend.FriendClient.RemoveBlack, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) ImportFriends(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.ImportFriends, o.client, c)
|
||||
a2r.Call(friend.FriendClient.ImportFriends, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Friend) IsFriend(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.IsFriend, o.client, c)
|
||||
a2r.Call(friend.FriendClient.IsFriend, o.Client, c)
|
||||
}
|
||||
|
@ -13,108 +13,106 @@ import (
|
||||
)
|
||||
|
||||
func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
|
||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
return &Group{discov: discov}
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := group.NewGroupClient(conn)
|
||||
return &Group{discov: discov, conn: conn, client: client}
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
conn *grpc.ClientConn
|
||||
client group.GroupClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (o *Group) client(ctx context.Context) (group.GroupClient, error) {
|
||||
c, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImGroupName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return group.NewGroupClient(c), nil
|
||||
func (o *Group) Client() group.GroupClient {
|
||||
return o.client
|
||||
}
|
||||
|
||||
func (o *Group) CreateGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.CreateGroup, o.client, c)
|
||||
a2r.Call(group.GroupClient.CreateGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) SetGroupInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.SetGroupInfo, o.client, c)
|
||||
a2r.Call(group.GroupClient.SetGroupInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) JoinGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.JoinGroup, o.client, c)
|
||||
a2r.Call(group.GroupClient.JoinGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) QuitGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.QuitGroup, o.client, c)
|
||||
a2r.Call(group.GroupClient.QuitGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) ApplicationGroupResponse(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GroupApplicationResponse, o.client, c)
|
||||
a2r.Call(group.GroupClient.GroupApplicationResponse, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) TransferGroupOwner(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.TransferGroupOwner, o.client, c)
|
||||
a2r.Call(group.GroupClient.TransferGroupOwner, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetRecvGroupApplicationList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupApplicationList, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetGroupApplicationList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetUserReqGroupApplicationList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetUserReqApplicationList, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetUserReqApplicationList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetGroupsInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupsInfo, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetGroupsInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) KickGroupMember(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.KickGroupMember, o.client, c)
|
||||
a2r.Call(group.GroupClient.KickGroupMember, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetGroupMembersInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupMembersInfo, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetGroupMembersInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetGroupMemberList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupMemberList, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetGroupMemberList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) InviteUserToGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.InviteUserToGroup, o.client, c)
|
||||
a2r.Call(group.GroupClient.InviteUserToGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetJoinedGroupList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetJoinedGroupList, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetJoinedGroupList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) DismissGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.DismissGroup, o.client, c)
|
||||
a2r.Call(group.GroupClient.DismissGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) MuteGroupMember(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.MuteGroupMember, o.client, c)
|
||||
a2r.Call(group.GroupClient.MuteGroupMember, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) CancelMuteGroupMember(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.CancelMuteGroupMember, o.client, c)
|
||||
a2r.Call(group.GroupClient.CancelMuteGroupMember, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) MuteGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.MuteGroup, o.client, c)
|
||||
a2r.Call(group.GroupClient.MuteGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) CancelMuteGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.CancelMuteGroup, o.client, c)
|
||||
a2r.Call(group.GroupClient.CancelMuteGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) SetGroupMemberInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.SetGroupMemberInfo, o.client, c)
|
||||
a2r.Call(group.GroupClient.SetGroupMemberInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetGroupAbstractInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupAbstractInfo, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetGroupAbstractInfo, o.Client, c)
|
||||
}
|
||||
|
||||
//func (g *Group) SetGroupMemberNickname(c *gin.Context) {
|
||||
@ -126,9 +124,9 @@ func (o *Group) GetGroupAbstractInfo(c *gin.Context) {
|
||||
//}
|
||||
|
||||
func (o *Group) GetJoinedSuperGroupList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetJoinedSuperGroupList, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetJoinedSuperGroupList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Group) GetSuperGroupsInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetSuperGroupsInfo, o.client, c)
|
||||
a2r.Call(group.GroupClient.GetSuperGroupsInfo, o.Client, c)
|
||||
}
|
||||
|
@ -22,15 +22,17 @@ import (
|
||||
)
|
||||
|
||||
func NewMsg(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
|
||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
return &Message{validate: validator.New(), discov: discov}
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := msg.NewMsgClient(conn)
|
||||
return &Message{validate: validator.New(), discov: discov, conn: conn, client: client}
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
conn *grpc.ClientConn
|
||||
client msg.MsgClient
|
||||
validate *validator.Validate
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
@ -107,76 +109,72 @@ func (m Message) newUserSendMsgReq(c *gin.Context, params *apistruct.ManagementS
|
||||
return &pbData
|
||||
}
|
||||
|
||||
func (m *Message) client(ctx context.Context) (msg.MsgClient, error) {
|
||||
c, err := m.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImMsgName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return msg.NewMsgClient(c), nil
|
||||
func (m *Message) Client() msg.MsgClient {
|
||||
return m.client
|
||||
}
|
||||
|
||||
func (m *Message) GetSeq(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.GetMaxSeq, m.client, c)
|
||||
a2r.Call(msg.MsgClient.GetMaxSeq, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) PullMsgBySeqs(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.PullMessageBySeqs, m.client, c)
|
||||
a2r.Call(msg.MsgClient.PullMessageBySeqs, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) RevokeMsg(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.RevokeMsg, m.client, c)
|
||||
a2r.Call(msg.MsgClient.RevokeMsg, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) MarkMsgsAsRead(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.MarkMsgsAsRead, m.client, c)
|
||||
a2r.Call(msg.MsgClient.MarkMsgsAsRead, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) MarkConversationAsRead(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.MarkConversationAsRead, m.client, c)
|
||||
a2r.Call(msg.MsgClient.MarkConversationAsRead, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) GetConversationsHasReadAndMaxSeq(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.GetConversationsHasReadAndMaxSeq, m.client, c)
|
||||
a2r.Call(msg.MsgClient.GetConversationsHasReadAndMaxSeq, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) SetConversationHasReadSeq(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.SetConversationHasReadSeq, m.client, c)
|
||||
a2r.Call(msg.MsgClient.SetConversationHasReadSeq, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) ClearConversationsMsg(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.ClearConversationsMsg, m.client, c)
|
||||
a2r.Call(msg.MsgClient.ClearConversationsMsg, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) UserClearAllMsg(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.UserClearAllMsg, m.client, c)
|
||||
a2r.Call(msg.MsgClient.UserClearAllMsg, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) DeleteMsgs(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.DeleteMsgs, m.client, c)
|
||||
a2r.Call(msg.MsgClient.DeleteMsgs, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) DeleteMsgPhysicalBySeq(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.DeleteMsgPhysicalBySeq, m.client, c)
|
||||
a2r.Call(msg.MsgClient.DeleteMsgPhysicalBySeq, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) DeleteMsgPhysical(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.DeleteMsgPhysical, m.client, c)
|
||||
a2r.Call(msg.MsgClient.DeleteMsgPhysical, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) SetMessageReactionExtensions(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.SetMessageReactionExtensions, m.client, c)
|
||||
a2r.Call(msg.MsgClient.SetMessageReactionExtensions, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) GetMessageListReactionExtensions(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.GetMessagesReactionExtensions, m.client, c)
|
||||
a2r.Call(msg.MsgClient.GetMessagesReactionExtensions, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) AddMessageReactionExtensions(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.AddMessageReactionExtensions, m.client, c)
|
||||
a2r.Call(msg.MsgClient.AddMessageReactionExtensions, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) DeleteMessageReactionExtensions(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.DeleteMessageReactionExtensions, m.client, c)
|
||||
a2r.Call(msg.MsgClient.DeleteMessageReactionExtensions, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) SendMessage(c *gin.Context) {
|
||||
@ -245,13 +243,13 @@ func (m *Message) SendMessage(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (m *Message) ManagementBatchSendMsg(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.SendMsg, m.client, c)
|
||||
a2r.Call(msg.MsgClient.SendMsg, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) CheckMsgIsSendSuccess(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.GetSendMsgStatus, m.client, c)
|
||||
a2r.Call(msg.MsgClient.GetSendMsgStatus, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *Message) GetUsersOnlineStatus(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.GetSendMsgStatus, m.client, c)
|
||||
a2r.Call(msg.MsgClient.GetSendMsgStatus, m.Client, c)
|
||||
}
|
||||
|
@ -177,8 +177,6 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
|
||||
s := NewStatistics(discov)
|
||||
conversationGroup.Use(mw.GinParseToken(rdb))
|
||||
statisticsGroup.POST("/user_register", s.UserRegister)
|
||||
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
@ -2,29 +2,34 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func NewStatistics(discov discoveryregistry.SvcDiscoveryRegistry) *Statistics {
|
||||
return &Statistics{discov: discov}
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := user.NewUserClient(conn)
|
||||
return &Statistics{discov: discov, client: client, conn: conn}
|
||||
}
|
||||
|
||||
type Statistics struct {
|
||||
conn *grpc.ClientConn
|
||||
client user.UserClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (s *Statistics) userClient(ctx context.Context) (user.UserClient, error) {
|
||||
conn, err := s.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImUserName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return user.NewUserClient(conn), nil
|
||||
func (s *Statistics) Client() user.UserClient {
|
||||
return s.client
|
||||
}
|
||||
|
||||
func (s *Statistics) UserRegister(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.UserRegisterCount, s.userClient, c)
|
||||
a2r.Call(user.UserClient.UserRegisterCount, s.Client, c)
|
||||
}
|
||||
|
@ -18,53 +18,51 @@ import (
|
||||
)
|
||||
|
||||
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
return &Third{discov: discov}
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := third.NewThirdClient(conn)
|
||||
return &Third{discov: discov, client: client, conn: conn}
|
||||
}
|
||||
|
||||
type Third struct {
|
||||
conn *grpc.ClientConn
|
||||
client third.ThirdClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (o *Third) client(ctx context.Context) (third.ThirdClient, error) {
|
||||
conn, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImThirdName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return third.NewThirdClient(conn), nil
|
||||
func (o *Third) Client() third.ThirdClient {
|
||||
return o.client
|
||||
}
|
||||
|
||||
func (o *Third) ApplyPut(c *gin.Context) {
|
||||
a2r.Call(third.ThirdClient.ApplyPut, o.client, c)
|
||||
a2r.Call(third.ThirdClient.ApplyPut, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Third) GetPut(c *gin.Context) {
|
||||
a2r.Call(third.ThirdClient.GetPut, o.client, c)
|
||||
a2r.Call(third.ThirdClient.GetPut, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Third) ConfirmPut(c *gin.Context) {
|
||||
a2r.Call(third.ThirdClient.ConfirmPut, o.client, c)
|
||||
a2r.Call(third.ThirdClient.ConfirmPut, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Third) GetHash(c *gin.Context) {
|
||||
a2r.Call(third.ThirdClient.GetHashInfo, o.client, c)
|
||||
a2r.Call(third.ThirdClient.GetHashInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Third) FcmUpdateToken(c *gin.Context) {
|
||||
a2r.Call(third.ThirdClient.FcmUpdateToken, o.client, c)
|
||||
a2r.Call(third.ThirdClient.FcmUpdateToken, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Third) SetAppBadge(c *gin.Context) {
|
||||
a2r.Call(third.ThirdClient.SetAppBadge, o.client, c)
|
||||
a2r.Call(third.ThirdClient.SetAppBadge, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *Third) GetURL(c *gin.Context) {
|
||||
if c.Request.Method == http.MethodPost {
|
||||
a2r.Call(third.ThirdClient.GetUrl, o.client, c)
|
||||
a2r.Call(third.ThirdClient.GetUrl, o.Client, c)
|
||||
return
|
||||
}
|
||||
name := c.Query("name")
|
||||
@ -81,13 +79,8 @@ func (o *Third) GetURL(c *gin.Context) {
|
||||
expires = 3600 * 1000
|
||||
}
|
||||
attachment, _ := strconv.ParseBool(c.Query("attachment"))
|
||||
client, err := o.client(c)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
c.Set(constant.OperationID, operationID)
|
||||
resp, err := client.GetUrl(mcontext.SetOperationID(c, operationID), &third.GetUrlReq{Name: name, Expires: expires, Attachment: attachment})
|
||||
resp, err := o.client.GetUrl(mcontext.SetOperationID(c, operationID), &third.GetUrlReq{Name: name, Expires: expires, Attachment: attachment})
|
||||
if err != nil {
|
||||
if errs.ErrArgs.Is(err) {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
@ -12,54 +12,54 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
return &User{discov: discov}
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := user.NewUserClient(conn)
|
||||
return &User{discov: discov, client: client, conn: conn}
|
||||
}
|
||||
|
||||
type User struct {
|
||||
conn *grpc.ClientConn
|
||||
client user.UserClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (u *User) client(ctx context.Context) (user.UserClient, error) {
|
||||
conn, err := u.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImUserName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return user.NewUserClient(conn), nil
|
||||
func (s *User) Client() user.UserClient {
|
||||
return s.client
|
||||
}
|
||||
|
||||
func (u *User) UserRegister(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.UserRegister, u.client, c)
|
||||
a2r.Call(user.UserClient.UserRegister, u.Client, c)
|
||||
}
|
||||
|
||||
func (u *User) UpdateUserInfo(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.UpdateUserInfo, u.client, c)
|
||||
a2r.Call(user.UserClient.UpdateUserInfo, u.Client, c)
|
||||
}
|
||||
|
||||
func (u *User) SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.SetGlobalRecvMessageOpt, u.client, c)
|
||||
a2r.Call(user.UserClient.SetGlobalRecvMessageOpt, u.Client, c)
|
||||
}
|
||||
|
||||
func (u *User) GetUsersPublicInfo(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.GetDesignateUsers, u.client, c)
|
||||
a2r.Call(user.UserClient.GetDesignateUsers, u.Client, c)
|
||||
}
|
||||
|
||||
func (u *User) GetAllUsersID(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.GetDesignateUsers, u.client, c)
|
||||
a2r.Call(user.UserClient.GetDesignateUsers, u.Client, c)
|
||||
}
|
||||
|
||||
func (u *User) AccountCheck(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.AccountCheck, u.client, c)
|
||||
a2r.Call(user.UserClient.AccountCheck, u.Client, c)
|
||||
}
|
||||
|
||||
func (u *User) GetUsers(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.GetPaginationUsers, u.client, c)
|
||||
a2r.Call(user.UserClient.GetPaginationUsers, u.Client, c)
|
||||
}
|
||||
|
||||
func (u *User) GetUsersOnlineStatus(c *gin.Context) {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
|
||||
func Call[A, B, C any](
|
||||
rpc func(client C, ctx context.Context, req *A, options ...grpc.CallOption) (*B, error),
|
||||
client func(ctx context.Context) (C, error),
|
||||
client func() C,
|
||||
c *gin.Context,
|
||||
) {
|
||||
var req A
|
||||
@ -29,12 +29,7 @@ func Call[A, B, C any](
|
||||
}
|
||||
}
|
||||
log.ZDebug(c, "gin bind json success", "req", req)
|
||||
cli, err := client(c)
|
||||
if err != nil {
|
||||
log.ZError(c, "get conn error", err, "req", req)
|
||||
apiresp.GinError(c, errs.ErrInternalServer.Wrap(err.Error())) // 获取RPC连接失败
|
||||
return
|
||||
}
|
||||
cli := client()
|
||||
log.ZDebug(c, "get conn success", "req", req)
|
||||
data, err := rpc(cli, c, &req)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user