diff --git a/internal/api/friend/friend.go b/internal/api/friend/friend.go index 973317838..ac3e49c12 100644 --- a/internal/api/friend/friend.go +++ b/internal/api/friend/friend.go @@ -68,17 +68,19 @@ func ImportFriend(c *gin.Context) { client := rpc.NewFriendClient(etcdConn) 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()}) + log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String()) + 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) } diff --git a/pkg/base_info/friend_api_struct.go b/pkg/base_info/friend_api_struct.go index 18c429471..653730fc0 100644 --- a/pkg/base_info/friend_api_struct.go +++ b/pkg/base_info/friend_api_struct.go @@ -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