go_dreamfactory/modules/atlas/module.go
2023-02-24 16:26:56 +08:00

65 lines
1.6 KiB
Go

/*
模块名:atlas
描述:武馆图鉴模块
开发:梅雄风
*/
package atlas
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
)
type PandaAtlas struct {
modules.ModuleBase
api *apiComp
configure *configureComp
modelPandaAtlas *modelPandaAtlas
service core.IService
}
func NewModule() core.IModule {
return &PandaAtlas{}
}
func (this *PandaAtlas) GetType() core.M_Modules {
return comm.ModulePandaAtlas
}
func (this *PandaAtlas) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service
return
}
func (this *PandaAtlas) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
this.modelPandaAtlas = this.RegisterComp(new(modelPandaAtlas)).(*modelPandaAtlas)
}
func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) (code pb.ErrorCode) {
list, _ := this.modelPandaAtlas.getPandaAtlasList(uid)
if _, ok := list.Collect[id]; !ok {
conf := this.configure.GetPandoAtlasConf(id)
if conf != nil {
list.Collect[id] = &pb.CollectInfo{
Score: conf.AtlasScore,
Time: configure.Now().Unix(),
Activate: false,
}
update := make(map[string]interface{}, 0)
update["collect"] = list.Collect
this.modelPandaAtlas.modifyPandaAtlasList(uid, update)
return
}
}
code = pb.ErrorCode_SmithyNoFoundAtlas
return
}