上传日志优化代码

This commit is contained in:
liwei1dao 2022-07-13 15:06:48 +08:00
parent 0e7e6169a2
commit 2bb353817e
14 changed files with 141 additions and 57 deletions

View File

@ -42,6 +42,7 @@ const (
ModuleShop core.M_Modules = "shop" //商店模块 ModuleShop core.M_Modules = "shop" //商店模块
ModuleTask core.M_Modules = "task" //任务模块 ModuleTask core.M_Modules = "task" //任务模块
ModuleStory core.M_Modules = "story" //主线模块 ModuleStory core.M_Modules = "story" //主线模块
ModuleNotify core.M_Modules = "notify" //公告模块
) )
//RPC服务接口定义处 //RPC服务接口定义处

View File

@ -50,7 +50,10 @@ func NewSys(option ...Option) (sys ILog, err error) {
} }
func Clone(option ...Option) ILog { func Clone(option ...Option) ILog {
return defsys.Clone(option...) if defsys != nil {
return defsys.Clone(option...)
}
return nil
} }
func Debug(msg string, fields ...Field) { defsys.Debug(msg, fields...) } func Debug(msg string, fields ...Field) { defsys.Debug(msg, fields...) }

View File

@ -2,10 +2,12 @@ package gm
import ( import (
"go_dreamfactory/lego/utils/mapstructure" "go_dreamfactory/lego/utils/mapstructure"
"go_dreamfactory/modules"
) )
type ( type (
Options struct { Options struct {
modules.Options
Port int Port int
Key string Key string
} }
@ -13,6 +15,9 @@ type (
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) { func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
if settings != nil { if settings != nil {
if err = this.Options.LoadConfig(settings); err != nil {
return
}
err = mapstructure.Decode(settings, this) err = mapstructure.Decode(settings, this)
} }
return return

View File

@ -2,7 +2,6 @@ package items
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"time" "time"
@ -37,7 +36,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
}() }()
if items, err = this.module.modelItems.Pack_QueryUserPack(session.GetUserId()); err != nil { if items, err = this.module.modelItems.Pack_QueryUserPack(session.GetUserId()); err != nil {
log.Errorf("QueryUserPackReq err:%v", err) this.module.Errorf("QueryUserPackReq err:%v", err)
code = pb.ErrorCode_CacheReadError code = pb.ErrorCode_CacheReadError
return return
} else { } else {

View File

@ -7,7 +7,6 @@ import (
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
) )
const ( const (
@ -17,11 +16,13 @@ const (
///背包配置管理组件 ///背包配置管理组件
type ConfigureComp struct { type ConfigureComp struct {
modules.MCompConfigure modules.MCompConfigure
module *Items
} }
//组件初始化接口 //组件初始化接口
func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options) this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Items)
err = this.LoadConfigure(game_item, cfg.NewGame_item) err = this.LoadConfigure(game_item, cfg.NewGame_item)
return return
} }
@ -32,7 +33,7 @@ func (this *ConfigureComp) GetItemsConfigure() (items map[int32]*cfg.Game_itemDa
v interface{} v interface{}
) )
if v, err = this.GetConfigure(game_item); err != nil { if v, err = this.GetConfigure(game_item); err != nil {
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} else { } else {
items = v.(*cfg.Game_item).GetDataMap() items = v.(*cfg.Game_item).GetDataMap()
@ -47,12 +48,12 @@ func (this *ConfigureComp) GetItemConfigure(id int32) (item *cfg.Game_itemData,
ok bool ok bool
) )
if v, err = this.GetConfigure(game_item); err != nil { if v, err = this.GetConfigure(game_item); err != nil {
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} else { } else {
if item, ok = v.(*cfg.Game_item).GetDataMap()[id]; !ok { if item, ok = v.(*cfg.Game_item).GetDataMap()[id]; !ok {
err = fmt.Errorf("no found item:%d configure", id) err = fmt.Errorf("no found item:%d configure", id)
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
} }
@ -70,7 +71,7 @@ func (this *ConfigureComp) GetPackItemByType(itmes []*pb.DB_UserItemData, usetyp
err error err error
) )
if v, err = this.GetConfigure(game_item); err != nil { if v, err = this.GetConfigure(game_item); err != nil {
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} else { } else {
table = v.(*cfg.Game_item) table = v.(*cfg.Game_item)
@ -80,7 +81,7 @@ func (this *ConfigureComp) GetPackItemByType(itmes []*pb.DB_UserItemData, usetyp
result = append(result, v) result = append(result, v)
} }
} else { } else {
log.Errorf("no found itemConfigure:%d", v.ItemId) this.module.Errorf("no found itemConfigure:%d", v.ItemId)
} }
} }
} }

