美食家
This commit is contained in:
parent
8b7822b836
commit
fc788396dc
@ -47,6 +47,7 @@ const (
|
||||
ModuleGM core.M_Modules = "gm" //gm模块
|
||||
ModulePagoda core.M_Modules = "pagoda" //魔塔模块
|
||||
ModuleMartialhall core.M_Modules = "martialhall" //武馆模块
|
||||
ModuleGourmet core.M_Modules = "gourmet" //美食馆
|
||||
)
|
||||
|
||||
//数据表名定义处
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
PagodaGetListResp = "getlist"
|
||||
GourmetGetListResp = "getlist"
|
||||
PagodaChallengeResp = "challenge"
|
||||
PagodaGetRewardResp = "getreward"
|
||||
)
|
||||
|
@ -8,15 +8,18 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode) {
|
||||
|
||||
func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode) {
|
||||
if len(req.Order) == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
///美食城领取奖励
|
||||
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode, data proto.Message) {
|
||||
///美食城创建订单
|
||||
func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
code = this.GetRewardCheck(session, req)
|
||||
code = this.CreateOrderCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
@ -8,15 +8,15 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode) {
|
||||
func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
///美食城创建订单
|
||||
func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode, data proto.Message) {
|
||||
///美食城领取奖励
|
||||
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
code = this.CreateOrderCheck(session, req)
|
||||
code = this.GetRewardCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
@ -16,5 +16,16 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.GourmetGetL
|
||||
///获取美食城基本信息
|
||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
code = this.GetListCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
_gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), GourmetGetListResp, &pb.GourmetGetListResp{Data: _gourmet})
|
||||
return
|
||||
}
|
||||
|
@ -56,6 +56,10 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
log.Errorf("get game_pagoda conf err:%v", err)
|
||||
return
|
||||
})
|
||||
|
||||
// _data := this.GetGourmetConfigData(1002, 4) // 测试配置文件读取
|
||||
// _dataskill := this.GetGourmetSkillConfigData(1001, 4)
|
||||
// fmt.Printf("%v,%v", _data, _dataskill)
|
||||
return
|
||||
}
|
||||
|
||||
@ -65,6 +69,12 @@ func (this *configureComp) GetGourmetConfigData(gourmetType int32, level int32)
|
||||
return this._gourmetMap[int64(gourmetType<<16)+int64(level)]
|
||||
}
|
||||
|
||||
// 获取美食馆配置数据
|
||||
func (this *configureComp) GetGourmetSkillConfigData(gourmetType int32, level int32) (data *cfg.GameGourmetSkillData) {
|
||||
|
||||
return this._gourmetSkillMap[int64(gourmetType<<16)+int64(level)]
|
||||
}
|
||||
|
||||
//加载多个配置文件
|
||||
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
|
||||
for k, v := range confs {
|
||||
|
39
modules/gourmet/model_gourmet.go
Normal file
39
modules/gourmet/model_gourmet.go
Normal file
@ -0,0 +1,39 @@
|
||||
package gourmet
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
type modelGourmet struct {
|
||||
modules.MCompModel
|
||||
module *Gourmet
|
||||
}
|
||||
|
||||
func (this *modelGourmet) 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
|
||||
}
|
||||
|
||||
func (this *modelGourmet) getGourmetList(uid string) (result *pb.DBGourmet, err error) {
|
||||
result = &pb.DBGourmet{}
|
||||
if err = this.Get(uid, result); err != nil {
|
||||
if redis.RedisNil != err { // 没有数据直接创建新的数据
|
||||
result.Uid = uid
|
||||
if err = this.Add(uid, result); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
return result, err
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
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
|
||||
}
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type Gourmet struct {
|
||||
modules.ModuleBase
|
||||
modelPagoda *ModelPagoda
|
||||
modelGourmet *modelGourmet
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
}
|
||||
@ -19,7 +19,7 @@ func NewModule() core.IModule {
|
||||
}
|
||||
|
||||
func (this *Gourmet) GetType() core.M_Modules {
|
||||
return comm.ModulePagoda
|
||||
return comm.ModuleGourmet
|
||||
}
|
||||
|
||||
func (this *Gourmet) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
@ -31,7 +31,7 @@ func (this *Gourmet) Init(service core.IService, module core.IModule, options co
|
||||
func (this *Gourmet) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelPagoda = this.RegisterComp(new(ModelPagoda)).(*ModelPagoda)
|
||||
this.modelGourmet = this.RegisterComp(new(modelGourmet)).(*modelGourmet)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"go_dreamfactory/modules/forum"
|
||||
"go_dreamfactory/modules/friend"
|
||||
"go_dreamfactory/modules/gm"
|
||||
"go_dreamfactory/modules/gourmet"
|
||||
"go_dreamfactory/modules/hero"
|
||||
"go_dreamfactory/modules/items"
|
||||
"go_dreamfactory/modules/mail"
|
||||
@ -59,6 +60,7 @@ func main() {
|
||||
gm.NewModule(),
|
||||
forum.NewModule(),
|
||||
pagoda.NewModule(),
|
||||
gourmet.NewModule(),
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user