mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-24 02:16:16 +08:00
Refactor code
This commit is contained in:
parent
aab6ad96eb
commit
9bee5c79c8
@ -1,6 +1,7 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
jsonData "Open_IM/internal/utils"
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/base_info"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"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}}
|
resp := api.GetBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||||
for _, v := range RpcResp.BlackUserInfoList {
|
for _, v := range RpcResp.BlackUserInfoList {
|
||||||
black := api.BlackUserInfo{}
|
black := open_im_sdk.PublicUserInfo{}
|
||||||
utils.CopyStructFields(&black, v)
|
utils.CopyStructFields(&black, v)
|
||||||
resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
|
resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
|
||||||
}
|
}
|
||||||
|
resp.Data = jsonData.JsonDataList(resp.BlackUserInfoList)
|
||||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
|
log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
|
||||||
c.JSON(http.StatusOK, 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}
|
resp := api.GetFriendListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendInfoList: RpcResp.FriendInfoList}
|
||||||
if len(resp.FriendInfoList) == 0 {
|
resp.Data = jsonData.JsonDataList(resp.FriendInfoList)
|
||||||
resp.FriendInfoList = []*open_im_sdk.FriendInfo{}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
|
log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
|
||||||
c.JSON(http.StatusOK, 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}
|
resp := api.GetFriendApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||||
if len(resp.FriendRequestList) == 0 {
|
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
||||||
resp.FriendRequestList = []*open_im_sdk.FriendRequest{}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
|
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
@ -451,9 +449,7 @@ func GetSelfApplyList(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||||
if len(resp.FriendRequestList) == 0 {
|
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
||||||
resp.FriendRequestList = []*open_im_sdk.FriendRequest{}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
|
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
|
||||||
c.JSON(http.StatusOK, 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}}
|
resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||||
if RpcResp.ErrCode == 0 {
|
if RpcResp.ErrCode == 0 {
|
||||||
utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
|
utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
|
||||||
|
resp.Data = jsonData.JsonDataOne(&resp.GroupInfo)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
|
log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
|
||||||
c.JSON(http.StatusOK, 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}
|
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
||||||
if len(resp.GroupRequestList) == 0 {
|
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
|
||||||
resp.GroupRequestList = []*open_im_sdk.GroupRequest{}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||||
c.JSON(http.StatusOK, 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}
|
resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
|
||||||
if len(resp.GroupInfoList) == 0 {
|
resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
|
||||||
resp.GroupInfoList = []*open_im_sdk.GroupInfo{}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
jsonData "Open_IM/internal/utils"
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/base_info"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"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 := 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)
|
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,6 @@ type AddFriendResp struct {
|
|||||||
|
|
||||||
type AddFriendResponseReq struct {
|
type AddFriendResponseReq struct {
|
||||||
ParamsCommFriend
|
ParamsCommFriend
|
||||||
//binding:"oneof=0 1 2"`
|
|
||||||
//}
|
|
||||||
Flag int32 `json:"flag" binding:"required,oneof=-1 0 1"`
|
Flag int32 `json:"flag" binding:"required,oneof=-1 0 1"`
|
||||||
HandleMsg string `json:"handleMsg"`
|
HandleMsg string `json:"handleMsg"`
|
||||||
}
|
}
|
||||||
@ -61,7 +59,8 @@ type GetBlackListReq struct {
|
|||||||
}
|
}
|
||||||
type GetBlackListResp struct {
|
type GetBlackListResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
BlackUserInfoList []*BlackUserInfo `json:"data"`
|
BlackUserInfoList []*open_im_sdk.PublicUserInfo
|
||||||
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//type PublicUserInfo struct {
|
//type PublicUserInfo struct {
|
||||||
@ -71,10 +70,6 @@ type GetBlackListResp struct {
|
|||||||
// Gender int32 `json:"gender"`
|
// Gender int32 `json:"gender"`
|
||||||
//}
|
//}
|
||||||
|
|
||||||
type BlackUserInfo struct {
|
|
||||||
open_im_sdk.PublicUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetFriendRemarkReq struct {
|
type SetFriendRemarkReq struct {
|
||||||
ParamsCommFriend
|
ParamsCommFriend
|
||||||
Remark string `json:"remark" binding:"required"`
|
Remark string `json:"remark" binding:"required"`
|
||||||
@ -106,7 +101,8 @@ type GetFriendsInfoReq struct {
|
|||||||
}
|
}
|
||||||
type GetFriendsInfoResp struct {
|
type GetFriendsInfoResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
FriendInfoList []*open_im_sdk.FriendInfo `json:"data"`
|
FriendInfoList []*open_im_sdk.FriendInfo
|
||||||
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetFriendListReq struct {
|
type GetFriendListReq struct {
|
||||||
@ -115,7 +111,8 @@ type GetFriendListReq struct {
|
|||||||
}
|
}
|
||||||
type GetFriendListResp struct {
|
type GetFriendListResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
FriendInfoList []*open_im_sdk.FriendInfo `json:"data"`
|
FriendInfoList []*open_im_sdk.FriendInfo
|
||||||
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetFriendApplyListReq struct {
|
type GetFriendApplyListReq struct {
|
||||||
@ -124,7 +121,8 @@ type GetFriendApplyListReq struct {
|
|||||||
}
|
}
|
||||||
type GetFriendApplyListResp struct {
|
type GetFriendApplyListResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
FriendRequestList []*open_im_sdk.FriendRequest `json:"data"`
|
FriendRequestList []*open_im_sdk.FriendRequest
|
||||||
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetSelfApplyListReq struct {
|
type GetSelfApplyListReq struct {
|
||||||
@ -133,5 +131,6 @@ type GetSelfApplyListReq struct {
|
|||||||
}
|
}
|
||||||
type GetSelfApplyListResp struct {
|
type GetSelfApplyListResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
FriendRequestList []*open_im_sdk.FriendRequest `json:"data"`
|
FriendRequestList []*open_im_sdk.FriendRequest
|
||||||
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,6 @@ type GetGroupAllMemberReq struct {
|
|||||||
type GetGroupAllMemberResp struct {
|
type GetGroupAllMemberResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
MemberList []*open_im_sdk.GroupMemberFullInfo
|
MemberList []*open_im_sdk.GroupMemberFullInfo
|
||||||
|
|
||||||
Data []map[string]interface{} `json:"data"`
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +83,10 @@ type CreateGroupReq struct {
|
|||||||
GroupType int32 `json:"groupType"`
|
GroupType int32 `json:"groupType"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateGroupResp struct {
|
type CreateGroupResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
GroupInfo open_im_sdk.GroupInfo `json:"data"`
|
GroupInfo open_im_sdk.GroupInfo
|
||||||
|
Data map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupApplicationListReq struct {
|
type GetGroupApplicationListReq struct {
|
||||||
|
@ -10,7 +10,8 @@ type GetUserInfoReq struct {
|
|||||||
}
|
}
|
||||||
type GetUserInfoResp struct {
|
type GetUserInfoResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
UserInfoList []*open_im_sdk.UserInfo `json:"data"`
|
UserInfoList []*open_im_sdk.UserInfo
|
||||||
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateUserInfoReq struct {
|
type UpdateUserInfoReq struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user