59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
package enchant
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
|
)
|
|
|
|
type modelEnchant struct {
|
|
modules.MCompModel
|
|
module *Enchant
|
|
}
|
|
|
|
func (this *modelEnchant) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = string(comm.TableEnchant)
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*Enchant)
|
|
// uid 创建索引
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
func (this *modelEnchant) modifyEnchantDataByObjId(uid string, data map[string]interface{}) error {
|
|
return this.Change(uid, data)
|
|
}
|
|
|
|
// 获取列表信息
|
|
func (this *modelEnchant) getEnchantList(uid string) (result *pb.DBEnchant, err error) {
|
|
result = &pb.DBEnchant{}
|
|
if err = this.Get(uid, result); err != nil && err != mgo.MongodbNil {
|
|
return
|
|
}
|
|
if mgo.MongodbNil == err {
|
|
result = &pb.DBEnchant{
|
|
Boss: make(map[int32]*pb.DBEnchantBoos),
|
|
}
|
|
}
|
|
|
|
err = nil
|
|
return result, err
|
|
}
|
|
|
|
// 红点检测
|
|
func (this *modelEnchant) checkReddot33(session comm.IUserSession) bool {
|
|
if conf, err := this.module.configure.GetEnchantBossConfigData(1); err == nil {
|
|
if code := this.module.CheckRes(session, conf.PsConsume); code == nil {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|