上传系统广告需求优化

This commit is contained in:
liwei1dao 2022-11-28 10:47:15 +08:00
parent 7f9807f51b
commit 3a73eb07cc
4 changed files with 22 additions and 19 deletions

View File

@ -195,7 +195,7 @@ type (
//推送消息到用户 //推送消息到用户
SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) SendUserChat(msg *pb.DBChat) (code pb.ErrorCode)
//广播系统消息 //广播系统消息
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode) SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode)
//广播系统消息 //广播系统消息
SendSysChatToUser(session IUserSession, ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode) SendSysChatToUser(session IUserSession, ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode)
} }

View File

@ -217,7 +217,7 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) {
} }
//广播系统消息 //广播系统消息
func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode) { func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode) {
var ( var (
jsonStr []byte jsonStr []byte
err error err error
@ -228,8 +228,10 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
Ctype: pb.ChatType_Text, Ctype: pb.ChatType_Text,
Stag: this.service.GetTag(), Stag: this.service.GetTag(),
Ctime: configure.Now().Unix(), Ctime: configure.Now().Unix(),
Content: fmt.Sprintf(st.Text, agrs...), Content: "",
Display: st.Display, Display: st.Display,
AppendInt: int64(st.Key),
AppendStrs: agrs,
} }
if ctype == comm.EquipmentUpgradeNotice { //装备分享 if ctype == comm.EquipmentUpgradeNotice { //装备分享
msg.Ctype = pb.ChatType_Share msg.Ctype = pb.ChatType_Share
@ -238,8 +240,8 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
this.Errorf("err:%v", err) this.Errorf("err:%v", err)
} else { } else {
data := map[string]interface{}{ data := map[string]interface{}{
agrs[1].(string): map[string]interface{}{ agrs[1]: map[string]interface{}{
"key": agrs[1].(string), "key": agrs[1],
"appendStr": string(jsonStr), "appendStr": string(jsonStr),
"itemType": pb.ChatType_EquipmentShare, "itemType": pb.ChatType_EquipmentShare,
}, },

View File

@ -2,7 +2,6 @@ package equipment
import ( import (
"crypto/rand" "crypto/rand"
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb" "go_dreamfactory/pb"
@ -190,7 +189,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
// var color *cfg.GameGameColorData // var color *cfg.GameGameColorData
// if color, err = this.module.configure.GetColor(conf.Color); err == nil { // if color, err = this.module.configure.GetColor(conf.Color); err == nil {
this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, fmt.Sprintf("[%s]", conf.Name)) this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, conf.Id)
// } else { // } else {
// this.module.Errorf("GetColor err:%s", err.Error()) // this.module.Errorf("GetColor err:%s", err.Error())
// } // }

View File

@ -68,7 +68,7 @@ func (this *ChatComp) Start() (err error) {
cronStr := fmt.Sprintf("0 %d %d ? * %s", v1.TimeM, v1.TimeH, weekStr) cronStr := fmt.Sprintf("0 %d %d ? * %s", v1.TimeM, v1.TimeH, weekStr)
this.module.Debug("注册Chat广播公告消息", log.Fields{"cronStr": cronStr, "text": v1.Text}) this.module.Debug("注册Chat广播公告消息", log.Fields{"cronStr": cronStr, "text": v1.Text})
if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1.Text)); err != nil { if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1)); err != nil {
this.module.Errorf("cron.AddFunc:%s err:%v", cronStr, err) this.module.Errorf("cron.AddFunc:%s err:%v", cronStr, err)
continue continue
} }
@ -80,16 +80,18 @@ func (this *ChatComp) Start() (err error) {
return return
} }
func (this *ChatComp) chatNoticen(content string) func() { func (this *ChatComp) chatNoticen(sys *cfg.GameChatSystemData) func() {
return func() { return func() {
msg := &pb.DBChat{ msg := &pb.DBChat{
Channel: pb.ChatChannel_System, Channel: pb.ChatChannel_System,
Stag: this.service.GetTag(), Stag: this.service.GetTag(),
Ctime: configure.Now().Unix(), Ctime: configure.Now().Unix(),
Content: content, Content: "",
Display: sys.Display,
AppendInt: int64(sys.Key),
} }
data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg}) data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
this.module.Debug("广播公告消息", log.Fields{"chat": content}) this.module.Debug("广播公告消息", log.Fields{"chat": sys.Text})
if err := this.module.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{ if err := this.module.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{
MainType: string(comm.ModuleChat), MainType: string(comm.ModuleChat),
SubType: "message", SubType: "message",