From fe159fb96e3a4ab2f6880600c986173162576073 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 11 Aug 2022 09:59:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E8=A7=84=E8=8C=83=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/gin/options.go | 4 +- lego/utils/codec/json/core.go | 1 + modules/chat/api_send.go | 4 +- modules/mainline/comp_configure.go | 22 ++++---- modules/task/api_activereceive.go | 3 +- modules/task/model_active.go | 9 ++-- modules/task/model_task.go | 18 +++---- modules/user/model_expand.go | 3 +- modules/user/model_session.go | 5 +- modules/user/model_user.go | 4 +- modules/user/module.go | 13 +++-- modules/web/api_createnotify.go | 5 +- modules/web/api_creatmail.go | 5 +- modules/web/api_register.go | 3 +- modules/web/modelMail.go | 3 +- modules/web/modelNotify.go | 5 +- modules/web/modelUser.go | 2 +- modules/web/module.go | 86 +++++++++++++++++++++--------- pb/chat_db.pb.go | 51 ++++++++++-------- pb/chat_msg.pb.go | 45 +++++++++++----- 20 files changed, 175 insertions(+), 116 deletions(-) diff --git a/lego/sys/gin/options.go b/lego/sys/gin/options.go index 72073ac34..856ecd656 100644 --- a/lego/sys/gin/options.go +++ b/lego/sys/gin/options.go @@ -60,7 +60,7 @@ func newOptions(config map[string]interface{}, opts ...Option) (options *Options o(options) } - if options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.discovery", 2)); options.Log == nil { + if options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.gin", 3)); options.Log == nil { err = errors.New("log is nil") } @@ -78,7 +78,7 @@ func newOptionsByOption(opts ...Option) (options *Options, err error) { o(options) } - if options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.discovery", 2)); options.Log == nil { + if options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.gin", 3)); options.Log == nil { err = errors.New("log is nil") } diff --git a/lego/utils/codec/json/core.go b/lego/utils/codec/json/core.go index 464216883..2f8cddfb5 100644 --- a/lego/utils/codec/json/core.go +++ b/lego/utils/codec/json/core.go @@ -52,6 +52,7 @@ func GetWriter() codecore.IWriter { } func PutWriter(w codecore.IWriter) { + w.Reset() writerPool.Put(w) } diff --git a/modules/chat/api_send.go b/modules/chat/api_send.go index bcc1337c2..655c15879 100644 --- a/modules/chat/api_send.go +++ b/modules/chat/api_send.go @@ -35,8 +35,10 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code Id: primitive.NewObjectID().Hex(), Channel: req.Channel, Suid: session.GetUserId(), - Stag: session.GetServiecTag(), + Slv: req.Ulv, + Uname: req.Uname, Avatar: req.Avatar, + Stag: session.GetServiecTag(), Content: req.Content, Ctime: time.Now().Unix(), } diff --git a/modules/mainline/comp_configure.go b/modules/mainline/comp_configure.go index e519ecdcc..2bc2e4af6 100644 --- a/modules/mainline/comp_configure.go +++ b/modules/mainline/comp_configure.go @@ -3,7 +3,6 @@ package mainline 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" ) @@ -18,6 +17,7 @@ const ( ///配置管理基础组件 type configureComp struct { cbase.ModuleCompBase + module *Mainline } //组件初始化接口 @@ -29,7 +29,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp game_mainlinehard: cfg.NewGame_mainlineHard, game_mainlinepurgatory: cfg.NewGame_mainlinePurgatory, }) - + this.module = module.(*Mainline) return } @@ -38,7 +38,7 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err for k, v := range confs { err = configure.RegisterConfigure(k, v) if err != nil { - log.Errorf("配置文件:%s解析失败!", k) + this.module.Errorf("配置文件:%s解析失败!", k) break } } @@ -52,7 +52,7 @@ func (this *configureComp) GetConfigure(name string) (v interface{}, err error) func (this *configureComp) GetMainlineChapter(id int32) (data *cfg.Game_mainlineChapterData) { if v, err := this.GetConfigure(game_mainlinechapter); err != nil { - log.Errorf("get global conf err:%v", err) + this.module.Errorf("get global conf err:%v", err) return } else { var ( @@ -60,7 +60,7 @@ func (this *configureComp) GetMainlineChapter(id int32) (data *cfg.Game_mainline ok bool ) if configure, ok = v.(*cfg.Game_mainlineChapter); !ok { - log.Errorf("%T no is *cfg.Game_mainlineChapterData", v) + this.module.Errorf("%T no is *cfg.Game_mainlineChapterData", v) return } @@ -74,7 +74,7 @@ func (this *configureComp) GetMainlineChapter(id int32) (data *cfg.Game_mainline // 获取简单的关卡配置信息 func (this *configureComp) GetMainlineEasyChapter(id int32) (data *cfg.Game_mainlineEasyData) { if v, err := this.GetConfigure(game_mainlineeasy); err != nil { - log.Errorf("get global conf err:%v", err) + this.module.Errorf("get global conf err:%v", err) return } else { var ( @@ -82,7 +82,7 @@ func (this *configureComp) GetMainlineEasyChapter(id int32) (data *cfg.Game_main ok bool ) if configure, ok = v.(*cfg.Game_mainlineEasy); !ok { - log.Errorf("%T no is *cfg.Game_mainlineEasyData", v) + this.module.Errorf("%T no is *cfg.Game_mainlineEasyData", v) return } @@ -96,7 +96,7 @@ func (this *configureComp) GetMainlineEasyChapter(id int32) (data *cfg.Game_main // 获取炼狱级别难度的关卡配置 func (this *configureComp) GetMainlinePurgatoryChapter(id int32) (data *cfg.Game_mainlinePurgatoryData) { if v, err := this.GetConfigure(game_mainlinepurgatory); err != nil { - log.Errorf("get global conf err:%v", err) + this.module.Errorf("get global conf err:%v", err) return } else { var ( @@ -104,7 +104,7 @@ func (this *configureComp) GetMainlinePurgatoryChapter(id int32) (data *cfg.Game ok bool ) if configure, ok = v.(*cfg.Game_mainlinePurgatory); !ok { - log.Errorf("%T no is *cfg.Game_mainlinePurgatoryData", v) + this.module.Errorf("%T no is *cfg.Game_mainlinePurgatoryData", v) return } @@ -118,7 +118,7 @@ func (this *configureComp) GetMainlinePurgatoryChapter(id int32) (data *cfg.Game // 获取困难的关卡配置 func (this *configureComp) GetMainlineHardChapter(id int32) (data *cfg.Game_mainlineHardData) { if v, err := this.GetConfigure(game_mainlinehard); err != nil { - log.Errorf("get global conf err:%v", err) + this.module.Errorf("get global conf err:%v", err) return } else { var ( @@ -126,7 +126,7 @@ func (this *configureComp) GetMainlineHardChapter(id int32) (data *cfg.Game_main ok bool ) if configure, ok = v.(*cfg.Game_mainlineHard); !ok { - log.Errorf("%T no is *cfg.Game_mainlineHardData", v) + this.module.Errorf("%T no is *cfg.Game_mainlineHardData", v) return } diff --git a/modules/task/api_activereceive.go b/modules/task/api_activereceive.go index 0239b00b5..d9cf53fdf 100644 --- a/modules/task/api_activereceive.go +++ b/modules/task/api_activereceive.go @@ -2,7 +2,6 @@ package task import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -72,7 +71,7 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive ua.Id, comm.TaskTag(req.TaskTag), update); err != nil { - log.Errorf("updateReceive err %v", err) + this.moduleTask.Errorf("updateReceive err %v", err) code = pb.ErrorCode_DBError return } diff --git a/modules/task/model_active.go b/modules/task/model_active.go index 138cd7ccd..6a622cee0 100644 --- a/modules/task/model_active.go +++ b/modules/task/model_active.go @@ -3,7 +3,6 @@ package task import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -35,7 +34,7 @@ func (this *ModelTaskActive) initActiveReward(uid string) { RId: conf.Key, } if err := this.moduleTask.modelTaskActive.AddList(uid, ta.Id, ta); err != nil { - log.Errorf("uid:%v tag:%v initActiv add err %v", uid, err) + this.moduleTask.Errorf("uid:%v tag:%v initActiv add err %v", uid, err) return } } @@ -45,7 +44,7 @@ func (this *ModelTaskActive) initActiveReward(uid string) { func (this *ModelTaskActive) getActiveListByTag(uid string, taskTag comm.TaskTag) (list []*pb.DBTaskActive) { al := []*pb.DBTaskActive{} if err := this.GetList(uid, &al); err != nil { - log.Errorf("getUserActiveList err:%v", err) + this.moduleTask.Errorf("getUserActiveList err:%v", err) return al } @@ -79,13 +78,13 @@ func (this *ModelTaskActive) updateReceive(uid, id string, taskTag comm.TaskTag, //清空任务 func (this *ModelTaskActive) clearTask(uid string, taskTag ...comm.TaskTag) { if len(taskTag) == 0 { - log.Errorf("least one param for taskTag") + this.moduleTask.Errorf("least one param for taskTag") return } data := this.getActiveListByTag(uid, taskTag[0]) for _, v := range data { if err := this.moduleTask.modelTaskActive.DelListlds(uid, v.Id); err != nil { - log.Errorf("uid: %v err:%v", uid, err) + this.moduleTask.Errorf("uid: %v err:%v", uid, err) return } } diff --git a/modules/task/model_task.go b/modules/task/model_task.go index fd0133986..9e313d226 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -27,7 +27,7 @@ func (this *ModelTask) Init(service core.IService, module core.IModule, comp cor func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newlist []*pb.DBTask) { list := []*pb.DBTask{} if err := this.GetList(uid, &list); err != nil { - log.Errorf("getTaskList err %v", err) + this.moduleTask.Errorf("getTaskList err %v", err) return } @@ -96,7 +96,7 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newli func (this *ModelTask) getTaskById(uid string, taskId int32) (newlist []*pb.DBTask) { list := []*pb.DBTask{} if err := this.GetList(uid, &list); err != nil { - log.Errorf("getTaskById err %v", err) + this.moduleTask.Errorf("getTaskById err %v", err) return } @@ -124,7 +124,7 @@ func (this *ModelTask) initTask(uid string) error { Sort: cnf.IdList, } if err := this.AddList(uid, task.Id, task); err != nil { - log.Errorf("initTask addlists err %v", err) + this.moduleTask.Errorf("initTask addlists err %v", err) return err } } @@ -136,7 +136,7 @@ func (this *ModelTask) initTask(uid string) error { func (this *ModelTask) getUserTask(uid string, taskId string) *pb.DBTask { userTask := &pb.DBTask{} if err := this.moduleTask.modelTask.GetListObj(uid, taskId, userTask); err != nil { - log.Errorf("getUserTask err:%v", err) + this.moduleTask.Errorf("getUserTask err:%v", err) return nil } return userTask @@ -167,7 +167,7 @@ func (this *ModelTask) checkTask(uid string, taskId int32) (*pb.DBTask, bool) { //更改用户任务 func (this *ModelTask) modifyUserTask(uid string, taskId string, data map[string]interface{}) error { if err := this.ChangeList(uid, taskId, data); err != nil { - log.Errorf("err %v", err) + this.moduleTask.Errorf("err %v", err) return err } return nil @@ -176,13 +176,13 @@ func (this *ModelTask) modifyUserTask(uid string, taskId string, data map[string //清空任务 func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) { if len(taskTag) == 0 { - log.Errorf("least one param for taskTag") + this.moduleTask.Errorf("least one param for taskTag") return } taskList := this.getTaskListByTag(uid, taskTag[0]) for _, v := range taskList { if err := this.moduleTask.modelTask.DelListlds(uid, v.Id); err != nil { - log.Errorf("uid: %v err:%v", uid, err) + this.moduleTask.Errorf("uid: %v err:%v", uid, err) return } } @@ -260,7 +260,7 @@ func (this *ModelTask) UpHeroLevel(uid string, taskId int32, tp *pb.TaskParam) * "progress": progress, } if err := this.modifyUserTask(task.Uid, task.Id, update); err != nil { - log.Errorf("err %v", err) + this.moduleTask.Errorf("err %v", err) return nil } task.Progress = progress @@ -274,7 +274,7 @@ func (this *ModelTask) UpHeroLevel(uid string, taskId int32, tp *pb.TaskParam) * func (this *ModelTask) doTaskHandle(uid string, taskType comm.TaskType, taskParam *pb.TaskParam) (tasks []*pb.DBTask, err error) { data, err := this.moduleTask.configure.getTasks(int32(taskType)) if err != nil { - log.Errorf("taskHandle err %v", err) + this.moduleTask.Errorf("taskHandle err %v", err) return nil, err } diff --git a/modules/user/model_expand.go b/modules/user/model_expand.go index 87d3f01d8..be1249b68 100644 --- a/modules/user/model_expand.go +++ b/modules/user/model_expand.go @@ -3,7 +3,6 @@ package user import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -26,7 +25,7 @@ func (this *ModelExpand) Init(service core.IService, module core.IModule, comp c func (this *ModelExpand) getUserSession(uid string) (cuser *pb.CacheUser) { cuser = &pb.CacheUser{} if err := this.Get(uid, cuser); err != nil { - log.Errorf("GetUserSession err:%v", err) + this.moduleUser.Errorf("GetUserSession err:%v", err) return } return diff --git a/modules/user/model_session.go b/modules/user/model_session.go index b8d613146..b417f1b3f 100644 --- a/modules/user/model_session.go +++ b/modules/user/model_session.go @@ -3,18 +3,19 @@ package user import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" ) type ModelSession struct { modules.MCompModel + module *User } func (this *ModelSession) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.TableName = comm.TableSession err = this.MCompModel.Init(service, module, comp, options) + this.module = module.(*User) return } @@ -22,7 +23,7 @@ func (this *ModelSession) Init(service core.IService, module core.IModule, comp func (this *ModelSession) getUserSession(uid string) (cuser *pb.CacheUser) { cuser = &pb.CacheUser{} if err := this.Get(uid, cuser); err != nil { - log.Errorf("GetUserSession err:%v", err) + this.module.Errorf("GetUserSession err:%v", err) return } return diff --git a/modules/user/model_user.go b/modules/user/model_user.go index df0071823..e52355d43 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -72,7 +72,7 @@ func (this *ModelUser) User_Create(user *pb.DBUser) (err error) { func (this *ModelUser) GetUser(uid string) (user *pb.DBUser) { user = &pb.DBUser{} if err := this.Get(uid, user); err != nil { - log.Errorf("getUser err:%v", err) + this.moduleUser.Errorf("getUser err:%v", err) return } return @@ -87,7 +87,7 @@ func (this *ModelUser) updateUserAttr(uid string, data map[string]interface{}) e func (this *ModelUser) isLoginFirst(timestamp int64) bool { now := time.Now() if timestamp == 0 || timestamp > now.Unix() { - log.Debugf("lastlogin time great now") + this.moduleUser.Debugf("lastlogin time great now") return false } tt := time.Unix(timestamp, 0) diff --git a/modules/user/module.go b/modules/user/module.go index 0fae4fb39..2ae4b0316 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -8,7 +8,6 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/event" - "go_dreamfactory/lego/sys/log" ) func NewModule() core.IModule { @@ -97,7 +96,7 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int32) { //用户资源 func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add int32, bPush bool) (code pb.ErrorCode) { if add == 0 { - log.Errorf("attr no changed,uid: %s attr: %s add: %d", session.GetUserId(), attr, add) + this.Errorf("attr no changed,uid: %s attr: %s add: %d", session.GetUserId(), attr, add) return } user := this.GetUser(session.GetUserId()) @@ -147,11 +146,11 @@ func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add } if len(update) == 0 { - log.Warn("AddAttributeValue param is empty") + this.Warn("AddAttributeValue param is empty") return } if err := this.modelUser.updateUserAttr(session.GetUserId(), update); err != nil { - log.Errorf("AddAttributeValue err:%v", err) + this.Errorf("AddAttributeValue err:%v", err) code = pb.ErrorCode_DBError } @@ -178,7 +177,7 @@ func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string update := make(map[string]interface{}) for key, add := range attrs { if add == 0 { - log.Errorf("attr no changed,uid: %s attr: %s add: %d", session.GetUserId(), key, add) + this.Errorf("attr no changed,uid: %s attr: %s add: %d", session.GetUserId(), key, add) continue } switch key { @@ -215,11 +214,11 @@ func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string } if len(update) == 0 { - log.Warn("AddAttributeValue param is empty") + this.Warn("AddAttributeValue param is empty") return } if err := this.modelUser.updateUserAttr(session.GetUserId(), update); err != nil { - log.Errorf("AddAttributeValue err:%v", err) + this.Errorf("AddAttributeValue err:%v", err) code = pb.ErrorCode_DBError } diff --git a/modules/web/api_createnotify.go b/modules/web/api_createnotify.go index 5bbc6a497..c9c5359bc 100644 --- a/modules/web/api_createnotify.go +++ b/modules/web/api_createnotify.go @@ -3,7 +3,6 @@ package web import ( "go_dreamfactory/lego/sys/gin" "go_dreamfactory/lego/sys/gin/engine" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "net/http" ) @@ -25,7 +24,7 @@ func (this *Api_Comp) CreateNotify(c *engine.Context) { ) defer c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data}) if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"Title": req.Title, "Ctime": req.Ctime, "Rtime": req.Rtime}); sign != req.Sign { - log.Errorf("LoginByCaptchaReq SignError sgin:%s", sign) + this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign) code = pb.ErrorCode_SignError msg = pb.GetErrorCodeMsg(code) return @@ -36,7 +35,7 @@ func (this *Api_Comp) CreateNotify(c *engine.Context) { return } if err = this.module.modelNotify.CreateSystemNotify(&req.DBSystemNotify); err != nil { - log.Errorf("LoginByCaptchaReq CreateSystemNotify err:%v", err) + this.module.Errorf("LoginByCaptchaReq CreateSystemNotify err:%v", err) code = pb.ErrorCode_DBError msg = pb.GetErrorCodeMsg(code) return diff --git a/modules/web/api_creatmail.go b/modules/web/api_creatmail.go index 5cee61e82..9ff9d52df 100644 --- a/modules/web/api_creatmail.go +++ b/modules/web/api_creatmail.go @@ -3,7 +3,6 @@ package web import ( "go_dreamfactory/lego/sys/gin" "go_dreamfactory/lego/sys/gin/engine" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "net/http" ) @@ -34,7 +33,7 @@ func (this *Api_Comp) CreateMail(c *engine.Context) { "Reward": req.Reward, "Items": req.Items, }); sign != req.Sign { - log.Errorf("LoginByCaptchaReq SignError sgin:%s", sign) + this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign) code = pb.ErrorCode_SignError msg = pb.GetErrorCodeMsg(code) return @@ -45,7 +44,7 @@ func (this *Api_Comp) CreateMail(c *engine.Context) { return } if err = this.module.modelMail.CreateGMMail(&req.DBMailData); err != nil { - log.Errorf("LoginByCaptchaReq CreateMail err:%v", err) + this.module.Errorf("LoginByCaptchaReq CreateMail err:%v", err) code = pb.ErrorCode_DBError msg = pb.GetErrorCodeMsg(code) return diff --git a/modules/web/api_register.go b/modules/web/api_register.go index 25a97ff6e..5d345ba57 100644 --- a/modules/web/api_register.go +++ b/modules/web/api_register.go @@ -2,7 +2,6 @@ package web import ( "go_dreamfactory/lego/sys/gin/engine" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "net/http" ) @@ -19,7 +18,7 @@ func (this *Api_Comp) Register(c *engine.Context) { Sid: req.Sid, }) if err != nil { - log.Errorf("create user err: %v", err) + this.module.Errorf("create user err: %v", err) rsp.Code = pb.ErrorCode_SqlExecutionError } rsp.Account = req.Account diff --git a/modules/web/modelMail.go b/modules/web/modelMail.go index 213a417ee..1e20f4d6b 100644 --- a/modules/web/modelMail.go +++ b/modules/web/modelMail.go @@ -3,7 +3,6 @@ package web import ( "errors" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -30,7 +29,7 @@ func (this *modelMailComp) CreateGMMail(mail *pb.DBMailData) (err error) { } mail.ObjId = primitive.NewObjectID().Hex() if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), mail); err != nil { - log.Errorf("CreateGMMail err:%v", err) + this.module.Errorln(err) return } return diff --git a/modules/web/modelNotify.go b/modules/web/modelNotify.go index 4a6719515..a7ae2b4b2 100644 --- a/modules/web/modelNotify.go +++ b/modules/web/modelNotify.go @@ -2,7 +2,6 @@ package web import ( "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -26,11 +25,11 @@ func (this *modelNotifyComp) Init(service core.IService, module core.IModule, co func (this *modelNotifyComp) CreateSystemNotify(notify *pb.DBSystemNotify) (err error) { notify.Id = primitive.NewObjectID().Hex() if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), notify); err != nil { - log.Errorf("CreateSystemNotify err:%v", err) + this.module.Errorf("CreateSystemNotify err:%v", err) return } if err = this.Redis.HSet(this.TableName, notify.Id, notify); err != nil { - log.Errorf("CreateSystemNotify err:%v", err) + this.module.Errorf("CreateSystemNotify err:%v", err) return } return diff --git a/modules/web/modelUser.go b/modules/web/modelUser.go index 7b65b0fb6..4830ea640 100644 --- a/modules/web/modelUser.go +++ b/modules/web/modelUser.go @@ -29,7 +29,7 @@ func (this *modelUserComp) User_Create(user *pb.DBUser) (err error) { now := time.Now().Unix() _id := primitive.NewObjectID().Hex() user.Id = _id - user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id) + user.Uid = fmt.Sprintf("%s_%s", user.Sid, _id) user.Uuid = uuid.NewV4().String() user.Lv = 1 //初始等级 user.Ctime = now diff --git a/modules/web/module.go b/modules/web/module.go index 66deec339..2d9f30249 100644 --- a/modules/web/module.go +++ b/modules/web/module.go @@ -1,11 +1,11 @@ package web import ( - "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" + "go_dreamfactory/lego/sys/log" ) /* @@ -54,33 +54,69 @@ func (this *Web) OnInstallComp() { } //日志 -func (this *Web) Debugf(format string, a ...interface{}) { - if this.options.GetDebug() { - this.options.GetLog().Debugf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...) - } +//日志接口 +func (this *Web) Debug(msg string, args ...log.Field) { + this.options.GetLog().Debug(msg, args...) } -func (this *Web) Infof(format string, a ...interface{}) { - if this.options.GetDebug() { - this.options.GetLog().Infof(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...) - } +func (this *Web) Info(msg string, args ...log.Field) { + this.options.GetLog().Info(msg, args...) } -func (this *Web) Warnf(format string, a ...interface{}) { - if this.options.Debug { - this.options.GetLog().Warnf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...) - } +func (this *Web) Print(msg string, args ...log.Field) { + this.options.GetLog().Print(msg, args...) } -func (this *Web) Errorf(format string, a ...interface{}) { - if this.options.GetLog() != nil { - this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...) - } +func (this *Web) Warn(msg string, args ...log.Field) { + this.options.GetLog().Warn(msg, args...) } -func (this *Web) Panicf(format string, a ...interface{}) { - if this.options.GetLog() != nil { - this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...) - } +func (this *Web) Error(msg string, args ...log.Field) { + this.options.GetLog().Error(msg, args...) } -func (this *Web) Fatalf(format string, a ...interface{}) { - if this.options.GetLog() != nil { - this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...) - } +func (this *Web) Panic(msg string, args ...log.Field) { + this.options.GetLog().Panic(msg, args...) +} +func (this *Web) Fatal(msg string, args ...log.Field) { + this.options.GetLog().Fatal(msg, args...) +} + +func (this *Web) Debugf(format string, args ...interface{}) { + this.options.GetLog().Debugf(format, args...) +} +func (this *Web) Infof(format string, args ...interface{}) { + this.options.GetLog().Infof(format, args...) +} +func (this *Web) Printf(format string, args ...interface{}) { + this.options.GetLog().Printf(format, args...) +} +func (this *Web) Warnf(format string, args ...interface{}) { + this.options.GetLog().Warnf(format, args...) +} +func (this *Web) Errorf(format string, args ...interface{}) { + this.options.GetLog().Errorf(format, args...) +} +func (this *Web) Fatalf(format string, args ...interface{}) { + this.options.GetLog().Fatalf(format, args...) +} +func (this *Web) Panicf(format string, args ...interface{}) { + this.options.GetLog().Panicf(format, args...) +} + +func (this *Web) Debugln(args ...interface{}) { + this.options.GetLog().Debugln(args...) +} +func (this *Web) Infoln(args ...interface{}) { + this.options.GetLog().Infoln(args...) +} +func (this *Web) Println(args ...interface{}) { + this.options.GetLog().Println(args...) +} +func (this *Web) Warnln(args ...interface{}) { + this.options.GetLog().Warnln(args...) +} +func (this *Web) Errorln(args ...interface{}) { + this.options.GetLog().Errorln(args...) +} +func (this *Web) Fatalln(args ...interface{}) { + this.options.GetLog().Fatalln(args...) +} +func (this *Web) Panicln(args ...interface{}) { + this.options.GetLog().Panicln(args...) } diff --git a/pb/chat_db.pb.go b/pb/chat_db.pb.go index 23ee19f70..bbcb6d05e 100644 --- a/pb/chat_db.pb.go +++ b/pb/chat_db.pb.go @@ -83,7 +83,8 @@ type DBChat struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //主键id Channel ChatChannel `protobuf:"varint,2,opt,name=channel,proto3,enum=ChatChannel" json:"channel"` //频道 Suid string `protobuf:"bytes,3,opt,name=suid,proto3" json:"suid"` //发送用户id - Ruid string `protobuf:"bytes,4,opt,name=ruid,proto3" json:"ruid"` //接收用户id channel == Private 有效 + Slv int32 `protobuf:"varint,4,opt,name=slv,proto3" json:"slv"` //发送者等级 + Ruid string `protobuf:"bytes,5,opt,name=ruid,proto3" json:"ruid"` //接收用户id channel == Private 有效 ChannelId int32 `protobuf:"varint,6,opt,name=channelId,proto3" json:"channelId"` //跨服频道 频道Id UnionId string `protobuf:"bytes,7,opt,name=unionId,proto3" json:"unionId"` //工会id Stag string `protobuf:"bytes,8,opt,name=stag,proto3" json:"stag"` //区服id @@ -146,6 +147,13 @@ func (x *DBChat) GetSuid() string { return "" } +func (x *DBChat) GetSlv() int32 { + if x != nil { + return x.Slv + } + return 0 +} + func (x *DBChat) GetRuid() string { if x != nil { return x.Ruid @@ -206,30 +214,31 @@ var File_chat_chat_db_proto protoreflect.FileDescriptor var file_chat_chat_db_proto_rawDesc = []byte{ 0x0a, 0x12, 0x63, 0x68, 0x61, 0x74, 0x2f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x64, 0x62, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x02, 0x0a, 0x06, 0x44, 0x42, 0x43, 0x68, 0x61, 0x74, 0x12, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa4, 0x02, 0x0a, 0x06, 0x44, 0x42, 0x43, 0x68, 0x61, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x75, 0x69, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, - 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x69, 0x64, 0x12, - 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x67, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x74, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x61, - 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, - 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x2a, 0x4d, 0x0a, 0x0b, 0x43, 0x68, 0x61, - 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x57, 0x6f, 0x72, 0x6c, - 0x64, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x43, - 0x72, 0x6f, 0x73, 0x73, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, - 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x73, + 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x6c, 0x76, 0x12, 0x12, 0x0a, + 0x04, 0x72, 0x75, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x69, + 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, + 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, + 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x74, 0x61, 0x67, 0x12, 0x16, 0x0a, + 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, + 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x2a, 0x4d, 0x0a, 0x0b, 0x43, + 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x57, 0x6f, + 0x72, 0x6c, 0x64, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x10, 0x01, + 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x10, 0x02, 0x12, 0x0f, 0x0a, + 0x0b, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x10, 0x03, 0x12, 0x0a, + 0x0a, 0x06, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/chat_msg.pb.go b/pb/chat_msg.pb.go index 06d323a25..f4f0341ba 100644 --- a/pb/chat_msg.pb.go +++ b/pb/chat_msg.pb.go @@ -371,9 +371,10 @@ type ChatSendReq struct { Avatar string `protobuf:"bytes,1,opt,name=avatar,proto3" json:"avatar"` //用户头像 Uname string `protobuf:"bytes,2,opt,name=uname,proto3" json:"uname"` //用户名 - Channel ChatChannel `protobuf:"varint,3,opt,name=channel,proto3,enum=ChatChannel" json:"channel"` //频道 - TargetId string `protobuf:"bytes,4,opt,name=targetId,proto3" json:"targetId"` //目标用户id - Content string `protobuf:"bytes,5,opt,name=content,proto3" json:"content"` //内容 + Ulv int32 `protobuf:"varint,3,opt,name=ulv,proto3" json:"ulv"` //用户等级 + Channel ChatChannel `protobuf:"varint,4,opt,name=channel,proto3,enum=ChatChannel" json:"channel"` //频道 + TargetId string `protobuf:"bytes,5,opt,name=targetId,proto3" json:"targetId"` //目标用户id + Content string `protobuf:"bytes,6,opt,name=content,proto3" json:"content"` //内容 } func (x *ChatSendReq) Reset() { @@ -422,6 +423,13 @@ func (x *ChatSendReq) GetUname() string { return "" } +func (x *ChatSendReq) GetUlv() int32 { + if x != nil { + return x.Ulv + } + return 0 +} + func (x *ChatSendReq) GetChannel() ChatChannel { if x != nil { return x.Channel @@ -448,6 +456,8 @@ type ChatSendResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Issucc bool `protobuf:"varint,1,opt,name=issucc,proto3" json:"issucc"` //是否成功 } func (x *ChatSendResp) Reset() { @@ -482,6 +492,13 @@ func (*ChatSendResp) Descriptor() ([]byte, []int) { return file_chat_chat_msg_proto_rawDescGZIP(), []int{8} } +func (x *ChatSendResp) GetIssucc() bool { + if x != nil { + return x.Issucc + } + return false +} + var File_chat_chat_msg_proto protoreflect.FileDescriptor var file_chat_chat_msg_proto_rawDesc = []byte{ @@ -512,19 +529,21 @@ var file_chat_chat_msg_proto_rawDesc = []byte{ 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x30, 0x0a, 0x0f, 0x43, 0x68, 0x61, 0x74, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x43, 0x68, 0x61, 0x74, - 0x52, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x22, 0x99, 0x01, 0x0a, 0x0b, 0x43, 0x68, 0x61, 0x74, + 0x52, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x22, 0xab, 0x01, 0x0a, 0x0b, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, - 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x1a, 0x0a, - 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x03, 0x75, 0x6c, 0x76, 0x12, 0x26, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, + 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, + 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, + 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x26, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x6e, + 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 36d3f893c841721648a774e6857be0248eda7228 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 11 Aug 2022 10:40:54 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/chat/api_getlist.go | 8 ++++---- modules/chat/modelChat.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/chat/api_getlist.go b/modules/chat/api_getlist.go index eda689c9d..4a5d5d895 100644 --- a/modules/chat/api_getlist.go +++ b/modules/chat/api_getlist.go @@ -24,13 +24,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) ) switch req.Channel { case pb.ChatChannel_World: - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil { code = pb.ErrorCode_DBError return } break case pb.ChatChannel_Union: - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil { code = pb.ErrorCode_DBError return } @@ -50,13 +50,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) code = pb.ErrorCode_ReqParameterError return } - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, req.ChannelId); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), 0, req.ChannelId); err != nil { code = pb.ErrorCode_DBError return } break case pb.ChatChannel_System: - if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), 0, 0); err != nil { code = pb.ErrorCode_DBError return } diff --git a/modules/chat/modelChat.go b/modules/chat/modelChat.go index 64f91095b..d9d5c8672 100644 --- a/modules/chat/modelChat.go +++ b/modules/chat/modelChat.go @@ -63,7 +63,7 @@ func (this *modelChatComp) QueryUserMsg(uid string) (result []*pb.DBChat, err er } //查询用户未读消息 -func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, area int32) (result []*pb.DBChat, err error) { +func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union string, area int32) (result []*pb.DBChat, err error) { var ( key string find bson.M @@ -74,15 +74,15 @@ func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, area int3 ) switch channel { case pb.ChatChannel_World: - key = worldchatkey + key = fmt.Sprintf("%s-%s", worldchatkey, stag) find = bson.M{"channel": channel} break case pb.ChatChannel_Union: - key = unionchatkey + key = fmt.Sprintf("%s-%s", unionchatkey, union) find = bson.M{"channel": channel, "unionId": union} break case pb.ChatChannel_CrossServer: - key = fmt.Sprintf("%s:%d", crosschatkey, area) + key = fmt.Sprintf("%s-%d", crosschatkey, area) find = bson.M{"channel": channel, "areaId": area} break case pb.ChatChannel_System: @@ -138,7 +138,7 @@ func (this *modelChatComp) AddCrossChannelMember(session comm.IUserSession) (cha return } for { - key := fmt.Sprintf("%s:%d-member", crosschatkey, channel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) if count, err = this.Redis.Hlen(key); err != nil { this.module.Errorf("err:%v", err) return @@ -167,7 +167,7 @@ func (this *modelChatComp) ChanageChannel(session comm.IUserSession, channel int var ( maxnum int32 ) - key := fmt.Sprintf("%s:%d-member", crosschatkey, channel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) count := 0 if maxnum, err = this.module.configure.GetChanageChannelMax(); err != nil { return @@ -188,7 +188,7 @@ func (this *modelChatComp) ChanageChannel(session comm.IUserSession, channel int //读取跨服聊天频道下成员 func (this *modelChatComp) GetCrossChannelMember(channel int32) (result []*pb.CacheUser, err error) { - key := fmt.Sprintf("%s:%d-member", crosschatkey, channel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) result = make([]*pb.CacheUser, 0) if err = this.Redis.HGetAll(key, &result); err != nil { this.module.Errorf("err:%v", err) @@ -207,7 +207,7 @@ func (this *modelChatComp) RemoveCrossChannelMember(session comm.IUserSession) ( return } - key := fmt.Sprintf("%s:%d-member", crosschatkey, result.Chatchannel) + key := fmt.Sprintf("%s-%d-member", crosschatkey, result.Chatchannel) if err = this.Redis.HDel(key, session.GetUserId()); err != nil { this.module.Errorf("err:%v", err) return From 377026b7ab4abe49f9b59dd5642b4329f86c06a3 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 11 Aug 2022 10:41:43 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E4=B8=9A=E5=8A=A1bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/chat/api_getlist.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/chat/api_getlist.go b/modules/chat/api_getlist.go index 4a5d5d895..9eb274e7e 100644 --- a/modules/chat/api_getlist.go +++ b/modules/chat/api_getlist.go @@ -50,13 +50,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) code = pb.ErrorCode_ReqParameterError return } - if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), 0, req.ChannelId); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", req.ChannelId); err != nil { code = pb.ErrorCode_DBError return } break case pb.ChatChannel_System: - if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), 0, 0); err != nil { + if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil { code = pb.ErrorCode_DBError return } From 161f8a4c20e69e6e682fd987ffb32ac8e1441c6a Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 11 Aug 2022 11:37:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8A=80=E8=83=BD=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A1=A8=E7=BB=93=E6=9E=84=E5=8F=98=E5=8C=96?= =?UTF-8?q?=20=E5=AF=B9=E5=BA=94=E8=AF=BB=E5=8F=96=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_heroskilllevel.json | 1689 ++++++++++++++--- modules/hero/api_strengthenUpSkill.go | 48 +- modules/hero/configure_comp.go | 15 +- sys/configure/structs/game.heroSkillLevel.go | 2 +- .../structs/game.heroSkillLevelData.go | 27 +- 5 files changed, 1456 insertions(+), 325 deletions(-) diff --git a/bin/json/game_heroskilllevel.json b/bin/json/game_heroskilllevel.json index d22e739bd..c61036780 100644 --- a/bin/json/game_heroskilllevel.json +++ b/bin/json/game_heroskilllevel.json @@ -1,387 +1,1526 @@ [ { - "key": 1, - "hid": "15001", - "skillpos": 1, - "skilllevel": 1, - "probability": 300 + "id": 190011000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 2, - "hid": "15001", - "skillpos": 1, - "skilllevel": 2, - "probability": 255 + "id": 190012000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 3, - "hid": "15001", - "skillpos": 1, - "skilllevel": 3, - "probability": 200 + "id": 190013000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 4, - "hid": "15001", - "skillpos": 1, - "skilllevel": 4, - "probability": 100 + "id": 190014000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 5, - "hid": "15001", - "skillpos": 1, - "skilllevel": 5, - "probability": 0 + "id": 190015000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 6, - "hid": "15001", - "skillpos": 2, - "skilllevel": 1, - "probability": 300 + "id": 190016000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 7, - "hid": "15001", - "skillpos": 2, - "skilllevel": 2, - "probability": 255 + "id": 190017000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 8, - "hid": "15001", - "skillpos": 2, - "skilllevel": 3, - "probability": 200 + "id": 190018000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 9, - "hid": "15001", - "skillpos": 2, - "skilllevel": 4, - "probability": 100 + "id": 190019000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 10, - "hid": "15001", - "skillpos": 2, - "skilllevel": 5, - "probability": 0 + "id": 190020000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 11, - "hid": "15001", - "skillpos": 3, - "skilllevel": 1, - "probability": 300 + "id": 190021000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 12, - "hid": "15001", - "skillpos": 3, - "skilllevel": 2, - "probability": 255 + "id": 190022000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 13, - "hid": "15001", - "skillpos": 3, - "skilllevel": 3, - "probability": 200 + "id": 190023000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 14, - "hid": "15001", - "skillpos": 3, - "skilllevel": 4, - "probability": 100 + "id": 190024000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 15, - "hid": "15001", - "skillpos": 3, - "skilllevel": 5, - "probability": 0 + "id": 190025000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 16, - "hid": "25001", - "skillpos": 1, - "skilllevel": 1, - "probability": 255 + "id": 190026000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 17, - "hid": "25001", - "skillpos": 1, - "skilllevel": 2, - "probability": 200 + "id": 190027000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 18, - "hid": "25001", - "skillpos": 1, - "skilllevel": 3, - "probability": 100 + "id": 190028000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 19, - "hid": "25001", - "skillpos": 1, - "skilllevel": 4, - "probability": 0 + "id": 190029000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 20, - "hid": "25001", - "skillpos": 2, - "skilllevel": 1, - "probability": 300 + "id": 190030000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 21, - "hid": "25001", - "skillpos": 2, - "skilllevel": 2, - "probability": 255 + "id": 190031000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 22, - "hid": "25001", - "skillpos": 2, - "skilllevel": 3, - "probability": 200 + "id": 190032000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 23, - "hid": "25001", - "skillpos": 2, - "skilllevel": 4, - "probability": 100 + "id": 190033000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 24, - "hid": "25001", - "skillpos": 2, - "skilllevel": 5, - "probability": 50 + "id": 190034000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 25, - "hid": "25001", - "skillpos": 2, - "skilllevel": 6, - "probability": 0 + "id": 190035000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 26, - "hid": "25001", - "skillpos": 3, - "skilllevel": 1, - "probability": 255 + "id": 190036000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 27, - "hid": "25001", - "skillpos": 3, - "skilllevel": 2, - "probability": 200 + "id": 190037000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 28, - "hid": "25001", - "skillpos": 3, - "skilllevel": 3, - "probability": 100 + "id": 190038000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 29, - "hid": "25001", - "skillpos": 3, - "skilllevel": 4, - "probability": 50 + "id": 190039000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 30, - "hid": "25001", - "skillpos": 3, - "skilllevel": 5, - "probability": 0 + "id": 190040000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 31, - "hid": "35001", - "skillpos": 1, - "skilllevel": 1, - "probability": 255 + "id": 190041000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 32, - "hid": "35001", - "skillpos": 1, - "skilllevel": 2, - "probability": 200 + "id": 190042000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 33, - "hid": "35001", - "skillpos": 1, - "skilllevel": 3, - "probability": 100 + "id": 190043000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 34, - "hid": "35001", - "skillpos": 1, - "skilllevel": 4, - "probability": 0 + "id": 190044000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 35, - "hid": "35001", - "skillpos": 2, - "skilllevel": 1, - "probability": 0 + "id": 190045000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 36, - "hid": "35001", - "skillpos": 3, - "skilllevel": 1, - "probability": 300 + "id": 190046000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 37, - "hid": "35001", - "skillpos": 3, - "skilllevel": 2, - "probability": 255 + "id": 190047000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 38, - "hid": "35001", - "skillpos": 3, - "skilllevel": 3, - "probability": 200 + "id": 190048000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 39, - "hid": "35001", - "skillpos": 3, - "skilllevel": 4, - "probability": 100 + "id": 190049000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 40, - "hid": "35001", - "skillpos": 3, - "skilllevel": 5, - "probability": 0 + "id": 190050000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 41, - "hid": "44001", - "skillpos": 1, - "skilllevel": 1, - "probability": 300 + "id": 190051000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 42, - "hid": "44001", - "skillpos": 1, - "skilllevel": 2, - "probability": 255 + "id": 190052000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 43, - "hid": "44001", - "skillpos": 1, - "skilllevel": 3, - "probability": 200 + "id": 190053000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 44, - "hid": "44001", - "skillpos": 1, - "skilllevel": 4, - "probability": 0 + "id": 190054000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 45, - "hid": "44001", - "skillpos": 2, - "skilllevel": 1, - "probability": 300 + "id": 190055000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 46, - "hid": "44001", - "skillpos": 2, - "skilllevel": 2, - "probability": 255 + "id": 190056000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 47, - "hid": "44001", - "skillpos": 2, - "skilllevel": 3, - "probability": 200 + "id": 190057000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 48, - "hid": "44001", - "skillpos": 2, - "skilllevel": 4, - "probability": 100 + "id": 190058000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 49, - "hid": "44001", - "skillpos": 2, - "skilllevel": 5, - "probability": 50 + "id": 190059000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 50, - "hid": "44001", - "skillpos": 2, - "skilllevel": 6, - "probability": 0 + "id": 190060000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 51, - "hid": "44001", - "skillpos": 3, - "skilllevel": 1, - "probability": 300 + "id": 190061000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 52, - "hid": "44001", - "skillpos": 3, - "skilllevel": 2, - "probability": 255 + "id": 190062000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 53, - "hid": "44001", - "skillpos": 3, - "skilllevel": 3, - "probability": 200 + "id": 190063000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 54, - "hid": "44001", - "skillpos": 3, - "skilllevel": 4, - "probability": 100 + "id": 190064000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] }, { - "key": 55, - "hid": "44001", - "skillpos": 3, - "skilllevel": 5, - "probability": 0 + "id": 190065000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190066000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190067000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190068000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190069000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190070000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190071000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190072000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190073000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190074000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190075000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190076000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190077000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190078000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190079000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190080000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190081000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190082000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190083000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190084000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190085000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190086000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100012100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100022100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100092100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100102100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100162100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100191100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100192100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100193100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100622100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 100626100, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190087000, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190087001, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190087002, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190087003, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 190087004, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110010, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110011, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110012, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110013, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110031, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110032, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110033, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110171, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110172, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110173, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110181, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110182, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110183, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110091, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110092, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110093, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110111, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110112, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110113, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 440051, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 440052, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 440053, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110081, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110082, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 110083, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 150051, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 150052, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 150053, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 125004011, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 125004111, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 125004211, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 125004311, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 135002011, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 135002111, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 135002211, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] + }, + { + "id": 135002311, + "probability": [ + 300, + 255, + 200, + 100, + 0, + 0, + 0 + ] } ] \ No newline at end of file diff --git a/modules/hero/api_strengthenUpSkill.go b/modules/hero/api_strengthenUpSkill.go index fdb8920a6..477a18163 100644 --- a/modules/hero/api_strengthenUpSkill.go +++ b/modules/hero/api_strengthenUpSkill.go @@ -22,12 +22,9 @@ func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.H /// 英雄技能升级 func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroStrengthenUpSkillReq) (code pb.ErrorCode, data proto.Message) { var ( - tmpUpSkillID map[int32]*pb.SkillData // 即将要升级的技能id - probability map[int32]int32 // 即将升级技能的权重 - upSkillPos int32 // 升级的技能位置 - totalprobability int32 // 所有技能总权重 - tmpValue int32 // 临时对象 存放累加权重 - tagColor int32 // 目标卡品质 + probability map[int32]int32 // 即将升级技能的权重 + upSkillPos int32 // 升级的技能位置 + totalprobability int32 // 所有技能总权重 _hero *pb.DBHero // 操作的英雄 ChangeList []*pb.DBHero // 推送 改变的英雄 @@ -39,7 +36,6 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt mapCostHero = make(map[string]int32, 0) mapCostObj = make(map[string]*pb.DBHero, 0) ChangeList = make([]*pb.DBHero, 0) - tmpUpSkillID = make(map[int32]*pb.SkillData, 0) code = this.StrengthenUpSkillCheck(session, req) // check if code != pb.ErrorCode_Success { @@ -55,7 +51,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt code = pb.ErrorCode_HeroNoExist return } - tagColor = heroCfg.Color + for _, v := range req.CostCardObj { // 数组转 map mapCostHero[v]++ } @@ -74,7 +70,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt return } tmp := this.module.configure.GetHero(costHero.HeroID) // 星级校验 - if tmp.Color != tagColor { + if tmp.Color != heroCfg.Color { code = pb.ErrorCode_HeroColorErr return } @@ -99,33 +95,27 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt return } + tmpUpSkillID := make(map[int32]bool, 0) for i := 0; i < int(lvUpCount); i++ { // 升级技能 - config, err1 := this.module.configure.GetHeroSkillUpConfig() - if err1 != nil { - code = pb.ErrorCode_ConfigNoFound - return - } - + probability = make(map[int32]int32, 0) for index, skill := range _hero.NormalSkill { skillMaxLv := this.module.configure.GetHeroSkillMaxLvConfig(uint32(skill.SkillID)) if skill.SkillLv < skillMaxLv { // 找到没有满级的技能id - tmpUpSkillID[int32(index)] = skill + tmpUpSkillID[int32(index)] = true + skillData := this.module.configure.GetHeroSkillUpConfig(skill.SkillID) + if skillData == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + probability[skill.SkillID] = skillData.Probability[skill.SkillLv] // 获取权重 } } if len(tmpUpSkillID) == 0 { code = pb.ErrorCode_HeroMaxSkillLv return } - probability = make(map[int32]int32, 0) - // 获取权重 - for k, v := range tmpUpSkillID { - for _, v2 := range config.GetDataList() { // 需要优化配置表 - if v2.Hid == _hero.HeroID && (k+1) == v2.Skillpos && v.SkillLv == v2.Skilllevel { - probability[k] = v2.Probability // 设置权重 - break - } - } - } + totalprobability = 0 // 根据权重升级对应的技能 for _, v := range probability { @@ -136,10 +126,10 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt return } n, _ := rand.Int(rand.Reader, big.NewInt(int64(totalprobability))) - tmpValue = 0 + tmp := 0 for k, v := range probability { - tmpValue += v - if int32(n.Int64()) < tmpValue { // 找到了 + tmp += int(v) + if int32(n.Int64()) < v { // 找到了 upSkillPos = k break } diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index e965155f6..dfab12956 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -270,18 +270,13 @@ func (this *configureComp) GetHeroLvgrow(heroId string) *cfg.Game_heroLevelgrowD } // 获取英雄技能升级相关信息 -func (this *configureComp) GetHeroSkillUpConfig() (configure *cfg.Game_heroSkillLevel, err error) { - var ( - v interface{} - ok bool - ) - if v, err = this.GetConfigure(hero_skillup); err == nil { - if configure, ok = v.(*cfg.Game_heroSkillLevel); !ok { - err = fmt.Errorf("%T no is *cfg.Game_hero", v) +func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.Game_heroSkillLevelData) { + + if v, err := this.GetConfigure(hero_skillup); err == nil { + if conf, ok := v.(*cfg.Game_heroSkillLevel); ok { + data = conf.Get(skillid) return } - } else { - err = fmt.Errorf("%T no is *cfg.Game_hero", v) } return diff --git a/sys/configure/structs/game.heroSkillLevel.go b/sys/configure/structs/game.heroSkillLevel.go index f72c2b50b..b14aadbe3 100644 --- a/sys/configure/structs/game.heroSkillLevel.go +++ b/sys/configure/structs/game.heroSkillLevel.go @@ -21,7 +21,7 @@ func NewGame_heroSkillLevel(_buf []map[string]interface{}) (*Game_heroSkillLevel return nil, err2 } else { _dataList = append(_dataList, _v) - dataMap[_v.Key] = _v + dataMap[_v.Id] = _v } } return &Game_heroSkillLevel{_dataList:_dataList, _dataMap:dataMap}, nil diff --git a/sys/configure/structs/game.heroSkillLevelData.go b/sys/configure/structs/game.heroSkillLevelData.go index 5f6d3b746..6122c4c6e 100644 --- a/sys/configure/structs/game.heroSkillLevelData.go +++ b/sys/configure/structs/game.heroSkillLevelData.go @@ -11,11 +11,8 @@ package cfg import "errors" type Game_heroSkillLevelData struct { - Key int32 - Hid string - Skillpos int32 - Skilllevel int32 - Probability int32 + Id int32 + Probability []int32 } func (Game_heroSkillLevelData) GetTypeId() int { @@ -24,10 +21,20 @@ func (Game_heroSkillLevelData) GetTypeId() int { func NewGame_heroSkillLevelData(_buf map[string]interface{}) (_v *Game_heroSkillLevelData, err error) { _v = &Game_heroSkillLevelData{} - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) } - { var _ok_ bool; if _v.Hid, _ok_ = _buf["hid"].(string); !_ok_ { err = errors.New("hid error"); return } } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skillpos"].(float64); !_ok_ { err = errors.New("skillpos error"); return }; _v.Skillpos = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skilllevel"].(float64); !_ok_ { err = errors.New("skilllevel error"); return }; _v.Skilllevel = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["probability"].(float64); !_ok_ { err = errors.New("probability error"); return }; _v.Probability = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["probability"].([]interface{}); !_ok_ { err = errors.New("probability error"); return } + + _v.Probability = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Probability = append(_v.Probability, _list_v_) + } + } + return } From 9ade1bb5a5b3b6a63190ad9b2fef7326692b5428 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 11 Aug 2022 12:02:13 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF=E7=BE=A4=E5=8F=91=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/chat/api_send.go | 2 +- modules/chat/modelChat.go | 10 ++++++++-- modules/modulebase.go | 12 ++++++------ modules/options.go | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/modules/chat/api_send.go b/modules/chat/api_send.go index 655c15879..cb0aca940 100644 --- a/modules/chat/api_send.go +++ b/modules/chat/api_send.go @@ -85,7 +85,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code return } msg.ChannelId = userexpand.Chatchannel //指定频道 - if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%d", crosschatkey, userexpand.Chatchannel), int64(max_chat), msg); err != nil { + if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, userexpand.Chatchannel), int64(max_chat), msg); err != nil { code = pb.ErrorCode_DBError return } diff --git a/modules/chat/modelChat.go b/modules/chat/modelChat.go index d9d5c8672..87faa28d1 100644 --- a/modules/chat/modelChat.go +++ b/modules/chat/modelChat.go @@ -189,11 +189,17 @@ func (this *modelChatComp) ChanageChannel(session comm.IUserSession, channel int //读取跨服聊天频道下成员 func (this *modelChatComp) GetCrossChannelMember(channel int32) (result []*pb.CacheUser, err error) { key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) - result = make([]*pb.CacheUser, 0) - if err = this.Redis.HGetAll(key, &result); err != nil { + temp := make(map[string]*pb.CacheUser, 0) + if err = this.Redis.HGetAll(key, &temp); err != nil { this.module.Errorf("err:%v", err) return } + n := 0 + result = make([]*pb.CacheUser, len(temp)) + for _, v := range temp { + result[n] = v + n++ + } return } diff --git a/modules/modulebase.go b/modules/modulebase.go index 992ec4b3a..47b41fc58 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -111,30 +111,30 @@ func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Messag func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.CacheUser) (err error) { var ( gateways map[string]map[string][]string = make(map[string]map[string][]string) - cluster map[string][]string + cluster map[string][]string = make(map[string][]string) gateway []string ok bool ) for _, v := range user { if cluster, ok = gateways[v.ServiceTag]; !ok { - gateways[v.ServiceTag] = make(map[string][]string) + cluster = make(map[string][]string) + gateways[v.ServiceTag] = cluster } if gateway, ok = cluster[v.GatewayServiceId]; !ok { gateway = make([]string, 0) cluster[v.GatewayServiceId] = gateway } - gateway = append(gateway, v.SessionId) + cluster[v.GatewayServiceId] = append(cluster[v.GatewayServiceId], v.SessionId) } - reply := &pb.RPCMessageReply{} data, _ := anypb.New(msg) for k, v := range gateways { for k1, v1 := range v { - if _, err = this.service.AcrossClusterRpcGo(context.Background(), k1, fmt.Sprintf("%s/%s", comm.Service_Gateway, k), string(comm.Rpc_GatewayAgentSendMsg), &pb.BatchMessageReq{ + if _, err = this.service.AcrossClusterRpcGo(context.Background(), k, fmt.Sprintf("%s/%s", comm.Service_Gateway, k1), string(comm.Rpc_GatewaySendBatchMsg), &pb.BatchMessageReq{ UserSessionIds: v1, MainType: mainType, SubType: subType, Data: data, - }, reply); err != nil { + }, nil); err != nil { log.Errorf("SendMsgToUsers:%s.%s->%s.%s err:%v", k1, k, mainType, subType, err) } } diff --git a/modules/options.go b/modules/options.go index 2922bb262..d0ef44696 100644 --- a/modules/options.go +++ b/modules/options.go @@ -33,7 +33,7 @@ func (this *Options) LoadConfig(settings map[string]interface{}) (err error) { err = mapstructure.Decode(settings, this) } - if this.Log = log.NewTurnlog(this.Debug, log.Clone("", 3)); this.Log == nil { + if this.Log = log.NewTurnlog(this.Debug, log.Clone("", 4)); this.Log == nil { err = errors.New("log is nil") } return