package group //import ( // common "Open_IM/internal/api_to_rpc" // api "Open_IM/pkg/api_struct" // "Open_IM/pkg/common/config" // "Open_IM/pkg/common/constant" // "Open_IM/pkg/common/log" // "Open_IM/pkg/common/token_verify" // "Open_IM/pkg/common/tracelog" // "Open_IM/pkg/getcdv3" // rpc "Open_IM/pkg/proto/group" // "Open_IM/pkg/utils" // "context" // "github.com/golang/protobuf/ptypes/wrappers" // "google.golang.org/grpc" // // "github.com/gin-gonic/gin" // // "net/http" // "strings" // // jsonData "Open_IM/internal/utils" //) // @Summary 把用户踢出群组 // @Description 把用户踢出群组 // @Tags 群组相关 // @ID KickGroupMember // @Accept json // @Param token header string true "im token" // @Param req body api.KickGroupMemberReq true "GroupID为要操作的群ID
kickedUserIDList为要踢出的群用户ID
reason为原因" // @Produce json // @Success 0 {object} api.KickGroupMemberResp "result为结果码, -1为失败, 0为成功" // @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" // @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" // @Router /group/kick_group [post] //func KickGroupMember(c *gin.Context) { // params := api.KickGroupMemberReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // if len(params.KickedUserIDList) > constant.MaxNotificationNum { // errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.KickedUserIDList))) // log.Error(params.OperationID, errMsg) // c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg}) // return // } // req := &rpc.KickGroupMemberReq{} // utils.CopyStructFields(req, ¶ms) // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "KickGroupMember args ", req.String()) // // 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.KickGroupMember(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "FindGroupMemberAll failed ", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // var memberListResp api.KickGroupMemberResp // memberListResp.ErrMsg = RpcResp.CommonResp.ErrMsg // memberListResp.ErrCode = RpcResp.CommonResp.ErrCode // for _, v := range RpcResp.Id2ResultList { // memberListResp.UserIDResultList = append(memberListResp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result}) // } // if len(memberListResp.UserIDResultList) == 0 { // memberListResp.UserIDResultList = []*api.UserIDResult{} // } // // log.NewInfo(req.OperationID, "KickGroupMember api return ", memberListResp) // c.JSON(http.StatusOK, memberListResp) //} // //// @Summary 获取群成员信息 //// @Description 获取群成员信息 //// @Tags 群组相关 //// @ID GetGroupMembersInfo //// @Accept json //// @Param token header string true "im token" //// @Param req body api.GetGroupMembersInfoReq true "groupID为要获取的群ID
memberList为要获取群成员的群ID列表" //// @Produce json //// @Success 0 {object} api.GetGroupMembersInfoResp{data=[]sdkws.GroupMemberFullInfo} //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/get_group_members_info [post] //func GetGroupMembersInfo(c *gin.Context) { // params := api.GetGroupMembersInfoReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.GetGroupMembersInfoReq{} // utils.CopyStructFields(req, params) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String()) // // 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.GetGroupMembersInfo(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "FindGroupMemberAll failed ", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList} // memberListResp.Map = jsonData.JsonDataList(RpcResp.MemberList) // log.NewInfo(req.OperationID, "GetGroupMembersInfo api return ", memberListResp) // c.JSON(http.StatusOK, memberListResp) //} // //func GetGroupMemberList(c *gin.Context) { // params := api.GetGroupMemberListReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.GetGroupMemberListReq{} // utils.CopyStructFields(req, params) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "FindGroupMemberAll args ", req.String()) // // 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.GetGroupMemberList(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "FindGroupMemberAll failed, ", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq} // memberListResp.Map = jsonData.JsonDataList(memberListResp.MemberList) // // log.NewInfo(req.OperationID, "FindGroupMemberAll api return ", memberListResp) // c.JSON(http.StatusOK, memberListResp) //} // //// @Summary 获取全部群成员列表 //// @Description 获取全部群成员列表 //// @Tags 群组相关 //// @ID GetGroupAllMemberList //// @Accept json //// @Param token header string true "im token" //// @Param req body api.GetGroupAllMemberReq true "GroupID为要获取群成员的群ID" //// @Produce json //// @Success 0 {object} api.GetGroupAllMemberResp{data=[]sdkws.GroupMemberFullInfo} //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/get_group_all_member_list [post] //func GetGroupAllMemberList(c *gin.Context) { // params := api.GetGroupAllMemberReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.GetGroupAllMemberReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String()) // // 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 // } // maxSizeOption := grpc.MaxCallRecvMsgSize(1024 * 1024 * constant.GroupRPCRecvSize) // client := rpc.NewGroupClient(etcdConn) // RpcResp, err := client.GetGroupAllMember(context.Background(), req, maxSizeOption) // if err != nil { // log.NewError(req.OperationID, "GetGroupAllMember failed err", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList} // memberListResp.Map = jsonData.JsonDataList(memberListResp.MemberList) // log.NewInfo(req.OperationID, "GetGroupAllMember api return ", len(memberListResp.MemberList)) // c.JSON(http.StatusOK, memberListResp) //} // //// @Summary 获取用户加入群列表 //// @Description 获取用户加入群列表 //// @Tags 群组相关 //// @ID GetJoinedGroupList //// @Accept json //// @Param token header string true "im token" //// @Param req body api.GetJoinedGroupListReq true "fromUserID为要获取的用户ID" //// @Produce json //// @Success 0 {object} api.GetJoinedGroupListResp{data=[]sdkws.GroupInfo} //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/get_joined_group_list [post] //func GetJoinedGroupList(c *gin.Context) { // params := api.GetJoinedGroupListReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.GetJoinedGroupListReq{} // utils.CopyStructFields(req, params) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "FindJoinedGroup args ", req.String()) // // 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.GetJoinedGroupList(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "FindJoinedGroup failed ", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // GroupListResp := 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, "FindJoinedGroup api return ", GroupListResp) // c.JSON(http.StatusOK, GroupListResp) //} // //// @Summary 将用户拉入群组 //// @Description 将用户拉入群组 //// @Tags 群组相关 //// @ID InviteUserToGroup //// @Accept json //// @Param token header string true "im token" //// @Param req body api.InviteUserToGroupReq true "groupID为要拉进的群组ID
invitedUserIDList为要获取群成员的群ID列表
reason为原因" //// @Produce json //// @Success 0 {object} api.InviteUserToGroupResp "result为结果码, -1为失败, 0为成功"" //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/invite_user_to_group [post] //func InviteUserToGroup(c *gin.Context) { // params := api.InviteUserToGroupReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // if len(params.InvitedUserIDList) > constant.MaxNotificationNum { // errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.InvitedUserIDList))) // log.Error(params.OperationID, errMsg) // c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg}) // return // } // req := &rpc.InviteUserToGroupReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String()) // // 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.InviteUserToGroup(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} // for _, v := range RpcResp.Id2ResultList { // resp.UserIDResultList = append(resp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result}) // } // // if len(resp.UserIDResultList) == 0 { // resp.UserIDResultList = *new([]*api.UserIDResult) // } // // log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 创建群组 //// @Description 创建群组 //// @Tags 群组相关 //// @ID CreateGroup //// @Accept json //// @Param token header string true "im token" //// @Param req body api.CreateGroupReq true "groupType这里填0代表普通群
groupName为群名称
introduction为群介绍
notification为群公共
ownerUserID为群主ID
ex为群扩展字段
memberList中对象roleLevel为群员角色,1为普通用户 2为群主 3为管理员" //// @Produce json //// @Success 0 {object} api.CreateGroupResp{data=sdkws.GroupInfo} //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/create_group [post] ////func CreateGroup(c *gin.Context) { //// params := api.CreateGroupReq{} //// if err := c.BindJSON(¶ms); err != nil { //// log.NewError("0", "BindJSON failed ", err.Error()) //// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) //// return //// } //// //// if len(params.MemberList) > constant.MaxNotificationNum { //// errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.MemberList))) //// log.Error(params.OperationID, errMsg) //// c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg}) //// return //// } //// req := &rpc.CreateGroupReq{GroupInfo: &sdkws.GroupInfo{}} //// utils.CopyStructFields(req.GroupInfo, ¶ms) //// //// for _, v := range params.MemberList { //// req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel}) //// } //// //// var ok bool //// var errInfo string //// ok, req.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.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg}) //// return //// } //// //// req.OwnerUserID = params.OwnerUserID //// req.OperationID = params.OperationID //// //// log.NewInfo(req.OperationID, "CreateGroup args ", req.String()) //// //// etcdConn := getcdv3.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.CreateGroup(context.Background(), req) //// if err != nil { //// log.NewError(req.OperationID, "CreateGroup failed ", err.Error(), req.String()) //// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) //// return //// } //// //// resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} //// if RpcResp.ErrCode == 0 { //// utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo) //// resp.Map = jsonData.JsonDataOne(&resp.GroupInfo) //// } //// log.NewInfo(req.OperationID, "CreateGroup api return ", resp) //// c.JSON(http.StatusOK, resp) ////} // //func NewCreateGroup(c *gin.Context) { // common.ApiToRpc(c, &api.CreateGroupReq{}, &api.CreateGroupResp{}, // config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "CreateGroup") //} // //// @Summary 获取用户收到的加群信息列表 //// @Description 获取用户收到的加群信息列表 //// @Tags 群组相关 //// @ID GetRecvGroupApplicationList //// @Accept json //// @Param token header string true "im token" //// @Param req body api.GetGroupApplicationListReq true "fromUserID为要获取的用户ID" //// @Produce json //// @Success 0 {object} api.GetGroupApplicationListResp{data=[]sdkws.GroupRequest} //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/get_recv_group_applicationList [post] //func GetRecvGroupApplicationList(c *gin.Context) { // params := api.GetGroupApplicationListReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.GetGroupApplicationListReq{} // utils.CopyStructFields(req, params) // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg}) // return // } // log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String()) // // 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) // reply, err := client.GetGroupApplicationList(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}, GroupRequestList: reply.GroupRequestList} // resp.Map = jsonData.JsonDataList(resp.GroupRequestList) // log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 获取用户加群申请列表 //// @Description 获取用户加群申请列表 //// @Tags 群组相关 //// @ID GetUserReqGroupApplicationList //// @Accept json //// @Param token header string true "im token" //// @Param req body api.GetUserReqGroupApplicationListReq true "userID为要获取的用户ID" //// @Produce json //// @Success 0 {object} api.GetGroupApplicationListResp{data=[]sdkws.GroupRequest} //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/get_user_req_group_applicationList [post] //func GetUserReqGroupApplicationList(c *gin.Context) { // common.ApiToRpc(c, &api.GetUserReqGroupApplicationListReq{}, &api.GetUserRespGroupApplicationResp{}, // config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "GetGroupApplicationList") //} // //// @Summary 通过群ID列表获取群信息 //// @Description 通过群ID列表获取群信息 //// @Tags 群组相关 //// @ID GetGroupsInfo //// @Accept json //// @Param token header string true "im token" //// @Param req body api.GetGroupInfoReq true "groupIDList为群ID列表" //// @Produce json //// @Success 0 {object} api.GetGroupInfoResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/get_groups_info [post] //func GetGroupsInfo(c *gin.Context) { // params := api.GetGroupInfoReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.GetGroupsInfoReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String()) // 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.GetGroupsInfo(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 // } // // resp := 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) //} // ////func transferGroupInfo(input []*sdkws.GroupInfo) []*api.GroupInfoAlias { //// var result []*api.GroupInfoAlias //// for _, v := range input { //// t := &api.GroupInfoAlias{} //// utils.CopyStructFields(t, &v) //// if v.NeedVerification != nil { //// t.NeedVerification = v.NeedVerification.Value //// } //// result = append(result, t) //// } //// return result ////} // ////process application // //// @Summary 处理加群消息 //// @Description 处理加群消息 //// @Tags 群组相关 //// @ID ApplicationGroupResponse //// @Accept json //// @Param token header string true "im token" //// @Param req body api.ApplicationGroupResponseReq true "groupID为要处理的群ID
fromUserID为要处理的用户ID
handleMsg为处理结果信息
handleResult为处理结果 1为同意加群 2为拒绝加群" //// @Produce json //// @Success 0 {object} api.ApplicationGroupResponseResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/group_application_response [post] //func ApplicationGroupResponse(c *gin.Context) { // params := api.ApplicationGroupResponseReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.GroupApplicationResponseReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String()) // // 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) // reply, err := client.GroupApplicationResponse(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "GroupApplicationResponse failed ", req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.ApplicationGroupResponseResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // log.NewInfo(req.OperationID, "ApplicationGroupResponse api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 加入群聊 //// @Description 加入群聊 //// @Tags 群组相关 //// @ID JoinGroup //// @Accept json //// @Param token header string true "im token" //// @Param req body api.JoinGroupReq true "reqMessage为申请进群信息
groupID为申请的群ID" //// @Produce json //// @Success 0 {object} api.JoinGroupResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/join_group [post] //func JoinGroup(c *gin.Context) { // params := api.JoinGroupReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.JoinGroupReq{} // utils.CopyStructFields(req, params) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "JoinGroup args ", req.String()) // 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.JoinGroup(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "JoinGroup failed ", err.Error(), req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) // return // } // resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg} // log.NewInfo(req.OperationID, "JoinGroup api return", RpcResp.String()) // c.JSON(http.StatusOK, resp) //} // //// @Summary 当前用户退出群聊 //// @Description 当前用户退出群聊 //// @Tags 群组相关 //// @ID QuitGroup //// @Accept json //// @Param token header string true "im token" //// @Param req body api.QuitGroupReq true "groupID为要退出的群ID" //// @Produce json //// @Success 0 {object} api.QuitGroupResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/quit_group [post] //func QuitGroup(c *gin.Context) { // params := api.QuitGroupReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.QuitGroupReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "QuitGroup args ", req.String()) // // 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.QuitGroup(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "call quit group rpc server failed,err=%s", err.Error()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) // return // } // resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg} // log.NewInfo(req.OperationID, "QuitGroup api return", RpcResp.String()) // c.JSON(http.StatusOK, resp) //} // //// @Summary 设置群信息 //// @Description 设置群信息 //// @Tags 群组相关 //// @ID SetGroupInfo //// @Accept json //// @Param token header string true "im token" //// @Param req body api.SetGroupInfoReq true "groupID为要修改的群ID
groupName为新的群名称
notification为群介绍
introduction为群公告
needVerification为加群验证 0为申请需要同意 邀请直接进 1为所有人进群需要验证,除了群主管理员邀请进群 2为直接进群" //// @Produce json //// @Success 0 {object} api.SetGroupInfoResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/set_group_info [post] ////func SetGroupInfo(c *gin.Context) { //// params := api.SetGroupInfoReq{} //// if err := c.BindJSON(¶ms); err != nil { //// log.NewError("0", "BindJSON failed ", err.Error()) //// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) //// return //// } //// req := &rpc.SetGroupInfoReq{GroupInfoForSet: &sdkws.GroupInfoForSet{}} //// utils.CopyStructFields(req.GroupInfoForSet, ¶ms) //// req.OperationID = params.OperationID //// argsHandle(¶ms, req) //// var ok bool //// var errInfo string //// ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) //// return //// } //// //// log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String()) //// //// etcdConn := getcdv3.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.SetGroupInfo(context.Background(), req) //// if err != nil { //// log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), req.String()) //// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) //// return //// } //// resp := api.SetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} //// c.JSON(http.StatusOK, resp) //// log.NewInfo(req.OperationID, "SetGroupInfo api return ", resp) ////} // //func NewSetGroupInfo(c *gin.Context) { // common.ApiToRpc(c, &api.SetGroupInfoReq{}, &api.SetGroupInfoResp{}, // config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "SetGroupInfo") //} // //func argsHandle(params *api.SetGroupInfoReq, req *rpc.SetGroupInfoReq) { // if params.NeedVerification != nil { // req.GroupInfoForSet.NeedVerification = &wrappers.Int32Value{Value: *params.NeedVerification} // log.NewInfo(req.OperationID, "NeedVerification ", req.GroupInfoForSet.NeedVerification) // } // if params.LookMemberInfo != nil { // req.GroupInfoForSet.LookMemberInfo = &wrappers.Int32Value{Value: *params.LookMemberInfo} // log.NewInfo(req.OperationID, "LookMemberInfo ", req.GroupInfoForSet.LookMemberInfo) // } // if params.ApplyMemberFriend != nil { // req.GroupInfoForSet.ApplyMemberFriend = &wrappers.Int32Value{Value: *params.ApplyMemberFriend} // log.NewInfo(req.OperationID, "ApplyMemberFriend ", req.GroupInfoForSet.ApplyMemberFriend) // } //} // //// @Summary 转让群主 //// @Description 转让群主 //// @Tags 群组相关 //// @ID TransferGroupOwner //// @Accept json //// @Param token header string true "im token" //// @Param req body api.TransferGroupOwnerReq true "GroupID为要操作的群ID
oldOwnerUserID为老群主ID
newOwnerUserID为新群主ID" //// @Produce json //// @Success 0 {object} api.TransferGroupOwnerResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/transfer_group [post] //func TransferGroupOwner(c *gin.Context) { // params := api.TransferGroupOwnerReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.TransferGroupOwnerReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String()) // // 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) // reply, err := client.TransferGroupOwner(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, "TransferGroupOwner failed ", req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.TransferGroupOwnerResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // log.NewInfo(req.OperationID, "TransferGroupOwner api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 解散群组 //// @Description 解散群组 //// @Tags 群组相关 //// @ID DismissGroup //// @Accept json //// @Param token header string true "im token" //// @Param req body api.DismissGroupReq true "groupID为要解散的群组ID" //// @Produce json //// @Success 0 {object} api.DismissGroupResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/dismiss_group [post] //func DismissGroup(c *gin.Context) { // params := api.DismissGroupReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.DismissGroupReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String()) // // 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) // reply, err := client.DismissGroup(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.DismissGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 禁言群成员 //// @Description 禁言群成员 //// @Tags 群组相关 //// @ID MuteGroupMember //// @Accept json //// @Param token header string true "im token" //// @Param req body api.MuteGroupMemberReq true "groupID为群组ID
userID为要禁言的用户ID
mutedSeconds为禁言秒数" //// @Produce json //// @Success 0 {object} api.DismissGroupResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/mute_group_member [post] //func MuteGroupMember(c *gin.Context) { // params := api.MuteGroupMemberReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.MuteGroupMemberReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) // // 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) // reply, err := client.MuteGroupMember(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.MuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 取消禁言群成员 //// @Description 取消禁言群成员 //// @Tags 群组相关 //// @ID CancelMuteGroupMember //// @Accept json //// @Param token header string true "im token" //// @Param req body api.CancelMuteGroupMemberReq true "groupID为群组ID
userID为要取消禁言的用户ID" //// @Produce json //// @Success 0 {object} api.CancelMuteGroupMemberResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/cancel_mute_group_member [post] //func CancelMuteGroupMember(c *gin.Context) { // nCtx := tracelog.NewCtx(c, utils.GetSelfFuncName()) // defer log.ShowLog(c) // // params := api.CancelMuteGroupMemberReq{} // if err := c.BindJSON(¶ms); err != nil { // tracelog.WriteErrorResponse(nCtx, "BindJSON", err) // return // } // tracelog.SetCtxInfo(nCtx, "BindJSON", nil, "params", params) // req := &rpc.CancelMuteGroupMemberReq{} // utils.CopyStructFields(req, ¶ms) // // //var err error // //if err, req.OpUserID, _ = token_verify.ParseUserIDFromToken(c.Request.Header.Get("token"), req.OperationID); err != nil { // // tracelog.WriteErrorResponse(nCtx, "ParseUserIDFromToken", err) // // return // //} // tracelog.SetCtxInfo(nCtx, "ParseUserIDFromToken", nil, "token", c.Request.Header.Get("token"), "OpUserID", req.OpUserID) // // etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID) // // client := rpc.NewGroupClient(etcdConn) // reply, err := client.CancelMuteGroupMember(nCtx, req) // if err != nil { // tracelog.WriteErrorResponse(nCtx, "CancelMuteGroupMember", err) // return // } // // tracelog.SetCtxInfo(nCtx, "CancelMuteGroupMember", nil, "req", req.String(), "resp", reply.String()) // resp := api.CancelMuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // c.JSON(http.StatusOK, resp) //} // //// @Summary 禁言群组 //// @Description 禁言群组 //// @Tags 群组相关 //// @ID MuteGroup //// @Accept json //// @Param token header string true "im token" //// @Param req body api.MuteGroupReq true "groupID为群组ID" //// @Produce json //// @Success 0 {object} api.MuteGroupResp //// @Failure 500 {object} api.MuteGroupResp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.MuteGroupResp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/mute_group [post] //func MuteGroup(c *gin.Context) { // params := api.MuteGroupReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.MuteGroupReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) // // 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) // reply, err := client.MuteGroup(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.MuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 取消禁言群组 //// @Description 取消禁言群组 //// @Tags 群组相关 //// @ID CancelMuteGroup //// @Accept json //// @Param token header string true "im token" //// @Param req body api.CancelMuteGroupReq true "groupID为群组ID" //// @Produce json //// @Success 0 {object} api.CancelMuteGroupResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/cancel_mute_group [post] //func CancelMuteGroup(c *gin.Context) { // params := api.CancelMuteGroupReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.CancelMuteGroupReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) // // 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) // reply, err := client.CancelMuteGroup(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.CancelMuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp) // c.JSON(http.StatusOK, resp) //} // ////SetGroupMemberNickname // //func SetGroupMemberNickname(c *gin.Context) { // params := api.SetGroupMemberNicknameReq{} // if err := c.BindJSON(¶ms); err != nil { // log.NewError("0", "BindJSON failed ", err.Error()) // c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) // return // } // req := &rpc.SetGroupMemberNicknameReq{} // utils.CopyStructFields(req, ¶ms) // // var ok bool // var errInfo string // ok, req.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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String()) // // 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) // reply, err := client.SetGroupMemberNickname(context.Background(), req) // if err != nil { // log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp := api.SetGroupMemberNicknameResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp) // c.JSON(http.StatusOK, resp) //} // //// @Summary 修改群成员信息 //// @Description 修改群成员信息 //// @Tags 群组相关 //// @ID SetGroupMemberInfo //// @Accept json //// @Param token header string true "im token" //// @Param req body api.SetGroupMemberInfoReq true "除了operationID, userID, groupID其他参数可选
ex为拓展字段
faceURL为群头像
nickName为群昵称
roleLevel为群员角色,1为普通用户 2为群主 3为管理员" //// @Produce json //// @Success 0 {object} api.SetGroupMemberInfoResp //// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" //// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" //// @Router /group/set_group_member_info [post] //func SetGroupMemberInfo(c *gin.Context) { // var ( // req api.SetGroupMemberInfoReq // resp api.SetGroupMemberInfoResp // ) // 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) // var opUserID string // 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // return // } // // reqPb := &rpc.SetGroupMemberInfoReq{ // GroupID: req.GroupID, // UserID: req.UserID, // OperationID: req.OperationID, // OpUserID: opUserID, // } // if req.Nickname != nil { // reqPb.Nickname = &wrappers.StringValue{Value: *req.Nickname} // } // if req.FaceURL != nil { // reqPb.FaceURL = &wrappers.StringValue{Value: *req.FaceURL} // } // if req.Ex != nil { // reqPb.Ex = &wrappers.StringValue{Value: *req.Ex} // } // if req.RoleLevel != nil { // reqPb.RoleLevel = &wrappers.Int32Value{Value: *req.RoleLevel} // } // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", reqPb.String()) // 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) // respPb, err := client.SetGroupMemberInfo(context.Background(), reqPb) // if err != nil { // log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", err.Error()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // return // } // // resp.ErrMsg = respPb.CommonResp.ErrMsg // resp.ErrCode = respPb.CommonResp.ErrCode // log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp) // c.JSON(http.StatusOK, resp) //} // //func GetGroupAbstractInfo(c *gin.Context) { // type GetGroupAbstractInfoReq struct { // //OperationID string `json:"operationID"` // GroupID string `json:"groupID"` // } // type GetGroupAbstractInfoResp struct { // GroupMemberNumber int32 `json:"groupMemberNumber"` // GroupMemberListHash uint64 `json:"groupMemberListHash"` // } // //common.ApiToRpc(c, &api.GetGroupAbstractInfoReq{}, &GetGroupAbstractInfoResp{}, config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, utils.GetSelfFuncName(), token_verify.ParseUserIDFromToken) // common.ApiToRpc(c, &api.GetGroupAbstractInfoReq{}, &GetGroupAbstractInfoResp{}, config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, utils.GetSelfFuncName()) // // //var ( // //req api.GetGroupAbstractInfoReq // //resp api.GetGroupAbstractInfoResp // //) // //nCtx := tracelog.NewCtx(c, utils.GetSelfFuncName()) // //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 // //} // //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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) // // return // //} // // // //etcdConn := getcdv3.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) // //md := metadata.Pairs("operationID", req.OperationID, "opUserID", opUserID) // //respPb, err := client.GetGroupAbstractInfo(metadata.NewOutgoingContext(c, md), &rpc.GetGroupAbstractInfoReq{ // // GroupID: req.GroupID, // // OpUserID: opUserID, // // OperationID: req.OperationID, // //}) // //log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", respPb.String()) // //if err != nil { // // //log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", err.Error()) // // //c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) // // tracelog.WriteErrorResponse(nCtx, "GetGroupAbstractInfo", utils.Wrap(err, "")) // // return // //} // //resp.GroupMemberNumber = respPb.GroupMemberNumber // //resp.GroupMemberListHash = respPb.GroupMemberListHash // //log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp) // //c.JSON(http.StatusOK, resp) // //return //}