package logRecord import ( "encoding/json" "game/common/model/user" "game/common/proto/pb" "game/common/rpc" "github.com/fox/fox/ipb" "github.com/fox/fox/log" "github.com/fox/fox/service" "time" ) const ( timeout = time.Second * 30 ) type LogUserResReq struct { UserId int64 `json:"user_id"` GameId int `json:"game_id"` GameNo string `json:"game_no"` ResName string `json:"res_name"` StartTime string `json:"start_time"` EndTime string `json:"end_time"` } // 添加玩家资源,负数为减少 func RpcGetUserResLogs(s service.IService, uid int64, req *LogUserResReq) ([]*user.UserResourcesLog, pb.ErrCode) { rpcMsg := ipb.MakeRpcMsg(rpc.RpcGetUserResLog, uid, req) 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 := []*user.UserResourcesLog{} if err = json.Unmarshal(rspMsg.Msg, &res); err != nil { log.ErrorF("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error()) } return res, pb.ErrCode_OK } return nil, pb.ErrCode(rspMsg.RpcCode) }