添加游戏日志
This commit is contained in:
parent
0192f51100
commit
fd951aa62f
@ -11,4 +11,6 @@ const (
|
||||
GetUserResources = "get.user.resources.rpc"
|
||||
GetGameUser = "get.game.user.rpc"
|
||||
AddUserResources = "add.user.resources.rpc"
|
||||
SaveGameRecordLog = "save.game.record.log.rpc" // 保存对局日志
|
||||
SaveUserRecordLog = "save.user.record.log.rpc" // 保存玩家战绩
|
||||
)
|
||||
|
16
server/db/operation/userGameLog.go
Normal file
16
server/db/operation/userGameLog.go
Normal file
@ -0,0 +1,16 @@
|
||||
package operation
|
||||
|
||||
import (
|
||||
"game/common/model"
|
||||
"game/common/model/user"
|
||||
)
|
||||
|
||||
// 游戏对局日志
|
||||
func NewGameRecordLogOp() *model.TableOp[user.GameRecordLog] {
|
||||
return model.NewTableOp[user.GameRecordLog](LogDB, nil)
|
||||
}
|
||||
|
||||
// 玩家游戏日志
|
||||
func NewUserRecordLogOp() *model.TableOp[user.UserRecordLog] {
|
||||
return model.NewTableOp[user.UserRecordLog](LogDB, nil)
|
||||
}
|
@ -171,3 +171,27 @@ func (s *DbService) onGetGameUser(iMsg *ipb.InternalMsg) *ipb.InternalMsg {
|
||||
})
|
||||
return iMsg
|
||||
}
|
||||
|
||||
// 保存游戏对局日志
|
||||
func (s *DbService) onSaveGameRecordLog(iMsg *ipb.InternalMsg) *ipb.InternalMsg {
|
||||
// 日志,没必要阻塞主协程
|
||||
ksync.GoSafe(func() {
|
||||
operationDb[user.GameRecordLog](iMsg, func(record *user.GameRecordLog) (*user.GameRecordLog, pb.ErrCode) {
|
||||
_, code := operation.NewGameRecordLogOp().Create(record)
|
||||
return nil, code
|
||||
})
|
||||
}, nil)
|
||||
return iMsg
|
||||
}
|
||||
|
||||
// 保存游戏对局日志
|
||||
func (s *DbService) onSaveUserRecordLog(iMsg *ipb.InternalMsg) *ipb.InternalMsg {
|
||||
// 日志,没必要阻塞主协程
|
||||
ksync.GoSafe(func() {
|
||||
operationDb[user.UserRecordLog](iMsg, func(record *user.UserRecordLog) (*user.UserRecordLog, pb.ErrCode) {
|
||||
_, code := operation.NewUserRecordLogOp().Create(record)
|
||||
return nil, code
|
||||
})
|
||||
}, nil)
|
||||
return iMsg
|
||||
}
|
||||
|
@ -16,5 +16,7 @@ func (s *DbService) initRpcProcessor() {
|
||||
rpc.GetUserResources: s.onGetUserResources,
|
||||
rpc.GetGameUser: s.onGetGameUser,
|
||||
rpc.AddUserResources: s.onAddUserResources,
|
||||
rpc.SaveGameRecordLog: s.onSaveGameRecordLog,
|
||||
rpc.SaveUserRecordLog: s.onSaveUserRecordLog,
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user