Skip to content

Commit

Permalink
rpc client
Browse files Browse the repository at this point in the history
  • Loading branch information
withchao committed Dec 23, 2024
1 parent 774b3a0 commit fc6569b
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 245 deletions.
16 changes: 9 additions & 7 deletions internal/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ import (
"github.com/openimsdk/tools/a2r"
)

type AuthApi struct{}
type AuthApi struct {
Client auth.AuthClient
}

func NewAuthApi() AuthApi {
return AuthApi{}
func NewAuthApi(client auth.AuthClient) AuthApi {
return AuthApi{client}
}

func (o *AuthApi) GetAdminToken(c *gin.Context) {
a2r.CallV2(c, auth.GetAdminTokenCaller.Invoke)
a2r.Call(c, auth.AuthClient.GetAdminToken, o.Client)
}

func (o *AuthApi) GetUserToken(c *gin.Context) {
a2r.CallV2(c, auth.GetUserTokenCaller.Invoke)
a2r.Call(c, auth.AuthClient.GetUserToken, o.Client)
}

func (o *AuthApi) ParseToken(c *gin.Context) {
a2r.CallV2(c, auth.ParseTokenCaller.Invoke)
a2r.Call(c, auth.AuthClient.ParseToken, o.Client)
}

func (o *AuthApi) ForceLogout(c *gin.Context) {
a2r.CallV2(c, auth.ForceLogoutCaller.Invoke)
a2r.Call(c, auth.AuthClient.ForceLogout, o.Client)
}
30 changes: 16 additions & 14 deletions internal/api/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,54 @@ import (
"github.com/openimsdk/tools/a2r"
)

type ConversationApi struct{}
type ConversationApi struct {
Client conversation.ConversationClient
}

func NewConversationApi() ConversationApi {
return ConversationApi{}
func NewConversationApi(client conversation.ConversationClient) ConversationApi {
return ConversationApi{client}
}

func (o *ConversationApi) GetAllConversations(c *gin.Context) {
a2r.CallV2(c, conversation.GetAllConversationsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetAllConversations, o.Client)
}

func (o *ConversationApi) GetSortedConversationList(c *gin.Context) {
a2r.CallV2(c, conversation.GetSortedConversationListCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetSortedConversationList, o.Client)
}

func (o *ConversationApi) GetConversation(c *gin.Context) {
a2r.CallV2(c, conversation.GetConversationCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetConversation, o.Client)
}

func (o *ConversationApi) GetConversations(c *gin.Context) {
a2r.CallV2(c, conversation.GetConversationsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetConversations, o.Client)
}

func (o *ConversationApi) SetConversations(c *gin.Context) {
a2r.CallV2(c, conversation.SetConversationsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.SetConversations, o.Client)
}

func (o *ConversationApi) GetConversationOfflinePushUserIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetConversationOfflinePushUserIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetConversationOfflinePushUserIDs, o.Client)
}

func (o *ConversationApi) GetFullOwnerConversationIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetFullOwnerConversationIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetFullOwnerConversationIDs, o.Client)
}

func (o *ConversationApi) GetIncrementalConversation(c *gin.Context) {
a2r.CallV2(c, conversation.GetIncrementalConversationCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetIncrementalConversation, o.Client)
}

func (o *ConversationApi) GetOwnerConversation(c *gin.Context) {
a2r.CallV2(c, conversation.GetOwnerConversationCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetOwnerConversation, o.Client)
}

func (o *ConversationApi) GetNotNotifyConversationIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetNotNotifyConversationIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetNotNotifyConversationIDs, o.Client)
}

func (o *ConversationApi) GetPinnedConversationIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetPinnedConversationIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetPinnedConversationIDs, o.Client)
}
50 changes: 26 additions & 24 deletions internal/api/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,94 +21,96 @@ import (
"github.com/openimsdk/tools/a2r"
)

type FriendApi struct{}
type FriendApi struct {
Client relation.FriendClient
}

