mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
group api
This commit is contained in:
+119
-1244
File diff suppressed because it is too large
Load Diff
@@ -1,36 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"OpenIM/internal/a2r"
|
||||
"OpenIM/pkg/common/config"
|
||||
"OpenIM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/OpenIMSDK/openKeeper"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var _ context.Context = nil // 解决goland编辑器bug
|
||||
|
||||
func NewGroup(zk *openKeeper.ZkClient) *Group {
|
||||
return &Group{zk: zk}
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
zk *openKeeper.ZkClient
|
||||
}
|
||||
|
||||
func (g *Group) getGroupClient() (group.GroupClient, error) {
|
||||
conn, err := g.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return group.NewGroupClient(conn), nil
|
||||
}
|
||||
|
||||
func (g *Group) KickGroupMember(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.KickGroupMember, g.getGroupClient, c)
|
||||
}
|
||||
|
||||
func (g *Group) GetGroupMembersInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupMembersInfo, g.getGroupClient, c)
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package group
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
var g Group
|
||||
|
||||
g.KickGroupMember(nil)
|
||||
g.GetGroupMembersInfo(nil)
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package group
|
||||
|
||||
//import (
|
||||
// jsonData "OpenIM/internal/utils"
|
||||
// api "OpenIM/pkg/apistruct"
|
||||
// "OpenIM/pkg/common/config"
|
||||
// "OpenIM/pkg/common/log"
|
||||
// "OpenIM/pkg/common/token_verify"
|
||||
// "OpenIM/pkg/getcdv3"
|
||||
// rpc "OpenIM/pkg/proto/group"
|
||||
// "OpenIM/pkg/utils"
|
||||
// "context"
|
||||
// "github.com/gin-gonic/gin"
|
||||
// "net/http"
|
||||
// "strings"
|
||||
//)
|
||||
//
|
||||
//func GetJoinedSuperGroupList(c *gin.Context) {
|
||||
// req := api.GetJoinedSuperGroupListReq{}
|
||||
// if err := c.BindJSON(&req); err != nil {
|
||||
// log.NewError("0", "BindJSON failed ", err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
// return
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
// ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
// if !ok {
|
||||
// errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
// log.NewError(req.OperationID, errMsg)
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
// return
|
||||
// }
|
||||
// reqPb := rpc.GetJoinedSuperGroupListReq{OperationID: req.OperationID, OpUserID: opUserID, UserID: req.FromUserID}
|
||||
// etcdConn := rpc.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)
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
// return
|
||||
// }
|
||||
// client := rpc.NewGroupClient(etcdConn)
|
||||
// rpcResp, err := client.GetJoinedSuperGroupList(context.Background(), &reqPb)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), reqPb.String())
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
// return
|
||||
// }
|
||||
// GroupListResp := api.GetJoinedSuperGroupListResp{GetJoinedGroupListResp: api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupList}}
|
||||
// GroupListResp.Map = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
||||
// log.NewInfo(req.OperationID, "GetJoinedSuperGroupList api return ", GroupListResp)
|
||||
// c.JSON(http.StatusOK, GroupListResp)
|
||||
//}
|
||||
//
|
||||
//func GetSuperGroupsInfo(c *gin.Context) {
|
||||
// req := api.GetSuperGroupsInfoReq{}
|
||||
// if err := c.BindJSON(&req); err != nil {
|
||||
// log.NewError("0", "BindJSON failed ", err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
// return
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
// ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
// if !ok {
|
||||
// errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
// log.NewError(req.OperationID, errMsg)
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
// return
|
||||
// }
|
||||
// reqPb := rpc.GetSuperGroupsInfoReq{OperationID: req.OperationID, OpUserID: opUserID, GroupIDList: req.GroupIDList}
|
||||
// etcdConn := rpc.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)
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
// return
|
||||
// }
|
||||
// client := rpc.NewGroupClient(etcdConn)
|
||||
// rpcResp, err := client.GetSuperGroupsInfo(context.Background(), &reqPb)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), reqPb.String())
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// resp := api.GetSuperGroupsInfoResp{GetGroupInfoResp: api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupInfoList}}
|
||||
// resp.Map = jsonData.JsonDataList(resp.GroupInfoList)
|
||||
// log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||
// c.JSON(http.StatusOK, resp)
|
||||
//}
|
||||
Reference in New Issue
Block a user