game/common/rpc/rpcAddUserResource.go

27 lines
755 B
Go

package rpc
import (
"encoding/json"
"game/common/model/user"
"game/common/proto/pb"
"github.com/fox/fox/ipb"
"github.com/fox/fox/log"
"github.com/fox/fox/service"
)
// 添加玩家资源,负数为减少
func RpcAddUserRes(s service.IService, uid int64, addUserRes *user.AddUserRes) (map[string]int64, pb.ErrCode) {
rpcMsg := ipb.MakeRpcMsg(AddUserResources, uid, addUserRes)
rspMsg, err := s.CallByServiceId(int(pb.ServiceTypeId_STI_DB), timeout, rpcMsg)
if err != nil {
log.ErrorF("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error())
return nil, pb.ErrCode_SystemErr
}
if rspMsg.RpcCode == 0 {
res := map[string]int64{}
_ = json.Unmarshal(rspMsg.Msg, &res)
return res, pb.ErrCode_OK
}
return nil, pb.ErrCode(rspMsg.RpcCode)
}