提交 9bee5c79 编写于 作者: W wenxu12345

Refactor code

上级 aab6ad96
package friend
import (
jsonData "Open_IM/internal/utils"
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
......@@ -214,10 +215,11 @@ func GetBlacklist(c *gin.Context) {
resp := api.GetBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
for _, v := range RpcResp.BlackUserInfoList {
black := api.BlackUserInfo{}
black := open_im_sdk.PublicUserInfo{}
utils.CopyStructFields(&black, v)
resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
}
resp.Data = jsonData.JsonDataList(resp.BlackUserInfoList)
log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
c.JSON(http.StatusOK, resp)
}
......@@ -381,9 +383,7 @@ func GetFriendList(c *gin.Context) {
}
resp := api.GetFriendListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendInfoList: RpcResp.FriendInfoList}
if len(resp.FriendInfoList) == 0 {
resp.FriendInfoList = []*open_im_sdk.FriendInfo{}
}
resp.Data = jsonData.JsonDataList(resp.FriendInfoList)
log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
c.JSON(http.StatusOK, resp)
}
......@@ -417,9 +417,7 @@ func GetFriendApplyList(c *gin.Context) {
}
resp := api.GetFriendApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
if len(resp.FriendRequestList) == 0 {
resp.FriendRequestList = []*open_im_sdk.FriendRequest{}
}
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
c.JSON(http.StatusOK, resp)
}
......@@ -451,9 +449,7 @@ func GetSelfApplyList(c *gin.Context) {
return
}
resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
if len(resp.FriendRequestList) == 0 {
resp.FriendRequestList = []*open_im_sdk.FriendRequest{}
}
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
c.JSON(http.StatusOK, resp)
}
......@@ -271,6 +271,7 @@ func CreateGroup(c *gin.Context) {
resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
if RpcResp.ErrCode == 0 {
utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
resp.Data = jsonData.JsonDataOne(&resp.GroupInfo)
}
log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
c.JSON(http.StatusOK, resp)
......@@ -305,9 +306,7 @@ func GetGroupApplicationList(c *gin.Context) {
}
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
if len(resp.GroupRequestList) == 0 {
resp.GroupRequestList = []*open_im_sdk.GroupRequest{}
}
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
c.JSON(http.StatusOK, resp)
}
......@@ -340,9 +339,7 @@ func GetGroupsInfo(c *gin.Context) {
}
resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
if len(resp.GroupInfoList) == 0 {
resp.GroupInfoList = []*open_im_sdk.GroupInfo{}
}
resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
......
package user
import (
jsonData "Open_IM/internal/utils"
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
......@@ -43,6 +44,7 @@ func GetUserInfo(c *gin.Context) {
}
resp := api.GetUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: RpcResp.UserInfoList}
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
......
......@@ -39,8 +39,6 @@ type AddFriendResp struct {
type AddFriendResponseReq struct {
ParamsCommFriend
//binding:"oneof=0 1 2"`
//}
Flag int32 `json:"flag" binding:"required,oneof=-1 0 1"`
HandleMsg string `json:"handleMsg"`
}
......@@ -61,7 +59,8 @@ type GetBlackListReq struct {
}
type GetBlackListResp struct {
CommResp
BlackUserInfoList []*BlackUserInfo `json:"data"`
BlackUserInfoList []*open_im_sdk.PublicUserInfo
Data []map[string]interface{} `json:"data"`
}
//type PublicUserInfo struct {
......@@ -71,10 +70,6 @@ type GetBlackListResp struct {
// Gender int32 `json:"gender"`
//}
type BlackUserInfo struct {
open_im_sdk.PublicUserInfo
}
type SetFriendRemarkReq struct {
ParamsCommFriend
Remark string `json:"remark" binding:"required"`
......@@ -106,7 +101,8 @@ type GetFriendsInfoReq struct {
}
type GetFriendsInfoResp struct {
CommResp
FriendInfoList []*open_im_sdk.FriendInfo `json:"data"`
FriendInfoList []*open_im_sdk.FriendInfo
Data []map[string]interface{} `json:"data"`
}
type GetFriendListReq struct {
......@@ -115,7 +111,8 @@ type GetFriendListReq struct {
}
type GetFriendListResp struct {
CommResp
FriendInfoList []*open_im_sdk.FriendInfo `json:"data"`
FriendInfoList []*open_im_sdk.FriendInfo
Data []map[string]interface{} `json:"data"`
}
type GetFriendApplyListReq struct {
......@@ -124,7 +121,8 @@ type GetFriendApplyListReq struct {
}
type GetFriendApplyListResp struct {
CommResp
FriendRequestList []*open_im_sdk.FriendRequest `json:"data"`
FriendRequestList []*open_im_sdk.FriendRequest
Data []map[string]interface{} `json:"data"`
}
type GetSelfApplyListReq struct {
......@@ -133,5 +131,6 @@ type GetSelfApplyListReq struct {
}
type GetSelfApplyListResp struct {
CommResp
FriendRequestList []*open_im_sdk.FriendRequest `json:"data"`
FriendRequestList []*open_im_sdk.FriendRequest
Data []map[string]interface{} `json:"data"`
}
......@@ -73,8 +73,7 @@ type GetGroupAllMemberReq struct {
type GetGroupAllMemberResp struct {
CommResp
MemberList []*open_im_sdk.GroupMemberFullInfo
Data []map[string]interface{} `json:"data"`
Data []map[string]interface{} `json:"data"`
}
type CreateGroupReq struct {
......@@ -84,10 +83,10 @@ type CreateGroupReq struct {
GroupType int32 `json:"groupType"`
OperationID string `json:"operationID" binding:"required"`
}
type CreateGroupResp struct {
CommResp
GroupInfo open_im_sdk.GroupInfo `json:"data"`
GroupInfo open_im_sdk.GroupInfo
Data map[string]interface{} `json:"data"`
}
type GetGroupApplicationListReq struct {
......
......@@ -10,7 +10,8 @@ type GetUserInfoReq struct {
}
type GetUserInfoResp struct {
CommResp
UserInfoList []*open_im_sdk.UserInfo `json:"data"`
UserInfoList []*open_im_sdk.UserInfo
Data []map[string]interface{} `json:"data"`
}
type UpdateUserInfoReq struct {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册