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()})
return
}
resp := api.GetAllConversationMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
resp.ConversationOptResultList = RpcResp.ConversationOptResultList
resp := api.GetAllConversationMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ConversationOptResultList: RpcResp.ConversationOptResultList}
if len(RpcResp.ConversationOptResultList) == 0 {
resp.ConversationOptResultList = []*user.OptResult{}
}
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt api return: ", 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()})
return
}
resp := api.GetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
resp.ConversationOptResultList = RpcResp.ConversationOptResultList
resp := api.GetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ConversationOptResultList: RpcResp.ConversationOptResultList}
if len(RpcResp.ConversationOptResultList) == 0 {
resp.ConversationOptResultList = []*user.OptResult{}
}
log.NewInfo(req.OperationID, "GetReceiveMessageOpt api return: ", 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()})
return
}
resp := api.SetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
resp.OptResultList = RpcResp.OptResultList
resp := api.SetReceiveMessageOptResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, OptResultList: RpcResp.OptResultList}
if len(RpcResp.OptResultList) == 0 {
resp.OptResultList = []*user.OptResult{}
}
log.NewInfo(req.OperationID, "SetReceiveMessageOpt api return: ", 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"})
return
}
failedUserIDList := make([]string, 0)
for _, v := range RpcResp.FailedUserIDList {
failedUserIDList = append(failedUserIDList, v)
resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FailedUserIDList: RpcResp.FailedUserIDList}
if len(RpcResp.FailedUserIDList) == 0 {
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)
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"})
return
}
userIDList := make([]string, 0)
for _, v := range RpcResp.UserIDList {
userIDList = append(userIDList, v)
resp := api.GetAllUsersUidResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserIDList: RpcResp.UserIDList}
if len(RpcResp.UserIDList) == 0 {
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)
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"})
return
}
resp := api.AccountCheckResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
resp.ResultList = RpcResp.ResultList
resp := api.AccountCheckResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ResultList: RpcResp.ResultList}
if len(RpcResp.ResultList) == 0 {
resp.ResultList = []*rpc.AccountCheckResp_SingleUserStatus{}
}
log.NewInfo(req.OperationID, "AccountCheck api return", resp)
c.JSON(http.StatusOK, resp)
}
@ -172,8 +170,10 @@ func GetUsersOnlineStatus(c *gin.Context) {
}
respResult = append(respResult, temp)
}
resp := api.GetUsersOnlineStatusResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}}
resp.SuccessResult = respResult
resp := api.GetUsersOnlineStatusResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, SuccessResult: respResult}
if len(respResult) == 0 {
resp.SuccessResult = []*pbRelay.GetUsersOnlineStatusResp_SuccessResult{}
}
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
c.JSON(http.StatusOK, resp)

Loading…
Cancel
Save