From 79a39b39d9cab69aa4c8e633cf3c55cf08bf4dc2 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Thu, 30 Dec 2021 17:44:06 +0800 Subject: [PATCH] Refactor code --- internal/api/group/group.go | 9 ++++++--- internal/rpc/group/group.go | 2 +- pkg/base_info/group_api_struct.go | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/api/group/group.go b/internal/api/group/group.go index 02ea2aaa1..6ce7412cd 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -146,7 +146,7 @@ func GetGroupAllMember(c *gin.Context) { return } req := &rpc.GetGroupAllMemberReq{} - utils.CopyStructFields(req, params) + utils.CopyStructFields(req, ¶ms) var ok bool ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) if !ok { @@ -165,9 +165,12 @@ func GetGroupAllMember(c *gin.Context) { return } - memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, Data: RpcResp.MemberList} - c.JSON(http.StatusOK, memberListResp) + memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList} + if len(memberListResp.MemberList) == 0 { + memberListResp.MemberList = []*open_im_sdk.GroupMemberFullInfo{} + } log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp) + c.JSON(http.StatusOK, memberListResp) } func GetJoinedGroupList(c *gin.Context) { diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index e2327a78b..2af77fa97 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -261,7 +261,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro for _, v := range memberList { var node open_im_sdk.GroupMemberFullInfo - utils.CopyStructFields(node, v) + utils.CopyStructFields(&node, &v) resp.MemberList = append(resp.MemberList, &node) } log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", resp.String()) diff --git a/pkg/base_info/group_api_struct.go b/pkg/base_info/group_api_struct.go index 3bfa090d5..a602b790f 100644 --- a/pkg/base_info/group_api_struct.go +++ b/pkg/base_info/group_api_struct.go @@ -69,7 +69,7 @@ type GetGroupAllMemberReq struct { } type GetGroupAllMemberResp struct { CommResp - Data []*open_im_sdk.GroupMemberFullInfo `json:"data"` + MemberList []*open_im_sdk.GroupMemberFullInfo `json:"data"` } type CreateGroupReq struct {