美食馆
This commit is contained in:
parent
6368eee720
commit
3eb6773160
@ -93,6 +93,8 @@ const (
|
||||
TablePagoda = "pagoda"
|
||||
///武馆数据表
|
||||
TableMartialhall = "martialhall"
|
||||
// 美食馆
|
||||
TableGourmet = "gourmet"
|
||||
)
|
||||
|
||||
//RPC服务接口定义处
|
||||
|
32
modules/gourmet/api.go
Normal file
32
modules/gourmet/api.go
Normal file
@ -0,0 +1,32 @@
|
||||
package gourmet
|
||||
|
||||
import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
)
|
||||
|
||||
const (
|
||||
PagodaGetListResp = "getlist"
|
||||
PagodaChallengeResp = "challenge"
|
||||
PagodaGetRewardResp = "getreward"
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
modules.MCompGate
|
||||
service core.IService
|
||||
module *Gourmet
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.MCompGate.Init(service, module, comp, options)
|
||||
this.module = module.(*Gourmet)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) Start() (err error) {
|
||||
err = this.MCompGate.Start()
|
||||
|
||||
return
|
||||
}
|
27
modules/gourmet/api_getReward.go
Normal file
27
modules/gourmet/api_getReward.go
Normal file
@ -0,0 +1,27 @@
|
||||
package gourmet
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.PagodaGetRewardReq) (code pb.ErrorCode) {
|
||||
if req.Id <= 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
///获取主线关卡信息
|
||||
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.PagodaGetRewardReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
code = this.GetRewardCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
return
|
||||
}
|
20
modules/gourmet/api_getlist.go
Normal file
20
modules/gourmet/api_getlist.go
Normal file
@ -0,0 +1,20 @@
|
||||
package gourmet
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.PagodaGetListReq) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
///获取主线关卡信息
|
||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
return
|
||||
}
|
95
modules/gourmet/comp_configure.go
Normal file
95
modules/gourmet/comp_configure.go
Normal file
@ -0,0 +1,95 @@
|
||||
package gourmet
|
||||
|
||||
import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/core/cbase"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
game_pagoda = "game_pagoda.json"
|
||||
game_pagodaseasonreward = "game_pagodaseasonreward.json"
|
||||
game_pagodataskreward = "game_pagodataskreward.json"
|
||||
)
|
||||
|
||||
///配置管理基础组件
|
||||
type configureComp struct {
|
||||
cbase.ModuleCompBase
|
||||
hlock sync.RWMutex
|
||||
_pagodaMap map[int64]*cfg.GamepagodaData
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleCompBase.Init(service, module, comp, options)
|
||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||
//game_pagoda: cfg.NewGame_pagoda,
|
||||
game_pagodaseasonreward: cfg.NewGamepagodaSeasonReward,
|
||||
game_pagodataskreward: cfg.NewGamepagodaTaskReward,
|
||||
})
|
||||
|
||||
this._pagodaMap = make(map[int64]*cfg.GamepagodaData, 0)
|
||||
configure.RegisterConfigure(game_pagoda, cfg.NewGamepagoda, func() {
|
||||
if v, err := this.GetConfigure(game_pagoda); err == nil {
|
||||
if configure, ok := v.(*cfg.Gamepagoda); ok {
|
||||
this.hlock.Lock()
|
||||
defer this.hlock.Unlock()
|
||||
for _, value := range configure.GetDataList() {
|
||||
this._pagodaMap[int64(value.PagodaType<<16)+int64(value.LayerNum)] = value
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Errorf("get game_pagoda conf err:%v", err)
|
||||
return
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取爬塔信息 参数1 塔类型 参数2 层数
|
||||
func (this *configureComp) GetPagodaConfigData(PagodaType int32, floorId int32) (data *cfg.GamepagodaData) {
|
||||
|
||||
return this._pagodaMap[int64(PagodaType<<16)+int64(floorId)]
|
||||
}
|
||||
|
||||
//加载多个配置文件
|
||||
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
|
||||
for k, v := range confs {
|
||||
err = configure.RegisterConfigure(k, v, nil)
|
||||
if err != nil {
|
||||
log.Errorf("配置文件:%s解析失败!", k)
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//读取配置数据
|
||||
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
|
||||
return configure.GetConfigure(name)
|
||||
}
|
||||
|
||||
// 获取爬塔配置表数据
|
||||
func (this *configureComp) GetPagodaconfig(id int32) (data *cfg.GamepagodaData) {
|
||||
if v, err := this.GetConfigure(game_pagoda); err != nil {
|
||||
log.Errorf("get global conf err:%v", err)
|
||||
return
|
||||
} else {
|
||||
var (
|
||||
configure *cfg.Gamepagoda
|
||||
ok bool
|
||||
)
|
||||
if configure, ok = v.(*cfg.Gamepagoda); !ok {
|
||||
log.Errorf("%T no is *cfg.Game_pagodaData", v)
|
||||
return
|
||||
}
|
||||
|
||||
if data, ok = configure.GetDataMap()[id]; ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
20
modules/gourmet/model_pagoda.go
Normal file
20
modules/gourmet/model_pagoda.go
Normal file
@ -0,0 +1,20 @@
|
||||
package gourmet
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
)
|
||||
|
||||
type ModelPagoda struct {
|
||||
modules.MCompModel
|
||||
module *Gourmet
|
||||
}
|
||||
|
||||
func (this *ModelPagoda) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.TableName = string(comm.TableGourmet)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.module = module.(*Gourmet)
|
||||
|
||||
return
|
||||
}
|
42
modules/gourmet/module.go
Normal file
42
modules/gourmet/module.go
Normal file
@ -0,0 +1,42 @@
|
||||
package gourmet
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
type Gourmet struct {
|
||||
modules.ModuleBase
|
||||
modelPagoda *ModelPagoda
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
return &Gourmet{}
|
||||
}
|
||||
|
||||
func (this *Gourmet) GetType() core.M_Modules {
|
||||
return comm.ModulePagoda
|
||||
}
|
||||
|
||||
func (this *Gourmet) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Gourmet) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelPagoda = this.RegisterComp(new(ModelPagoda)).(*ModelPagoda)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
// 接口信息
|
||||
func (this *Gourmet) ModifyGourmetData(uid string, objId string, data map[string]interface{}) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user