62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package atlas
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
|
)
|
|
|
|
type modelPandaAtlas struct {
|
|
modules.MCompModel
|
|
module *PandaAtlas
|
|
}
|
|
|
|
func (this *modelPandaAtlas) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = string(comm.TablePandaAtlas)
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*PandaAtlas)
|
|
// uid 创建索引
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
func (this *modelPandaAtlas) getPandaAtlasList(uid string) (result *pb.DBPandaAtlas, err error) {
|
|
result = &pb.DBPandaAtlas{
|
|
Collect: map[string]*pb.CollectInfo{},
|
|
}
|
|
if err = this.Get(uid, result); err != nil {
|
|
if mongo.ErrNoDocuments == err {
|
|
result.Id = primitive.NewObjectID().Hex()
|
|
result.Uid = uid
|
|
result.Collect = make(map[string]*pb.CollectInfo, 0)
|
|
result.Award = 1 // 初始1级
|
|
this.Add(uid, result)
|
|
err = nil
|
|
}
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *modelPandaAtlas) modifyPandaAtlasList(uid string, data map[string]interface{}) error {
|
|
return this.Change(uid, data)
|
|
}
|
|
|
|
// 检查是否激活图鉴
|
|
func (this *modelPandaAtlas) CheckActivateAtlas(uid string, id string, lv int32, quality int32, forgeCount int32) bool {
|
|
|
|
return true
|
|
}
|
|
|
|
// 检查是否激活收藏品
|
|
func (this *modelPandaAtlas) CheckActivatePandaAtlas(uid string, id string) {
|
|
|
|
}
|