mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Refactor code
This commit is contained in:
parent
ef67aa9e48
commit
8cd38693dd
@ -69,16 +69,18 @@ func ImportFriend(c *gin.Context) {
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed " + err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed "})
|
||||
return
|
||||
}
|
||||
resp := api.ImportFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
if resp.ErrCode == 0 {
|
||||
for _, v := range RpcResp.UserIDResultList {
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, api.UserIDResult{v.UserID, v.Result})
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, api.UserIDResult{UserID: v.UserID, Result: v.Result})
|
||||
}
|
||||
}
|
||||
|
||||
if len(resp.UserIDResultList) == 0 {
|
||||
resp.UserIDResultList = []api.UserIDResult{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "ImportFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ type ImportFriendReq struct {
|
||||
FromUserID string `json:"fromUserID" binding:"required"`
|
||||
}
|
||||
type UserIDResult struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
Result int32 `json:"result" binding:"required"`
|
||||
UserID string `json:"userID""`
|
||||
Result int32 `json:"result"`
|
||||
}
|
||||
type ImportFriendResp struct {
|
||||
CommResp
|
||||
|
Loading…
x
Reference in New Issue
Block a user