func NewFriendApi() FriendApi {
return FriendApi{}
func NewFriendApi(client relation.FriendClient) FriendApi {
return FriendApi{client}
}

func (o *FriendApi) ApplyToAddFriend(c *gin.Context) {
a2r.CallV2(c, relation.ApplyToAddFriendCaller.Invoke)
a2r.Call(c, relation.FriendClient.ApplyToAddFriend, o.Client)
}

func (o *FriendApi) RespondFriendApply(c *gin.Context) {
a2r.CallV2(c, relation.RespondFriendApplyCaller.Invoke)
a2r.Call(c, relation.FriendClient.RespondFriendApply, o.Client)
}

func (o *FriendApi) DeleteFriend(c *gin.Context) {
a2r.CallV2(c, relation.DeleteFriendCaller.Invoke)
a2r.Call(c, relation.FriendClient.DeleteFriend, o.Client)
}

func (o *FriendApi) GetFriendApplyList(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationFriendsApplyToCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationFriendsApplyTo, o.Client)
}

func (o *FriendApi) GetDesignatedFriendsApply(c *gin.Context) {
a2r.CallV2(c, relation.GetDesignatedFriendsApplyCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetDesignatedFriendsApply, o.Client)
}

func (o *FriendApi) GetSelfApplyList(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationFriendsApplyFromCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationFriendsApplyFrom, o.Client)
}

func (o *FriendApi) GetFriendList(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationFriends, o.Client)
}

func (o *FriendApi) GetDesignatedFriends(c *gin.Context) {
a2r.CallV2(c, relation.GetDesignatedFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetDesignatedFriends, o.Client)
}

func (o *FriendApi) SetFriendRemark(c *gin.Context) {
a2r.CallV2(c, relation.SetFriendRemarkCaller.Invoke)
a2r.Call(c, relation.FriendClient.SetFriendRemark, o.Client)
}

func (o *FriendApi) AddBlack(c *gin.Context) {
a2r.CallV2(c, relation.AddBlackCaller.Invoke)
a2r.Call(c, relation.FriendClient.AddBlack, o.Client)
}

func (o *FriendApi) GetPaginationBlacks(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationBlacksCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationBlacks, o.Client)
}

func (o *FriendApi) GetSpecifiedBlacks(c *gin.Context) {
a2r.CallV2(c, relation.GetSpecifiedBlacksCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetSpecifiedBlacks, o.Client)
}

func (o *FriendApi) RemoveBlack(c *gin.Context) {
a2r.CallV2(c, relation.RemoveBlackCaller.Invoke)
a2r.Call(c, relation.FriendClient.RemoveBlack, o.Client)
}

func (o *FriendApi) ImportFriends(c *gin.Context) {
a2r.CallV2(c, relation.ImportFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.ImportFriends, o.Client)
}

func (o *FriendApi) IsFriend(c *gin.Context) {
a2r.CallV2(c, relation.IsFriendCaller.Invoke)
a2r.Call(c, relation.FriendClient.IsFriend, o.Client)
}

func (o *FriendApi) GetFriendIDs(c *gin.Context) {
a2r.CallV2(c, relation.GetFriendIDsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetFriendIDs, o.Client)
}

func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) {
a2r.CallV2(c, relation.GetSpecifiedFriendsInfoCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetSpecifiedFriendsInfo, o.Client)
}

func (o *FriendApi) UpdateFriends(c *gin.Context) {
a2r.CallV2(c, relation.UpdateFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.UpdateFriends, o.Client)
}

func (o *FriendApi) GetIncrementalFriends(c *gin.Context) {
a2r.CallV2(c, relation.GetIncrementalFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetIncrementalFriends, o.Client)
}

// GetIncrementalBlacks is temporarily unused.
// Deprecated: This function is currently unused and may be removed in future versions.
func (o *FriendApi) GetIncrementalBlacks(c *gin.Context) {
a2r.CallV2(c, relation.GetIncrementalBlacksCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetIncrementalBlacks, o.Client)
}

func (o *FriendApi) GetFullFriendUserIDs(c *gin.Context) {
a2r.CallV2(c, relation.GetFullFriendUserIDsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetFullFriendUserIDs, o.Client)
}
Loading

0 comments on commit fc6569b

Please sign in to comment.