go_dreamfactory/modules/island/modelhero.go
2023-10-30 15:00:56 +08:00

38 lines
919 B
Go

package island
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
type modelHeroComp struct {
modules.MCompModel
module *IsLand
}
func (this *modelHeroComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TableIsLandHero
this.module = module.(*IsLand)
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})
return
}
// 读取数据
// 获取玩家的英雄列表
func (this *modelHeroComp) getHeroList(uid string) []*pb.DBHero {
heroes := make([]*pb.DBHero, 0)
err := this.GetList(uid, &heroes)
if err != nil {
return nil
}
return heroes
}