package battlerecord import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) /* 模块名:用户埋点完成条件触发系统 模块描述:用户埋点数据中心管理模块 开发人员:李伟 */ const moduleName = "埋点统计中心" type BattleRecord struct { modules.ModuleBase api *apiComp model *modelComp } func NewModule() core.IModule { return &BattleRecord{} } func (this *BattleRecord) GetType() core.M_Modules { return comm.ModuleBattleRecord } func (this *BattleRecord) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { if err = this.ModuleBase.Init(service, module, options); err != nil { return } return } // 装备组件 func (this *BattleRecord) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.model = this.RegisterComp(new(modelComp)).(*modelComp) } func (this *BattleRecord) Start() (err error) { if err = this.ModuleBase.Start(); err != nil { return } return } //写入战斗记录 func (this *BattleRecord) WrietBattleRecord(uid string, report *pb.BattleReport, expire int64) { var ( result *pb.DBBattlePlayRecord model *recordModel data []byte err error ) if data, err = proto.Marshal(report); err != nil { this.Errorln(err) return } result = &pb.DBBattlePlayRecord{ Id: report.Info.Id, Record: data, ExpireAt: expire, } if model, err = this.model.getrecordModel(uid); err != nil { this.Errorln(err) return } if err = model.addRecord(result); err != nil { this.Errorln(err) return } return }