package moonfantasy import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "time" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" ) ///论坛 数据组件 type modelDreamComp struct { modules.MCompModel module *Moonfantasy } //组件初始化接口 func (this *modelDreamComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Moonfantasy) this.TableName = comm.TableMoonfantasy //创建uid索引 this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "heroid", Value: bsonx.Int32(1)}}, }) return } ///添加月之秘境记录 func (this *modelDreamComp) queryDreamData(uid string, mid string) (result *pb.DBMoonfantasy, err error) { result = &pb.DBMoonfantasy{} if err = this.GetListObj(uid, mid, result); err != nil && err != mongo.ErrNilDocument { this.module.Errorln(err) } return } ///添加月之秘境记录 func (this *modelDreamComp) addDreamData(uid string, boss *cfg.GameDreamlandBoosData) (result *pb.DBMoonfantasy, err error) { result = &pb.DBMoonfantasy{ Id: primitive.NewObjectID().Hex(), Uid: uid, Monster: boss.Bossid, Ctime: time.Now().Unix(), Joinnum: 0, } if err = this.AddList(uid, result.Id, result); err != nil { this.module.Errorln(err) } return }