package academy import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/modules" "go_dreamfactory/pb" ) ///论坛 数据组件 type modelAcademyComp struct { modules.MCompModel module *Academy } //组件初始化接口 func (this *modelAcademyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { this.TableName = comm.TableAcademy this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Academy) //创建uid索引 // this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ // Keys: bsonx.Doc{{Key: "heroid", Value: bsonx.Int32(1)}}, // }) return } //查询用户装备数据 func (this *modelAcademyComp) queryInfo(uId string) (result *pb.DBAcademy, err error) { result = &pb.DBAcademy{ Uid: uId, Level: make(map[int32]bool), Hero: make(map[string]bool), } if err = this.Get(uId, result); err != nil && err != mgo.MongodbNil { this.module.Errorln(err) return } if err == mgo.MongodbNil { err = nil } return } ///保存用户竞技场信息 func (this *modelAcademyComp) updateInfo(info *pb.DBAcademy) (err error) { if err = this.Change(info.Uid, map[string]interface{}{ "level": info.Level, "hero": info.Hero, }); err != nil { this.module.Errorln(err) return } return }