nil return modify

pull/131/head
Gordon 3 years ago
parent 447ccdf042
commit c4fca3b23d

@ -39,8 +39,10 @@ func GetAllConversationMessageOpt(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return return
} }
resp := api.GetAllConversationMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} resp := api.GetAllConversationMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ConversationOptResultList: RpcResp.ConversationOptResultList}
resp.ConversationOptResultList = RpcResp.ConversationOptResultList if len(RpcResp.ConversationOptResultList) == 0 {
resp.ConversationOptResultList = []*user.OptResult{}
}
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt api return: ", resp) log.NewInfo(req.OperationID, "GetAllConversationMsgOpt api return: ", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
} }
@ -69,8 +71,10 @@ func GetReceiveMessageOpt(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetReceiveMessageOpt rpc failed, " + err.Error()}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetReceiveMessageOpt rpc failed, " + err.Error()})
return return
} }
resp := api.GetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} resp := api.GetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ConversationOptResultList: RpcResp.ConversationOptResultList}
resp.ConversationOptResultList = RpcResp.ConversationOptResultList if len(RpcResp.ConversationOptResultList) == 0 {
resp.ConversationOptResultList = []*user.OptResult{}
}
log.NewInfo(req.OperationID, "GetReceiveMessageOpt api return: ", resp) log.NewInfo(req.OperationID, "GetReceiveMessageOpt api return: ", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
} }
@ -99,8 +103,10 @@ func SetReceiveMessageOpt(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "SetReceiveMessageOpt rpc failed, " + err.Error()}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "SetReceiveMessageOpt rpc failed, " + err.Error()})
return return
} }
resp := api.SetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} resp := api.SetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, OptResultList: RpcResp.OptResultList}
resp.OptResultList = RpcResp.OptResultList if len(RpcResp.OptResultList) == 0 {
resp.OptResultList = []*user.OptResult{}
}
log.NewInfo(req.OperationID, "SetReceiveMessageOpt api return: ", resp) log.NewInfo(req.OperationID, "SetReceiveMessageOpt api return: ", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
} }

@ -47,12 +47,10 @@ func DeleteUser(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
return return
} }
failedUserIDList := make([]string, 0) resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FailedUserIDList: RpcResp.FailedUserIDList}
for _, v := range RpcResp.FailedUserIDList { if len(RpcResp.FailedUserIDList) == 0 {
failedUserIDList = append(failedUserIDList, v) resp.FailedUserIDList = []string{}
} }
resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
resp.FailedUserIDList = failedUserIDList
log.NewInfo(req.OperationID, "DeleteUser api return", resp) log.NewInfo(req.OperationID, "DeleteUser api return", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
} }
@ -80,12 +78,10 @@ func GetAllUsersUid(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call GetAllUsersUid users rpc server failed"}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call GetAllUsersUid users rpc server failed"})
return return
} }
userIDList := make([]string, 0) resp := api.GetAllUsersUidResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserIDList: RpcResp.UserIDList}
for _, v := range RpcResp.UserIDList { if len(RpcResp.UserIDList) == 0 {
userIDList = append(userIDList, v) resp.UserIDList = []string{}
} }
resp := api.GetAllUsersUidResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
resp.UserIDList = userIDList
log.NewInfo(req.OperationID, "GetAllUsersUid api return", resp) log.NewInfo(req.OperationID, "GetAllUsersUid api return", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
@ -115,8 +111,10 @@ func AccountCheck(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call AccountCheck users rpc server failed"}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call AccountCheck users rpc server failed"})
return return
} }
resp := api.AccountCheckResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} resp := api.AccountCheckResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ResultList: RpcResp.ResultList}
resp.ResultList = RpcResp.ResultList if len(RpcResp.ResultList) == 0 {
resp.ResultList = []*rpc.AccountCheckResp_SingleUserStatus{}
}
log.NewInfo(req.OperationID, "AccountCheck api return", resp) log.NewInfo(req.OperationID, "AccountCheck api return", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
} }
@ -172,8 +170,10 @@ func GetUsersOnlineStatus(c *gin.Context) {
} }
respResult = append(respResult, temp) respResult = append(respResult, temp)
} }
resp := api.GetUsersOnlineStatusResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}} resp := api.GetUsersOnlineStatusResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, SuccessResult: respResult}
resp.SuccessResult = respResult if len(respResult) == 0 {
resp.SuccessResult = []*pbRelay.GetUsersOnlineStatusResp_SuccessResult{}
}
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp) log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)

Loading…
Cancel
Save