View File

@ -34,14 +34,18 @@ func (this *ModelItemsComp) Init(service core.IService, module core.IModule, com
///查询用户背包数据 ///查询用户背包数据
func (this *ModelItemsComp) Pack_QueryUserPack(uId string) (itmes []*pb.DB_UserItemData, err error) { func (this *ModelItemsComp) Pack_QueryUserPack(uId string) (itmes []*pb.DB_UserItemData, err error) {
itmes = make([]*pb.DB_UserItemData, 0) itmes = make([]*pb.DB_UserItemData, 0)
err = this.GetList(uId, &itmes) if err = this.GetList(uId, &itmes); err != nil {
this.module.Errorf("err:%v", err)
}
return return
} }
///查询用户指定格子的物品数据 ///查询用户指定格子的物品数据
func (this *ModelItemsComp) Pack_QueryUserPackByGridId(uId string, grid string) (itme *pb.DB_UserItemData, err error) { func (this *ModelItemsComp) Pack_QueryUserPackByGridId(uId string, grid string) (itme *pb.DB_UserItemData, err error) {
itme = &pb.DB_UserItemData{} itme = &pb.DB_UserItemData{}
err = this.GetListObj(uId, grid, itme) if err = this.GetListObj(uId, grid, itme); err != nil {
this.module.Errorf("err:%v", err)
}
return return
} }
@ -55,7 +59,9 @@ func (this *ModelItemsComp) Pack_AddUserPack(uId string, itmes ...*pb.DB_UserIte
//更新用户的背包信息 //更新用户的背包信息
func (this *ModelItemsComp) Pack_DelUserPack(uId string, ids ...string) (err error) { func (this *ModelItemsComp) Pack_DelUserPack(uId string, ids ...string) (err error) {
err = this.DelListlds(uId, ids...) if err = this.DelListlds(uId, ids...); err != nil {
this.module.Errorf("err:%v", err)
}
return return
} }
@ -71,7 +77,10 @@ func (this *ModelItemsComp) Pack_UpdateUserPack(uId string, itmes ...*pb.DB_User
//更新用户的背包信息 //更新用户的背包信息
func (this *ModelItemsComp) Pack_DeleteUserPack(uId string, gridIds ...string) (err error) { func (this *ModelItemsComp) Pack_DeleteUserPack(uId string, gridIds ...string) (err error) {
err = this.DelListlds(uId, gridIds...) if err = this.DelListlds(uId, gridIds...); err != nil {
this.module.Errorf("err:%v", err)
return
}
return return
} }
@ -82,6 +91,7 @@ func (this *ModelItemsComp) Pack_QueryUserPackItemsAmount(uId string, itemid ...
err error err error
) )
if itmes, err = this.Pack_QueryUserPack(uId); err != nil { if itmes, err = this.Pack_QueryUserPack(uId); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
result = map[int32]uint32{} result = map[int32]uint32{}
@ -108,6 +118,7 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
return return
} }
if itmes, err = this.Pack_QueryUserPack(uId); err != nil { if itmes, err = this.Pack_QueryUserPack(uId); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
add, update, del, leftnum = this.pack_addItemToUserPack(itmes, itemId, addnum) add, update, del, leftnum = this.pack_addItemToUserPack(itmes, itemId, addnum)
@ -120,16 +131,19 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
} }
if len(add) > 0 { if len(add) > 0 {
if err = this.Pack_AddUserPack(uId, add...); err != nil { if err = this.Pack_AddUserPack(uId, add...); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
} }
if len(del) > 0 { if len(del) > 0 {
if err = this.Pack_DeleteUserPack(uId, del...); err != nil { if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
} }
if len(update) > 0 { if len(update) > 0 {
if err = this.Pack_UpdateUserPack(uId, update...); err != nil { if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
} }
@ -147,6 +161,7 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
leftnum int64 leftnum int64
) )
if itmes, err = this.Pack_QueryUserPack(uId); err != nil { if itmes, err = this.Pack_QueryUserPack(uId); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
for k, v := range items { for k, v := range items {
@ -160,16 +175,19 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
} }
if len(add) > 0 { if len(add) > 0 {
if err = this.Pack_AddUserPack(uId, add...); err != nil { if err = this.Pack_AddUserPack(uId, add...); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
} }
if len(del) > 0 { if len(del) > 0 {
if err = this.Pack_DeleteUserPack(uId, del...); err != nil { if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
} }
if len(update) > 0 { if len(update) > 0 {
if err = this.Pack_UpdateUserPack(uId, update...); err != nil { if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
} }
@ -190,10 +208,12 @@ func (this *ModelItemsComp) Pack_AddItemToUserPackByGrid(uId string, gridid stri
return return
} }
if conf, err = this.module.configure.GetItemConfigure(itemId); err != nil { if conf, err = this.module.configure.GetItemConfigure(itemId); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
if itme, err = this.Pack_QueryUserPackByGridId(uId, gridid); err != nil { if itme, err = this.Pack_QueryUserPackByGridId(uId, gridid); err != nil {
this.module.Errorf("err:%v", err)
return return
} }
amount = int64(itme.Amount) amount = int64(itme.Amount)

View File

@ -6,7 +6,6 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
) )
/* /*
@ -48,7 +47,7 @@ func (this *Items) OnInstallComp() {
//IItems------------------------------------------------------------------------------------------------------------------------------- //IItems-------------------------------------------------------------------------------------------------------------------------------
///查询用户背包物品数量 ///查询用户背包物品数量
func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid int32) (amount uint32) { func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid int32) (amount uint32) {
defer log.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount) defer this.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount)
amount = 0 amount = 0
if result := this.modelItems.Pack_QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 { if result := this.modelItems.Pack_QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 {
return result[itemid] return result[itemid]
@ -65,9 +64,9 @@ func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, i
///添加单个物品到背包 (可以加物品和减物品) ///添加单个物品到背包 (可以加物品和减物品)
func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode) { func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode) {
var err error var err error
defer log.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil) defer this.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil)
if err = this.modelItems.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil { if err = this.modelItems.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil {
log.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err) this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err)
if err == ItemNotEnoughError { if err == ItemNotEnoughError {
code = pb.ErrorCode_ItemsNoEnough code = pb.ErrorCode_ItemsNoEnough
} else if err == PackGridNumUpper { } else if err == PackGridNumUpper {
@ -82,9 +81,9 @@ func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, ad
///添加多个物品到背包 (可以加物品和减物品) ///添加多个物品到背包 (可以加物品和减物品)
func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode) { func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode) {
var err error var err error
defer log.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil) defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil)
if err = this.modelItems.Pack_AddItemsToUserPack(uId, items); err != nil { if err = this.modelItems.Pack_AddItemsToUserPack(uId, items); err != nil {
log.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err) this.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err)
if err == ItemNotEnoughError { if err == ItemNotEnoughError {
code = pb.ErrorCode_ItemsNoEnough code = pb.ErrorCode_ItemsNoEnough
} else if err == PackGridNumUpper { } else if err == PackGridNumUpper {

View File

@ -23,6 +23,7 @@ type ModuleBase struct {
cbase.ModuleBase cbase.ModuleBase
module core.IModule module core.IModule
service base.IRPCXService service base.IRPCXService
options IOptions
scomp comm.ISC_GateRouteComp //网关服务组件 scomp comm.ISC_GateRouteComp //网关服务组件
//常用的一些通用模块 在底层注册好 //常用的一些通用模块 在底层注册好
ModuleUser comm.IUser //用户模块 ModuleUser comm.IUser //用户模块
@ -32,11 +33,17 @@ type ModuleBase struct {
ModuleTask comm.ITask //任务 ModuleTask comm.ITask //任务
} }
//重构模块配置对象
func (this *ModuleBase) NewOptions() (options core.IModuleOptions) {
return new(Options)
}
//模块初始化接口 //模块初始化接口
func (this *ModuleBase) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *ModuleBase) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.service = service.(base.IRPCXService) this.service = service.(base.IRPCXService)
this.module = module this.module = module
this.options = options.(IOptions)
return return
} }
@ -228,3 +235,35 @@ func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn) (code pb.Er
} }
return return
} }
//日志接口
func (this *ModuleBase) Debugf(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Debugf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
}
func (this *ModuleBase) Infof(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Infof(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
}
func (this *ModuleBase) Warnf(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Warnf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
}
func (this *ModuleBase) Errorf(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
}
func (this *ModuleBase) Panicf(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
}
func (this *ModuleBase) Fatalf(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
}

View File

@ -1,23 +0,0 @@
package notify
import (
"go_dreamfactory/modules"
"go_dreamfactory/lego/core"
)
const (
game_equipment = "game_equipment.json"
)
///背包配置管理组件
type configureComp struct {
modules.MCompConfigure
}
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.ModuleCompBase.Init(service, module, comp, options)
return
}

View File

@ -3,7 +3,6 @@ package notify
import ( import (
"context" "context"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"time" "time"
@ -43,14 +42,14 @@ func (this *modelNotifyComp) GetFullNotify() (result []*pb.DBSystemNotify, err e
for c.Next(context.Background()) { for c.Next(context.Background()) {
notify := &pb.DBSystemNotify{} notify := &pb.DBSystemNotify{}
if err = c.Decode(notify); err != nil { if err = c.Decode(notify); err != nil {
log.Errorf("GetFullNotify err:%v", err) this.module.Errorf("GetFullNotify err:%v", err)
break break
} }
notifys[notify.Id] = notify notifys[notify.Id] = notify
} }
if len(notifys) > 0 { if len(notifys) > 0 {
if err = this.Redis.HMSet(this.TableName, notifys); err != nil { if err = this.Redis.HMSet(this.TableName, notifys); err != nil {
log.Errorf("GetFullNotify err:%v", err) this.module.Errorf("GetFullNotify err:%v", err)
} }
} }
} }

View File

@ -20,7 +20,6 @@ func NewModule() core.IModule {
type Notification struct { type Notification struct {
modules.ModuleBase modules.ModuleBase
api_comp *apiComp api_comp *apiComp
configure *configureComp
modelNotify *modelNotifyComp modelNotify *modelNotifyComp
} }
@ -40,5 +39,4 @@ func (this *Notification) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelNotify = this.RegisterComp(new(modelNotifyComp)).(*modelNotifyComp) this.modelNotify = this.RegisterComp(new(modelNotifyComp)).(*modelNotifyComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
} }

42
modules/options.go Normal file
View File

@ -0,0 +1,42 @@
package modules
import (
"fmt"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/utils/mapstructure"
)
type (
IOptions interface {
core.IModuleOptions
GetDebug() bool
GetLog() log.ILog
}
Options struct {
Debug bool //日志是否开启
Log log.ILog
}
)
func (this *Options) GetDebug() bool {
return this.Debug
}
func (this *Options) GetLog() log.ILog {
return this.Log
}
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
if settings != nil {
err = mapstructure.Decode(settings, this)
}
if this.Debug && this.Log == nil {
this.Log = log.Clone()
if this.Log == nil {
err = fmt.Errorf("Log is nil")
return
}
}
return
}

View File

@ -3,7 +3,6 @@ package shop
import ( import (
"fmt" "fmt"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
@ -17,11 +16,13 @@ const (
///背包配置管理组件 ///背包配置管理组件
type configureComp struct { type configureComp struct {
modules.MCompConfigure modules.MCompConfigure
module *Shop
} }
//组件初始化接口 //组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.ModuleCompBase.Init(service, module, comp, options) this.ModuleCompBase.Init(service, module, comp, options)
this.module = module.(*Shop)
this.LoadConfigure(game_shop, cfg.NewGame_shop) this.LoadConfigure(game_shop, cfg.NewGame_shop)
this.LoadConfigure(game_shopitem, cfg.NewGame_shopitem) this.LoadConfigure(game_shopitem, cfg.NewGame_shopitem)
return return
@ -34,12 +35,12 @@ func (this *configureComp) GetShopConfigure(id int32) (configure *cfg.Game_shopD
ok bool ok bool
) )
if v, err = this.GetConfigure(game_shop); err != nil { if v, err = this.GetConfigure(game_shop); err != nil {
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} else { } else {
if configure, ok = v.(*cfg.Game_shop).GetDataMap()[id]; !ok { if configure, ok = v.(*cfg.Game_shop).GetDataMap()[id]; !ok {
err = fmt.Errorf("ShopConfigure not found:%d ", id) err = fmt.Errorf("ShopConfigure not found:%d ", id)
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
} }
@ -53,12 +54,12 @@ func (this *configureComp) GetShopItemsConfigure(key int32) (result *cfg.Game_sh
ok bool ok bool
) )
if v, err = this.GetConfigure(game_shopitem); err != nil { if v, err = this.GetConfigure(game_shopitem); err != nil {
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} else { } else {
if result, ok = v.(*cfg.Game_shopitem).GetDataMap()[key]; !ok { if result, ok = v.(*cfg.Game_shopitem).GetDataMap()[key]; !ok {
err = fmt.Errorf("ShopConfigure not found:%d ", key) err = fmt.Errorf("ShopConfigure not found:%d ", key)
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
} }
@ -73,7 +74,7 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb
table *cfg.Game_shopitem table *cfg.Game_shopitem
) )
if v, err = this.GetConfigure(game_shopitem); err != nil { if v, err = this.GetConfigure(game_shopitem); err != nil {
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} else { } else {
table = v.(*cfg.Game_shopitem) table = v.(*cfg.Game_shopitem)
@ -99,7 +100,7 @@ func (this *configureComp) GetShopItemsConfigureByIds(keys ...int32) (result []*
ok bool ok bool
) )
if v, err = this.GetConfigure(game_shopitem); err != nil { if v, err = this.GetConfigure(game_shopitem); err != nil {
log.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} else { } else {
table = v.(*cfg.Game_shopitem) table = v.(*cfg.Game_shopitem)
@ -107,7 +108,7 @@ func (this *configureComp) GetShopItemsConfigureByIds(keys ...int32) (result []*
if item, ok = table.GetDataMap()[v]; ok { if item, ok = table.GetDataMap()[v]; ok {
result = append(result, item) result = append(result, item)
} else { } else {
log.Errorf("no found GetShopItemsConfigureByIds:%d", v) this.module.Errorf("no found GetShopItemsConfigureByIds:%d", v)
} }
} }
} }

View File

@ -2,7 +2,6 @@ package shop
import ( import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/mgo" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
@ -35,6 +34,7 @@ func (this *modelShopItemsComp) QueryUserShopData(uId string) (result map[int32]
result = make(map[int32]*pb.DBShopItem) result = make(map[int32]*pb.DBShopItem)
data := make([]*pb.DBShopItem, 0) data := make([]*pb.DBShopItem, 0)
if err = this.GetList(uId, &data); err != nil && err != mgo.MongodbNil { if err = this.GetList(uId, &data); err != nil && err != mgo.MongodbNil {
err = nil
return return
} }
err = nil err = nil
@ -52,7 +52,7 @@ func (this *modelShopItemsComp) QueryUserShopDataByGoodId(uId string, goodId int
) )
data = make([]*pb.DBShopItem, 0) data = make([]*pb.DBShopItem, 0)
if err = this.GetList(uId, &data); err != nil { if err = this.GetList(uId, &data); err != nil {
log.Errorf("err%v", err) this.module.Errorf("err%v", err)
return return
} }
for _, v := range data { for _, v := range data {