提交 18902029 编写于 作者: W wenxu12345

Merge remote-tracking branch 'origin/tuoyun' into tuoyun

......@@ -58,6 +58,7 @@ func main() {
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
......
......@@ -47,6 +47,7 @@ require (
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
google.golang.org/grpc v1.40.0
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
......
......@@ -290,13 +290,13 @@ func GetRecvGroupApplicationList(c *gin.Context) {
}
req := &rpc.GetGroupApplicationListReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
//var ok bool
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//if !ok {
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
//}
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
......@@ -314,6 +314,37 @@ func GetRecvGroupApplicationList(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
func GetUserReqGroupApplicationList(c *gin.Context) {
var params api.GetUserReqGroupApplicationListReq
if err := c.BindJSON(&params); err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetUserReqApplicationListReq{}
utils.CopyStructFields(req, params)
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//if !ok {
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
//}
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetUserReqApplicationList(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
log.NewInfo(req.OperationID, RpcResp)
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupRequestList: RpcResp.GroupRequestList}
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
c.JSON(http.StatusOK, resp)
}
func GetGroupsInfo(c *gin.Context) {
params := api.GetGroupInfoReq{}
if err := c.BindJSON(&params); err != nil {
......
......@@ -638,3 +638,41 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
}
func (s *groupServer) GetUserReqApplicationList(_ context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbGroup.GetUserReqApplicationListResp{}
groupRequests, err := imdb.GetUserReqGroupByUserID(req.UserID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserReqGroupByUserID failed ", err.Error())
resp.CommonResp = &pbGroup.CommonResp{
ErrCode: constant.ErrDB.ErrCode,
ErrMsg: constant.ErrDB.ErrMsg,
}
return resp, nil
}
for _, groupReq := range groupRequests {
node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}}
group, err := imdb.GetGroupInfoByGroupID(groupReq.GroupID)
if err != nil {
log.Error(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), groupReq.GroupID)
continue
}
user, err := imdb.GetUserByUserID(groupReq.UserID)
if err != nil {
log.Error(req.OperationID, "GetUserByUserID failed ", err.Error(), groupReq.UserID)
continue
}
cp.GroupRequestDBCopyOpenIM(&node, &groupReq)
cp.UserDBCopyOpenIMPublicUser(node.UserInfo, user)
cp.GroupDBCopyOpenIM(node.GroupInfo, group)
resp.GroupRequestList = append(resp.GroupRequestList, &node)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupRequests)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "output:", resp)
resp.CommonResp = &pbGroup.CommonResp{
ErrCode: 0,
ErrMsg: "",
}
return resp, nil
}
\ No newline at end of file
......@@ -103,6 +103,16 @@ type GetGroupApplicationListResp struct {
Data []map[string]interface{} `json:"data"`
}
type GetUserReqGroupApplicationListReq struct {
OperationID string `json:"operationID" binding:"required"`
UserID string `json:"userID" binding:"required"`
}
type GetUserRespGroupApplicationResp struct {
CommResp
GroupRequestList []*open_im_sdk.GroupRequest `json:"-"`
}
type GetGroupInfoReq struct {
GroupIDList []string `json:"groupIDList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
......
......@@ -225,6 +225,7 @@ func IsGroupOwnerAdmin(groupID, UserID string) bool {
return false
}
//
//func SelectGroupList(groupID string) ([]string, error) {
// var groupUserID string
......
......@@ -117,6 +117,18 @@ func GetGroupApplicationList(userID string) ([]db.GroupRequest, error) {
return groupRequestList, nil
}
func GetUserReqGroupByUserID(userID string) ([]db.GroupRequest, error) {
var groupRequestList []db.GroupRequest
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return nil, err
}
dbConn.LogMode(true)
err = dbConn.Table("group_requests").Where("user_id=?", userID).Find(&groupRequestList).Error
return groupRequestList, err
}
//
//func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.CommonResp, error) {
//
......
此差异已折叠。
......@@ -61,6 +61,17 @@ message GetGroupApplicationListResp {
repeated server_api_params.GroupRequest GroupRequestList = 3;
}
message GetUserReqApplicationListReq{
string UserID = 1;
string OpUserID = 2;
string OperationID = 3;
}
message GetUserReqApplicationListResp{
CommonResp CommonResp = 1;
repeated server_api_params.GroupRequest GroupRequestList = 2;
}
message TransferGroupOwnerReq {
string GroupID = 1;
......@@ -204,6 +215,7 @@ service group{
rpc getGroupsInfo(GetGroupsInfoReq) returns(GetGroupsInfoResp);
rpc setGroupInfo(SetGroupInfoReq) returns(SetGroupInfoResp);
rpc getGroupApplicationList(GetGroupApplicationListReq) returns(GetGroupApplicationListResp);
rpc getUserReqApplicationList(GetUserReqApplicationListReq) returns(GetUserReqApplicationListResp);
rpc transferGroupOwner(TransferGroupOwnerReq) returns(TransferGroupOwnerResp);
rpc groupApplicationResponse(GroupApplicationResponseReq) returns(GroupApplicationResponseResp);
rpc getGroupMemberList(GetGroupMemberListReq) returns(GetGroupMemberListResp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册