game/common/rpc/logRecord/rpcGetUserResLogs.go

41 lines
1.0 KiB
Go
Raw Normal View History

2025-06-24 00:19:30 +08:00
package logRecord
import (
"encoding/json"
"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) (map[string]int64, 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 := map[string]int64{}
_ = json.Unmarshal(rspMsg.Msg, &res)
return res, pb.ErrCode_OK
}
return nil, pb.ErrCode(rspMsg.RpcCode)
}