53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package parkour
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/db"
|
|
)
|
|
|
|
///竞速数据模块
|
|
type ModelRaceComp struct {
|
|
modules.MCompModel
|
|
module *Parkour
|
|
}
|
|
|
|
//组件初始化接口
|
|
func (this *ModelRaceComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
|
this.TableName = comm.TableParkourRace
|
|
this.MCompModel.Init(service, module, comp, opt)
|
|
this.module = module.(*Parkour)
|
|
return
|
|
}
|
|
|
|
//记录战斗信息
|
|
func (this *ModelRaceComp) addrace(race *pb.DBRace) (err error) {
|
|
if err = this.AddList("", race.Id, race, db.SetDBMgoLog(false)); err != nil {
|
|
this.module.Errorln(err)
|
|
}
|
|
return
|
|
}
|
|
|
|
//移除战斗记录
|
|
func (this *ModelRaceComp) delrace(id string) (err error) {
|
|
if err = this.DelListlds("", []string{id}, db.SetDBMgoLog(false)); err != nil {
|
|
this.module.Errorln(err)
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询用户重置数据
|
|
func (this *ModelRaceComp) queryraces() (result []*pb.DBRace, err error) {
|
|
result = make([]*pb.DBRace, 0)
|
|
if err = this.GetList("", &result); err != nil && err != mgo.MongodbNil {
|
|
this.module.Errorf("err:%v", err)
|
|
}
|
|
if err == mgo.MongodbNil {
|
|
err = nil
|
|
}
|
|
return
|
|
}
|