From fe159fb96e3a4ab2f6880600c986173162576073 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 11 Aug 2022 09:59:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=97=A5=E5=BF=97=E8=BE=93?= =?UTF-8?q?=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 (