From bd14e5019f5972bd048cdf82804858ef7e6ead60 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Thu, 30 Dec 2021 16:19:06 +0800 Subject: [PATCH] Refactor code --- cmd/open_im_api/main.go | 10 +++++----- internal/api/group/group.go | 10 +++++----- pkg/base_info/group_api_struct.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index f2a0a7793..8efc36ab1 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -38,11 +38,11 @@ func main() { friendRouterGroup.POST("/add_blacklist", friend.AddBlacklist) //1 friendRouterGroup.POST("/get_blacklist", friend.GetBlacklist) //1 friendRouterGroup.POST("/remove_blacklist", friend.RemoveBlacklist) //1 - friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) - friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1 - friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1 - friendRouterGroup.POST("/is_friend", friend.IsFriend) //1 - friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1 + friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) //1 + friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1 + friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1 + friendRouterGroup.POST("/is_friend", friend.IsFriend) //1 + friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1 } //group related routing group groupRouterGroup := r.Group("/group") diff --git a/internal/api/group/group.go b/internal/api/group/group.go index 790836089..f400154aa 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -197,7 +197,7 @@ func InviteUserToGroup(c *gin.Context) { return } req := &rpc.InviteUserToGroupReq{} - utils.CopyStructFields(req, params) + utils.CopyStructFields(req, ¶ms) var ok bool ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) if !ok { @@ -216,12 +216,12 @@ func InviteUserToGroup(c *gin.Context) { return } - Resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} + resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} for _, v := range RpcResp.Id2ResultList { - Resp.UserIDResultList = append(Resp.UserIDResultList, api.UserIDResult{UserID: v.UserID, Result: v.Result}) + resp.UserIDResultList = append(resp.UserIDResultList, api.UserIDResult{UserID: v.UserID, Result: v.Result}) } - c.JSON(http.StatusOK, Resp) - log.NewInfo(req.OperationID, "InviteUserToGroup api return ", Resp) + c.JSON(http.StatusOK, resp) + log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp) } func CreateGroup(c *gin.Context) { diff --git a/pkg/base_info/group_api_struct.go b/pkg/base_info/group_api_struct.go index 7c14bb7b4..690506146 100644 --- a/pkg/base_info/group_api_struct.go +++ b/pkg/base_info/group_api_struct.go @@ -33,7 +33,7 @@ type GetGroupMembersInfoResp struct { type InviteUserToGroupReq struct { GroupID string `json:"groupID" binding:"required"` - InvitedUserIDList []string `json:"uidList" binding:"required"` + InvitedUserIDList []string `json:"invitedUserIDList" binding:"required"` Reason string `json:"reason"` OperationID string `json:"operationID" binding:"required"` }