57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package hunting
|
|
|
|
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 modelHunting struct {
|
|
modules.MCompModel
|
|
module *Hunting
|
|
}
|
|
|
|
func (this *modelHunting) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = string(comm.TableHunting)
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*Hunting)
|
|
// uid 创建索引
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
func (this *modelHunting) modifyHuntingDataByObjId(uid string, data map[string]interface{}) error {
|
|
return this.Change(uid, data)
|
|
}
|
|
|
|
// 获取列表信息
|
|
func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err error) {
|
|
result = &pb.DBHunting{}
|
|
if err = this.Get(uid, result); err != nil {
|
|
return
|
|
}
|
|
|
|
err = nil
|
|
return result, err
|
|
}
|
|
|
|
// 红点检测
|
|
func (this *modelHunting) checkReddot32(session comm.IUserSession) bool {
|
|
if list, err := this.module.modelHunting.getHuntingList(session.GetUserId()); err == nil {
|
|
if _, ok := list.Boss[1]; ok {
|
|
conf := this.module.configure.GetHuntingBossConfigData(1, 1)
|
|
if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|