From 7c0ea7a0c940acc1119a78790065aa12c3b49603 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 13 Jul 2022 16:30:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=8E=A5=E5=8F=A3=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_awaken.go | 5 ++--- modules/hero/api_resonance.go | 5 ++--- modules/hero/api_resonanceReset.go | 5 ++--- modules/hero/api_resonanceSelect.go | 5 ++--- modules/hero/api_skillUp.go | 5 ++--- modules/hero/api_starUp.go | 5 ++--- modules/hero/api_strengthen.go | 7 +++---- modules/hero/hero_test.go | 2 +- modules/hero/model_hero.go | 17 ++++++++--------- modules/mail/api_delmail.go | 3 +-- modules/mail/api_getmail.go | 3 +-- modules/mail/module.go | 3 +-- modules/story/model_story.go | 9 ++++----- 13 files changed, 31 insertions(+), 43 deletions(-) diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index 9d95c0fd9..0434f43fb 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -2,7 +2,6 @@ package hero import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "strconv" @@ -77,7 +76,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) if err1 != nil { code = pb.ErrorCode_DBError - log.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err1) return } } else { // 加属性 @@ -91,7 +90,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err1 != nil { - log.Errorf("PushHeroProperty err!") + this.module.Errorf("PushHeroProperty err!") } session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero}) return diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index c318c9ce5..0c045826f 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -2,7 +2,6 @@ package hero import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "strconv" @@ -105,7 +104,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR } err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { - log.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err1) code = pb.ErrorCode_DBError return } @@ -124,7 +123,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR } err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err1 != nil { - log.Errorf("PushHeroProperty err!") + this.module.Errorf("PushHeroProperty err!") } session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero}) return diff --git a/modules/hero/api_resonanceReset.go b/modules/hero/api_resonanceReset.go index 073498a19..bd13d0669 100644 --- a/modules/hero/api_resonanceReset.go +++ b/modules/hero/api_resonanceReset.go @@ -2,7 +2,6 @@ package hero import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -76,13 +75,13 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { - log.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err1) code = pb.ErrorCode_DBError return } err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err1 != nil { - log.Errorf("PushHeroProperty err!") + this.module.Errorf("PushHeroProperty err!") } session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum}) return diff --git a/modules/hero/api_resonanceSelect.go b/modules/hero/api_resonanceSelect.go index a55a0fb23..93acfc744 100644 --- a/modules/hero/api_resonanceSelect.go +++ b/modules/hero/api_resonanceSelect.go @@ -2,7 +2,6 @@ package hero import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "math" @@ -46,7 +45,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { code = pb.ErrorCode_DBError - log.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err1) return } // 计算属性 @@ -69,7 +68,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err1 != nil { - log.Errorf("PushHeroProperty err!") + this.module.Errorf("PushHeroProperty err!") } session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero}) return diff --git a/modules/hero/api_skillUp.go b/modules/hero/api_skillUp.go index a82e91673..37fb690d4 100644 --- a/modules/hero/api_skillUp.go +++ b/modules/hero/api_skillUp.go @@ -3,7 +3,6 @@ package hero import ( "crypto/rand" "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "math/big" @@ -120,7 +119,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt } err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { - log.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err1) code = pb.ErrorCode_DBError return } @@ -132,7 +131,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt } err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err1 != nil { - log.Errorf("PushHeroProperty err!") + this.module.Errorf("PushHeroProperty err!") } session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero}) diff --git a/modules/hero/api_starUp.go b/modules/hero/api_starUp.go index 4a100d04c..5be07e57c 100644 --- a/modules/hero/api_starUp.go +++ b/modules/hero/api_starUp.go @@ -2,7 +2,6 @@ package hero import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -116,7 +115,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr // 消耗道具 code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), "gold", -target.Gold) // 减少金币 if code != pb.ErrorCode_Success { - log.Errorf("cost gold failed ,count = %d", target.Gold) + this.module.Errorf("cost gold failed ,count = %d", target.Gold) code = pb.ErrorCode_GoldNoEnough return } @@ -125,7 +124,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr code = this.module.DelCard(session.GetUserId(), v.CostCardObj, v.Amount) if code != pb.ErrorCode_Success { code = pb.ErrorCode_DBError - log.Errorf("del hero err card:%s,count = %d", v.CostCardObj, v.Amount) + this.module.Errorf("del hero err card:%s,count = %d", v.CostCardObj, v.Amount) return } } diff --git a/modules/hero/api_strengthen.go b/modules/hero/api_strengthen.go index 6d735d5f1..9b6f7e3d0 100644 --- a/modules/hero/api_strengthen.go +++ b/modules/hero/api_strengthen.go @@ -2,7 +2,6 @@ package hero import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -122,7 +121,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren return } - log.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costRes["gold"], addExp) + this.module.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costRes["gold"], addExp) // 执行升级逻辑 code = this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验 if code != pb.ErrorCode_Success { @@ -140,13 +139,13 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren err1 := this.module.modelHero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount) if err1 != nil { code = pb.ErrorCode_HeroNoEnough - log.Errorf("delete err failed err:%T!", err1) + this.module.Errorf("delete err failed err:%T!", err1) return } err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err1 != nil { - log.Errorf("PushHeroProperty err!") + this.module.Errorf("PushHeroProperty err!") } session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero}) diff --git a/modules/hero/hero_test.go b/modules/hero/hero_test.go index 648b96c6f..e0f1148f9 100644 --- a/modules/hero/hero_test.go +++ b/modules/hero/hero_test.go @@ -87,7 +87,7 @@ func TestPropertyCompute(t *testing.T) { func TestHeroList(t *testing.T) { heroes := module.modelHero.getHeroList("u1") - fmt.Printf("%v", heroes,) + fmt.Printf("%v", heroes) } func TestModify(t *testing.T) { diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index be52221c1..26f34c235 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -4,7 +4,6 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" "math" @@ -35,7 +34,7 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero { heroCfg := this.moduleHero.configure.GetHero(heroCfgId) if heroCfg == nil { - log.Errorf("%v hero not found from config %v", heroCfgId) + this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId) return nil } objId := primitive.NewObjectID().Hex() @@ -90,7 +89,7 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) { hero := this.initHero(uid, heroCfgId) if hero != nil { if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil { - log.Errorf("%v", err) + this.moduleHero.Errorf("%v", err) return } } @@ -151,7 +150,7 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero { func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err error) { for i := 0; i < int(count); i++ { if err := this.moduleHero.modelHero.DelListlds(uid, heroId); err != nil { - log.Errorf("%v", err) + this.moduleHero.Errorf("%v", err) break } } @@ -197,7 +196,7 @@ func (this *ModelHero) mergeMainProperty(uid, heroId string, data map[string]int comm.Def: hero.Property[comm.Def], } if err := this.modifyHeroData(uid, heroId, update); err != nil { - log.Errorf("mergeMainProperty err %v", err) + this.moduleHero.Errorf("mergeMainProperty err %v", err) } } @@ -216,7 +215,7 @@ func (this *ModelHero) mergeAddProperty(uid, heroId string, data map[string]int3 comm.DefPro: hero.AddProperty[comm.DefPro], } if err := this.modifyHeroData(uid, heroId, update); err != nil { - log.Errorf("mergeAddProperty err %v", err) + this.moduleHero.Errorf("mergeAddProperty err %v", err) } } @@ -288,7 +287,7 @@ func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string } if err = this.ChangeList(session.GetUserId(), heroId, update); err != nil { - log.Errorf("PushHeroProperty err:%v", err) + this.moduleHero.Errorf("PushHeroProperty err:%v", err) return } return session.SendMsg("push", "property", &pb.HeroProperty{Property: m}) @@ -304,7 +303,7 @@ func (this *ModelHero) HeroStarUp(session comm.IUserSession, hero *pb.DBHero) (c err1 := this.modifyHeroData(session.GetUserId(), hero.Id, _heroMap) if err1 != nil { code = pb.ErrorCode_DBError - log.Errorf("update hero skill failed:%v", err1) + this.moduleHero.Errorf("update hero skill failed:%v", err1) } // 计算属性 data := make(map[string]int32, 0) @@ -324,7 +323,7 @@ func (this *ModelHero) HeroStarUp(session comm.IUserSession, hero *pb.DBHero) (c err1 = this.PushHeroProperty(session, hero.Id) // 推送属性变化 if err1 != nil { code = pb.ErrorCode_Unknown - log.Errorf("PushHeroProperty err!") + this.moduleHero.Errorf("PushHeroProperty err!") } return } diff --git a/modules/mail/api_delmail.go b/modules/mail/api_delmail.go index 504c55350..f26a60989 100644 --- a/modules/mail/api_delmail.go +++ b/modules/mail/api_delmail.go @@ -2,7 +2,6 @@ package mail import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -36,7 +35,7 @@ func (this *apiComp) DelMail(session comm.IUserSession, req *pb.MailDelMailReq) } if mailinfo, err = this.module.modelMail.Mail_QueryUserMail(session.GetUserId()); err != nil { - log.Errorf("QueryUserMailResp err:%v", err) + this.module.Errorf("QueryUserMailResp err:%v", err) code = pb.ErrorCode_CacheReadError return } diff --git a/modules/mail/api_getmail.go b/modules/mail/api_getmail.go index cf610060a..cb8db052f 100644 --- a/modules/mail/api_getmail.go +++ b/modules/mail/api_getmail.go @@ -2,7 +2,6 @@ package mail import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -25,7 +24,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.MailGetListReq) return } if mailinfo, err = this.module.modelMail.Mail_QueryUserMail(session.GetUserId()); err != nil { - log.Errorf("Mail_GetList_Resp err:%v", err) + this.module.Errorf("Mail_GetList_Resp err:%v", err) code = pb.ErrorCode_CacheReadError return } diff --git a/modules/mail/module.go b/modules/mail/module.go index c652bc61a..5f60c376f 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -6,7 +6,6 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" ) /* @@ -53,7 +52,7 @@ func (this *Mail) CreateNewMail(uId string, mail *pb.DBMailData) bool { } err := this.modelMail.Mail_InsertUserMail(mail) if err != nil { - log.Error("create mail failed") + this.ModuleBase.Errorf("create mail failed") } // 通知玩家 var _cache = &pb.CacheUser{} diff --git a/modules/story/model_story.go b/modules/story/model_story.go index 8a5132fe9..a65481bee 100644 --- a/modules/story/model_story.go +++ b/modules/story/model_story.go @@ -2,7 +2,6 @@ package story import ( "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" ) @@ -13,12 +12,12 @@ const ( //Redis type ModelStory struct { modules.MCompModel - moduleStory *Story + module *Story } func (this *ModelStory) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.MCompModel.Init(service, module, comp, options) - this.moduleStory = module.(*Story) + this.module = module.(*Story) this.TableName = string(TableStory) return } @@ -32,14 +31,14 @@ func (this *ModelStory) getStoryList(uid string) (storys []*pb.DBStory, err erro // 修改章节信息 func (this *ModelStory) modifyStoryData(uid string, objid string, data map[string]interface{}) error { - return this.moduleStory.modelStory.ChangeList(uid, objid, data) + return this.module.modelStory.ChangeList(uid, objid, data) } // 增加新的章节数据 func (this *ModelStory) addNewChapter(uId string, data map[string]interface{}) (err error) { if err = this.AddLists(uId, data); err != nil { - log.Errorf("err:%v", err) + this.module.Errorf("err:%v", err) return } return nil