mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-01 15:18:59 +08:00
1
This commit is contained in:
parent
0c9ca254e6
commit
24896299d3
@ -7,7 +7,6 @@ import (
|
|||||||
utils2 "Open_IM/pkg/utils"
|
utils2 "Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
utils "github.com/OpenIMSDK/open_utils"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
@ -31,10 +30,11 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
|||||||
reflect.ValueOf(etcdConn),
|
reflect.ValueOf(etcdConn),
|
||||||
})[0].MethodByName(rpcFuncName) // rpc func
|
})[0].MethodByName(rpcFuncName) // rpc func
|
||||||
rpcReqPtr := reflect.New(rpc.Type().In(1).Elem()) // *req参数
|
rpcReqPtr := reflect.New(rpc.Type().In(1).Elem()) // *req参数
|
||||||
if err := utils.CopyStructFields(rpcReqPtr.Interface(), apiReq); err != nil {
|
//if err := utils.CopyStructFields(rpcReqPtr.Interface(), apiReq); err != nil {
|
||||||
trace_log.WriteErrorResponse(nCtx, "CopyStructFields_RpcReq", err)
|
// trace_log.WriteErrorResponse(nCtx, "CopyStructFields_RpcReq", err)
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
CopyAny(apiReq, rpcReqPtr.Interface())
|
||||||
trace_log.SetCtxInfo(nCtx, logFuncName, nil, "opUserID", c.GetString("opUserID"), "callRpcReq", rpcString(rpcReqPtr.Elem().Interface()))
|
trace_log.SetCtxInfo(nCtx, logFuncName, nil, "opUserID", c.GetString("opUserID"), "callRpcReq", rpcString(rpcReqPtr.Elem().Interface()))
|
||||||
respArr := rpc.Call([]reflect.Value{
|
respArr := rpc.Call([]reflect.Value{
|
||||||
reflect.ValueOf(context.Context(c)), // context.Context
|
reflect.ValueOf(context.Context(c)), // context.Context
|
||||||
@ -48,9 +48,10 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
|||||||
rpcResp := respArr[0].Elem()
|
rpcResp := respArr[0].Elem()
|
||||||
trace_log.SetCtxInfo(nCtx, rpcFuncName, nil, "callRpcResp", rpcString(rpcResp.Interface()))
|
trace_log.SetCtxInfo(nCtx, rpcFuncName, nil, "callRpcResp", rpcString(rpcResp.Interface()))
|
||||||
if apiResp != nil {
|
if apiResp != nil {
|
||||||
if err := utils.CopyStructFields(apiResp, rpcResp.Interface()); err != nil {
|
//if err := utils.CopyStructFields(apiResp, rpcResp.Interface()); err != nil {
|
||||||
trace_log.SetCtxInfo(nCtx, "CopyStructFields_RpcResp", err, "apiResp", fmt.Sprintf("%T", apiResp), "rpcResp", fmt.Sprintf("%T", rpcResp.Interface()))
|
// trace_log.SetCtxInfo(nCtx, "CopyStructFields_RpcResp", err, "apiResp", fmt.Sprintf("%T", apiResp), "rpcResp", fmt.Sprintf("%T", rpcResp.Interface()))
|
||||||
}
|
//}
|
||||||
|
CopyAny(rpcResp.Interface(), apiResp)
|
||||||
}
|
}
|
||||||
trace_log.SetSuccess(nCtx, rpcFuncName, apiResp)
|
trace_log.SetSuccess(nCtx, rpcFuncName, apiResp)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user