go_dreamfactory/modules/island/modelhero.go
2023-11-02 10:48:17 +08:00

46 lines
1.2 KiB
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) (heros []*pb.DBHero, err error) {
heros = make([]*pb.DBHero, 0)
err = this.GetList(uid, &heros)
return
}
// 获取玩家的英雄
func (this *modelHeroComp) getHeros(uid string, ids []string) (heros []*pb.DBHero, err error) {
heros = make([]*pb.DBHero, 0)
err = this.GetListObjs(uid, ids, &heros)
return
}
func (this *modelHeroComp) addheros(heros *pb.DBHero) (err error) {
return
}