43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package hunting
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/redis"
|
|
"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 && redis.RedisNil != err {
|
|
return
|
|
}
|
|
err = nil
|
|
return result, err
|
|
}
|