Files
open-im-server/internal/api/friend.go
T

78 lines
1.9 KiB
Go
Raw Normal View History

2023-02-28 14:20:26 +08:00
package api
2021-12-23 17:22:49 +08:00
2023-02-28 11:38:05 +08:00
import (
2023-02-28 14:20:26 +08:00
"OpenIM/internal/api/a2r"
2023-02-28 11:38:05 +08:00
"OpenIM/pkg/common/config"
2023-03-08 17:29:03 +08:00
"OpenIM/pkg/discoveryregistry"
2023-02-28 11:38:05 +08:00
"OpenIM/pkg/proto/friend"
"context"
2023-03-08 17:29:03 +08:00
2023-02-28 11:38:05 +08:00
"github.com/gin-gonic/gin"
)
var _ context.Context // 解决goland编辑器bug
2023-03-08 17:29:03 +08:00
func NewFriend(c discoveryregistry.SvcDiscoveryRegistry) *Friend {
return &Friend{c: c}
2023-02-28 11:38:05 +08:00
}
type Friend struct {
2023-03-08 17:29:03 +08:00
c discoveryregistry.SvcDiscoveryRegistry
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) client() (friend.FriendClient, error) {
2023-03-08 17:29:03 +08:00
conn, err := o.c.GetConn(config.Config.RpcRegisterName.OpenImFriendName)
2023-02-28 11:38:05 +08:00
if err != nil {
return nil, err
}
return friend.NewFriendClient(conn), nil
}
2023-03-02 14:41:59 +08:00
func (o *Friend) ApplyToAddFriend(c *gin.Context) {
a2r.Call(friend.FriendClient.ApplyToAddFriend, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) DeleteFriend(c *gin.Context) {
a2r.Call(friend.FriendClient.DeleteFriend, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) GetFriendApplyList(c *gin.Context) {
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) GetSelfApplyList(c *gin.Context) {
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) GetFriendList(c *gin.Context) {
a2r.Call(friend.FriendClient.GetDesignatedFriends, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) RespondFriendApply(c *gin.Context) {
a2r.Call(friend.FriendClient.RespondFriendApply, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) SetFriendRemark(c *gin.Context) {
a2r.Call(friend.FriendClient.SetFriendRemark, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) AddBlack(c *gin.Context) {
a2r.Call(friend.FriendClient.AddBlack, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) GetPaginationBlacks(c *gin.Context) {
a2r.Call(friend.FriendClient.GetPaginationBlacks, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) RemoveBlack(c *gin.Context) {
a2r.Call(friend.FriendClient.RemoveBlack, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) ImportFriends(c *gin.Context) {
a2r.Call(friend.FriendClient.ImportFriends, o.client, c)
2023-02-28 11:38:05 +08:00
}
2023-03-02 14:41:59 +08:00
func (o *Friend) IsFriend(c *gin.Context) {
a2r.Call(friend.FriendClient.IsFriend, o.client, c)
2023-02-28 11:38:05 +08:00
}