From fb7c4114c14e7500afc193f23964adce3b6b0257 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 29 Dec 2021 14:57:36 +0800 Subject: [PATCH] Refactor code --- cmd/open_im_api/main.go | 2 +- internal/api/friend/friend.go | 4 +++- pkg/base_info/friend_api_struct.go | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index edb44e5dd..6135ee3f0 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -40,7 +40,7 @@ func main() { friendRouterGroup.POST("/remove_blacklist", friend.RemoveBlacklist) friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1 - friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) + friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1 friendRouterGroup.POST("/is_friend", friend.IsFriend) friendRouterGroup.POST("/import_friend", friend.ImportFriend) } diff --git a/internal/api/friend/friend.go b/internal/api/friend/friend.go index 9728eeb2b..1a27effb9 100644 --- a/internal/api/friend/friend.go +++ b/internal/api/friend/friend.go @@ -305,7 +305,9 @@ func IsFriend(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"}) return } - resp := api.IsFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, Response: RpcResp.Response} + resp := api.IsFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} + resp.Response.Friend = RpcResp.Response + log.NewInfo(req.CommID.OperationID, "IsFriend api return ", resp) c.JSON(http.StatusOK, resp) } diff --git a/pkg/base_info/friend_api_struct.go b/pkg/base_info/friend_api_struct.go index 361d54bd6..5d7f33d27 100644 --- a/pkg/base_info/friend_api_struct.go +++ b/pkg/base_info/friend_api_struct.go @@ -89,9 +89,12 @@ type RemoveBlackListResp struct { type IsFriendReq struct { ParamsCommFriend } +type Response struct { + Friend bool `json:"isFriend"` +} type IsFriendResp struct { CommResp - Response bool `json:"response"` + Response Response `json:"data"` } type GetFriendsInfoReq struct {