diff --git a/common/clock.go b/common/clock.go index 7245ee5..92bf8ec 100644 --- a/common/clock.go +++ b/common/clock.go @@ -251,25 +251,25 @@ func RegisterClockFunc(fs *ClockFunc) { return } if fs.OnSecTimerFunc != nil { - fs.event = fs.event | ClockEventSecond + fs.event = fs.event | 1<%s" -// 5] "玩家 %s 在 %s 中获得了 %s元 ,进入游戏即可参与!" -// 6] "玩家 在 %s 中获得了爆池奖励 %s元 ,进入游戏即可参与!" -// 10] "恭喜 %s 在 %s 游戏内获得jackpot %s ,中奖金额【 %s】" -// 11] "恭喜 %s 击杀 %s %s 获得 %s奖励" const ( - //消息类型 0:标示消息内容为服务端拼装好的字符串 - //1-99:根据客户端配置的编号格式化参数组成完整的消息内容(详见:HorseRaceLampMsgType) - //100:弹幕跑马灯 - HorseRaceLampType_ServerStr = 0 - HorseRaceLampType_CoinNormal = 5 - HorseRaceLampType_CoinReward = 6 - HorseRaceLampType_CustomMsg = 100 + HorseRaceLampTypeServer = iota + HorseRaceLampTypeLottery // 竞技馆抽奖活动中奖消息 + + HorseRaceLampTypeBatch = 100 // 弹幕跑马灯 ) -var HorseRaceLampMgrSington = &HorseRaceLampMgr{ +var HorseRaceLampMgrSingleton = &HorseRaceLampMgr{ HorseRaceLampMsgList: make(map[string]*HorseRaceLamp), HorseRaceLampGameList: make(map[string][]*HorseRaceLamp), HorseRaceLampCastList: make(map[string]*HorseRaceLampCastInfo), @@ -35,37 +28,37 @@ var HorseRaceLampMgrSington = &HorseRaceLampMgr{ } type HorseRaceLampMgr struct { - HorseRaceLampMsgList map[string]*HorseRaceLamp // _id:跑马灯数据; 所有平台数据 - HorseRaceLampGameList map[string][]*HorseRaceLamp // 平台:跑马灯 - HorseRaceLampCastList map[string]*HorseRaceLampCastInfo // 平台:跑马灯 - NextGameHorseRaceLamp map[string]int64 + HorseRaceLampMsgList map[string]*HorseRaceLamp // _id:所有平台跑马灯数据 + HorseRaceLampCastList map[string]*HorseRaceLampCastInfo // 平台:跑马灯(队列跑马灯+弹幕跑马灯) + HorseRaceLampGameList map[string][]*HorseRaceLamp // 平台:游戏跑马灯,只播一次,播完删除 + NextGameHorseRaceLamp map[string]int64 // 平台:下次游戏跑马灯播放时间 } type HorseRaceLamp struct { - Key string - Channel string - Title string - Content string - Footer string - StartTime int64 - Interval int32 - limitInterval int32 - Count int32 // bo - LastTime int64 - Priority int32 - CreateTime int64 - MsgType int32 - Platform string - State int32 - isRob bool - Target []int32 - StandSec int32 + Platform string // 平台 + Key string // _id + Channel string // 包渠道 + Title string // 标题 + Content string // 内容 + StartTime int64 // 开始播放的时间 + Interval int32 // 播放间隔 + Count int32 // 播放次数 + LastTime int64 // 上次播放时间 + Priority int32 // 播放优先级 + CreateTime int64 // 创建时间 + MsgType int32 // 消息类型 + State int32 // 状态 0.启用;1.关闭 + Players []int32 // 玩家 + StandSec int32 // 保持时间 + + isRob bool // 是否是机器人 + limitInterval int32 // 播放需要的时间 } type HorseRaceLampCastInfo struct { - CurIndex int - CurTime int64 - DealQueue []*HorseRaceLamp + CurIndex int // 队列跑马灯当前索引 + CurTime int64 // 队列跑马灯当下次检测时间(时间间隔是上一个跑马灯播放需要的时间) + DealQueue []*HorseRaceLamp // 队列跑马灯,按顺序播放 DealList []*HorseRaceLamp // 弹幕跑马灯列表 } @@ -77,54 +70,25 @@ func (this *HorseRaceLampMgr) InitHorseRaceLamp() { } for _, value := range noticeList { - msg := &HorseRaceLamp{ - Key: value.Id.Hex(), - Channel: value.Channel, - Content: value.Content, - StartTime: value.StartTime, - Interval: value.Interval, - Count: value.Count, - MsgType: value.MsgType, - Priority: value.Priority, - CreateTime: value.CreateTime, - Platform: value.Platform, - State: value.State, - Target: value.Target, - StandSec: value.StandSec, - limitInterval: int32(math.Floor(float64(len(value.Content))*0.3)) + 6, - } - - this.HorseRaceLampMsgList[value.Id.Hex()] = msg - this.insertToCastMsg(msg) + this.AddHorseRaceLampMsg(&HorseRaceLampParam{ + Platform: value.Platform, + Key: value.Id.Hex(), + AppChannel: value.Channel, + Title: value.Title, + Content: value.Content, + StartTime: value.StartTime, + Interval: value.Interval, + Count: value.Count, + MsgType: value.MsgType, + State: value.State, + Priority: value.Priority, + Players: value.Target, + StandSec: value.StandSec, + }) } } } -func (this *HorseRaceLampMgr) AddHorseRaceLampMsg(key, ch, p, title, content, footer string, startTime int64, interval, count, - msgType, state, priority int32, createTime int64, target []int32, standSec int32) string { - msg := &HorseRaceLamp{ - Key: key, - Channel: ch, - Title: title, - Content: content, - Footer: footer, - StartTime: startTime, - Interval: interval, - Count: count, - MsgType: msgType, - Priority: priority, - CreateTime: createTime, - Platform: p, - State: state, - Target: target, - StandSec: standSec, - } - this.HorseRaceLampMsgList[key] = msg - this.insertToCastMsg(msg) - - return key -} - func (this *HorseRaceLampMgr) insertToCastMsg(msg *HorseRaceLamp) { pKey := msg.Platform if this.HorseRaceLampCastList[pKey] == nil { @@ -134,16 +98,57 @@ func (this *HorseRaceLampMgr) insertToCastMsg(msg *HorseRaceLamp) { DealQueue: []*HorseRaceLamp{}, DealList: []*HorseRaceLamp{}, } - } else { - switch msg.MsgType { - case HorseRaceLampType_CustomMsg: - this.HorseRaceLampCastList[pKey].DealList = append(this.HorseRaceLampCastList[pKey].DealList, msg) - default: - this.HorseRaceLampCastList[pKey].DealQueue = append(this.HorseRaceLampCastList[pKey].DealQueue, msg) - } + } + + switch msg.MsgType { + case HorseRaceLampTypeBatch: + this.HorseRaceLampCastList[pKey].DealList = append(this.HorseRaceLampCastList[pKey].DealList, msg) + default: + this.HorseRaceLampCastList[pKey].DealQueue = append(this.HorseRaceLampCastList[pKey].DealQueue, msg) } } +type HorseRaceLampParam struct { + Platform string + Key string + AppChannel string + Title string + Content string + StartTime int64 // 开始时间 + Interval int32 // 播放间隔,秒 + Count int32 // 播放次数 + MsgType int32 // 消息类型 + State int32 // 状态 0.启用;1.关闭 + Priority int32 // 优先级 + Players []int32 // 玩家 + StandSec int32 // 保持时间 +} + +// AddHorseRaceLampMsg 添加跑马灯 +func (this *HorseRaceLampMgr) AddHorseRaceLampMsg(param *HorseRaceLampParam) string { + msg := &HorseRaceLamp{ + Key: param.Key, + Channel: param.AppChannel, + Title: param.Title, + Content: param.Content, + StartTime: param.StartTime, + Interval: param.Interval, + Count: param.Count, + MsgType: param.MsgType, + Priority: param.Priority, + CreateTime: time.Now().Unix(), + Platform: param.Platform, + State: param.State, + Players: param.Players, + StandSec: param.StandSec, + limitInterval: int32(math.Floor(float64(len(param.Content))*0.3)) + 6, + } + this.HorseRaceLampMsgList[param.Key] = msg + this.insertToCastMsg(msg) + return param.Key +} + +// EditHorseRaceLampMsg 修改跑马灯 func (this *HorseRaceLampMgr) EditHorseRaceLampMsg(hrl *HorseRaceLamp) bool { if _, ok := this.HorseRaceLampMsgList[hrl.Key]; !ok { return false @@ -151,13 +156,14 @@ func (this *HorseRaceLampMgr) EditHorseRaceLampMsg(hrl *HorseRaceLamp) bool { hrl.limitInterval = int32(math.Floor(float64(len(hrl.Content))*0.3)) + 6 this.HorseRaceLampMsgList[hrl.Key] = hrl - if pInfo, ok := this.HorseRaceLampCastList[hrl.Platform]; ok && hrl.MsgType != HorseRaceLampType_CustomMsg { + if pInfo, ok := this.HorseRaceLampCastList[hrl.Platform]; ok && hrl.MsgType != HorseRaceLampTypeBatch { pInfo.CurTime = 0 pInfo.CurIndex = 0 } return true } +// DelHorseRaceLampMsg 删除跑马灯 func (this *HorseRaceLampMgr) DelHorseRaceLampMsg(key string) { if needDel, ok := this.HorseRaceLampMsgList[key]; ok { if pInfo, ok := this.HorseRaceLampCastList[needDel.Platform]; ok { @@ -180,18 +186,31 @@ func (this *HorseRaceLampMgr) DelHorseRaceLampMsg(key string) { delete(this.HorseRaceLampMsgList, key) } -func (this *HorseRaceLampMgr) PushGameHorseRaceLamp(ch, platform, content string, msgType int32, isRob bool, priority int32) bool { +type GameHorseRaceLampParam struct { + Platform string // 平台 + AppChannel string // 包渠道 + Content string // 内容 + MsgType int32 // 消息类型 + IsRobot bool // 是否是机器人消息 + Priority int32 // 优先级 +} + +// PushGameHorseRaceLamp 推送游戏跑马灯 +func (this *HorseRaceLampMgr) PushGameHorseRaceLamp(param *GameHorseRaceLampParam) bool { msg := &HorseRaceLamp{ - Channel: ch, - Content: content, + Platform: param.Platform, + Content: param.Content, Count: 1, - MsgType: msgType, - Platform: platform, - Priority: priority, - limitInterval: int32(math.Floor(float64(len(content))*0.3)) + 6, - isRob: isRob, + MsgType: param.MsgType, + Priority: param.Priority, + limitInterval: int32(math.Floor(float64(len(param.Content))*0.3)) + 6, + isRob: param.IsRobot, } + platform := param.Platform + isRob := param.IsRobot + priority := param.Priority + if pool, exist := this.HorseRaceLampGameList[platform]; exist { if len(pool) >= model.GameParamData.BacklogGameHorseRaceLamp && len(pool) > 0 { minRobPriority := priority @@ -256,6 +275,7 @@ func (this *HorseRaceLampMgr) PushGameHorseRaceLamp(ch, platform, content string return true } +// DealHorseRaceLamp 广播跑马灯 func (this *HorseRaceLampMgr) DealHorseRaceLamp(uTime int64, value *HorseRaceLamp) { if value.Count > 0 { // 播放次数 this.BroadcastHorseRaceLampMsg(value) @@ -273,19 +293,17 @@ func (this *HorseRaceLampMgr) DealHorseRaceLamp(uTime int64, value *HorseRaceLam } } -// ////////////////////////////////////////////////////////////////// -// / Module Implement [HorseRaceLampMgr] -// ////////////////////////////////////////////////////////////////// func (this *HorseRaceLampMgr) ModuleName() string { return "HorseRaceLampMgr" } func (this *HorseRaceLampMgr) Init() { + //this.InitHorseRaceLamp() } func (this *HorseRaceLampMgr) Update() { uTime := time.Now().Unix() - //调整了跑马灯功能,需要排队发送 + // 队列跑马灯 for _, v := range this.HorseRaceLampCastList { if uTime > v.CurTime { if v.CurIndex < len(v.DealQueue) { @@ -307,6 +325,7 @@ func (this *HorseRaceLampMgr) Update() { } } } + // 弹幕跑马灯 for _, nc := range this.HorseRaceLampCastList { for _, value := range nc.DealList { if uTime > value.StartTime && value.State == 0 { @@ -314,6 +333,7 @@ func (this *HorseRaceLampMgr) Update() { } } } + // 游戏跑马灯,只播一次 for name, pool := range this.HorseRaceLampGameList { if len(pool) > 0 { msg := pool[0] @@ -333,10 +353,9 @@ func (this *HorseRaceLampMgr) SaveHorseRaceLamp() { for _, hrl := range this.HorseRaceLampMsgList { model.EditHorseRaceLamp(&model.HorseRaceLamp{ Id: bson.ObjectIdHex(hrl.Key), - Channel: "", + Channel: hrl.Channel, Title: hrl.Title, Content: hrl.Content, - Footer: hrl.Footer, StartTime: hrl.StartTime, Interval: hrl.Interval, Count: hrl.Count, @@ -345,21 +364,21 @@ func (this *HorseRaceLampMgr) SaveHorseRaceLamp() { MsgType: hrl.MsgType, Platform: hrl.Platform, State: hrl.State, - Target: hrl.Target, + Target: hrl.Players, StandSec: hrl.StandSec, }) } } func (this *HorseRaceLampMgr) Shutdown() { - this.SaveHorseRaceLamp() - module.UnregisteModule(this) + //this.SaveHorseRaceLamp() + //module.UnregisteModule(this) } func (this *HorseRaceLampMgr) BroadcastHorseRaceLampMsg(horseRaceLamp *HorseRaceLamp) { - if horseRaceLamp.MsgType == HorseRaceLampType_CustomMsg { + if horseRaceLamp.MsgType == HorseRaceLampTypeBatch { logger.Logger.Infof(">>>>>>>弹幕>>>>>>>>(this *HorseRaceLampMgr) BroadcastHorseRaceLampMsg content:%v msgType:%v "+ - "target:%v standSec:%v", horseRaceLamp.Content, horseRaceLamp.MsgType, horseRaceLamp.Target, horseRaceLamp.StandSec) + "players:%v standSec:%v", horseRaceLamp.Content, horseRaceLamp.MsgType, horseRaceLamp.Players, horseRaceLamp.StandSec) } var rawpack = &message.SCNotice{ Count: proto.Int(1), @@ -379,17 +398,17 @@ func (this *HorseRaceLampMgr) BroadcastHorseRaceLampMsg(horseRaceLamp *HorseRace } else if horseRaceLamp.MsgType == 100 { rawpack.Params = append(rawpack.Params, &message.NoticeParam{StrParam: proto.String(horseRaceLamp.Title)}) rawpack.Params = append(rawpack.Params, &message.NoticeParam{StrParam: proto.String(horseRaceLamp.Content)}) - rawpack.Params = append(rawpack.Params, &message.NoticeParam{StrParam: proto.String(horseRaceLamp.Footer)}) + //rawpack.Params = append(rawpack.Params, &message.NoticeParam{StrParam: proto.String(horseRaceLamp.Footer)}) } proto.SetDefaults(rawpack) - if len(horseRaceLamp.Target) == 0 { + if len(horseRaceLamp.Players) == 0 { PlayerMgrSington.BroadcastMessageToPlatform(horseRaceLamp.Platform, int(message.MSGPacketID_PACKET_SC_NOTICE), rawpack) } else { - PlayerMgrSington.BroadcastMessageToTarget(horseRaceLamp.Target, int(message.MSGPacketID_PACKET_SC_NOTICE), rawpack) + PlayerMgrSington.BroadcastMessageToTarget(horseRaceLamp.Players, int(message.MSGPacketID_PACKET_SC_NOTICE), rawpack) } } func init() { - module.RegisteModule(HorseRaceLampMgrSington, time.Second*3, 0) + //module.RegisteModule(HorseRaceLampMgrSingleton, time.Second*3, 0) } diff --git a/worldsrv/lotterymgr.go b/worldsrv/lotterymgr.go index 892a592..8f54f54 100644 --- a/worldsrv/lotterymgr.go +++ b/worldsrv/lotterymgr.go @@ -36,6 +36,7 @@ func init() { continue } if v.IsCycle { + logger.Logger.Tracef("LotteryMgrInst OnDayChange Reset") // 每天重置抽奖数据 LotteryMgrInst.Reset() // 重置玩家抽奖数据 @@ -89,6 +90,7 @@ func (l *LotteryData) Reset() { l.RobotIndex = 0 l.SnId = 0 l.Name = "" + l.RoleId = 0 l.WinCostCard = 0 l.WinCode = "" l.IsRobot = false @@ -233,6 +235,7 @@ func (l *LotteryData) Done() { var isMust bool // 是否必中 var index int // 开奖码序号 var tp int // 开奖类型 + var roleId int32 = common.DefaultRoleId // 先随机一个机器人 for _, v := range PlayerMgrSington.snidMap { @@ -326,8 +329,9 @@ func (l *LotteryData) Done() { if playerData != nil { awardPlayer = &Player{ PlayerData: &model.PlayerData{ - SnId: playerData.SnId, - Name: playerData.Name, + SnId: playerData.SnId, + Name: playerData.Name, + Roles: playerData.Roles, }, } } @@ -364,12 +368,16 @@ func (l *LotteryData) Done() { // 记录中奖结果 if awardPlayer != nil { + if awardPlayer.Roles != nil { + roleId = awardPlayer.Roles.ModId + } l.Num = LotteryMgrInst.GetIndex(l.Platform, l.CId) l.SnId = awardPlayer.SnId l.Name = awardPlayer.Name l.WinCostCard = costCard l.WinCode = code.Code l.IsRobot = awardPlayer.IsRobot() + l.RoleId = roleId var lotteryAward []*model.LotteryAward for _, v := range l.Reward { @@ -430,6 +438,9 @@ func (l *LotteryMgr) Init() { ld := l.GetData(v.IdStr, d.CId) ld.LotteryData = d ld.Platform = v.IdStr + if !common.TsInSameDay(ld.StartTs, time.Now().Unix()) { + ld.Reset() + } } } } @@ -615,6 +626,7 @@ func (l *LotteryMgr) GetList(plt string) []*welfare.LotteryInfo { WinCode: d.WinCode, SnId: d.SnId, Name: d.Name, + RoleId: d.RoleId, Index: int32(d.Num), Price: d.Price, NeedRoomCard: LotteryRoomCard, diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index 471d0ac..6a10564 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -10,7 +10,6 @@ import ( "sync" "time" - "github.com/globalsign/mgo/bson" "mongo.games.com/goserver/core/basic" "mongo.games.com/goserver/core/etcd" "mongo.games.com/goserver/core/logger" @@ -1795,212 +1794,212 @@ func init() { return common.ResponseTag_TransactYield, pack })) - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/CreateHorseRaceLamp", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &webapiproto.SACreateHorseRaceLamp{} - msg := &webapiproto.ASCreateHorseRaceLamp{} - err := proto.Unmarshal(params, msg) - if err != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "数据序列化失败" + err.Error() - return common.ResponseTag_ParamError, pack - } - platform := msg.Platform - title := msg.Title - content := msg.Content - footer := msg.Footer - count := msg.Count - state := msg.State - startTime := msg.StartTime - priority := msg.Priority - msgType := msg.MsgType - standSec := msg.StandSec - target := msg.Target - var horseRaceLamp *model.HorseRaceLamp - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - horseRaceLamp = model.NewHorseRaceLamp("", platform, title, content, footer, startTime, standSec, count, - priority, state, msgType, target, standSec) - return model.InsertHorseRaceLamp(platform, horseRaceLamp) - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - if data != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = data.(error).Error() - tNode.TransRep.RetFiels = pack - tNode.Resume() - return - } - HorseRaceLampMgrSington.AddHorseRaceLampMsg(horseRaceLamp.Id.Hex(), "", platform, title, content, footer, startTime, standSec, - count, msgType, state, priority, horseRaceLamp.CreateTime, target, standSec) - pack.Tag = webapiproto.TagCode_SUCCESS - tNode.TransRep.RetFiels = pack - tNode.Resume() - }), "CreateHorseRaceLamp").Start() - return common.ResponseTag_TransactYield, pack - })) - - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/GetHorseRaceLampById", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &webapiproto.SAGetHorseRaceLampById{} - msg := &webapiproto.ASGetHorseRaceLampById{} - err := proto.Unmarshal(params, msg) - if err != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "数据序列化失败" + err.Error() - return common.ResponseTag_ParamError, pack - } - noticeKey := msg.NoticeId - platform := msg.Platform - horseRaceLamp := HorseRaceLampMgrSington.HorseRaceLampMsgList[noticeKey] - if horseRaceLamp == nil || (len(platform) > 0 && horseRaceLamp.Platform != platform) { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "not find data" - } else { - pack.HorseRaceLamp = &webapiproto.HorseRaceLamp{ - Id: noticeKey, - Title: horseRaceLamp.Title, - Content: horseRaceLamp.Content, - Footer: horseRaceLamp.Footer, - StartTime: horseRaceLamp.StartTime, - Frequency: horseRaceLamp.Interval, - Count: horseRaceLamp.Count, - State: horseRaceLamp.State, - CreateTime: horseRaceLamp.CreateTime, - Priority: horseRaceLamp.Priority, - MsgType: horseRaceLamp.MsgType, - } - pack.Tag = webapiproto.TagCode_SUCCESS - } - return common.ResponseTag_Ok, pack - })) - - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/EditHorseRaceLamp", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &webapiproto.SAEditHorseRaceLamp{} - msg := &webapiproto.ASEditHorseRaceLamp{} - err := proto.Unmarshal(params, msg) - if err != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "数据序列化失败" + err.Error() - return common.ResponseTag_ParamError, pack - } - noticeKey := msg.HorseRaceLamp.Id - if len(noticeKey) == 0 { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "NoticeMsg id is nil" - return common.ResponseTag_ParamError, pack - } - hrl := msg.HorseRaceLamp - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - notice, err2 := model.GetHorseRaceLamp(hrl.Platform, bson.ObjectIdHex(noticeKey)) - if err2 != nil { - logger.Logger.Error("api GetNotice is error", err2) - return nil - } - model.EditHorseRaceLamp(&model.HorseRaceLamp{ - Id: bson.ObjectIdHex(noticeKey), - Channel: "", - Title: hrl.Title, - Content: hrl.Content, - Footer: hrl.Footer, - StartTime: hrl.StartTime, - Interval: hrl.Frequency, - Count: hrl.Count, - CreateTime: hrl.CreateTime, - Priority: hrl.Priority, - MsgType: hrl.MsgType, - Platform: hrl.Platform, - State: hrl.State, - Target: hrl.Target, - StandSec: hrl.StandSec, - }) - return notice - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - if data == nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "api GetNotice is error" - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("Marshal EditHorseRaceLamp response data error1:", err) - } - return - } else { - cache := HorseRaceLampMgrSington.EditHorseRaceLampMsg(&HorseRaceLamp{ - Key: noticeKey, - Channel: "", - Title: hrl.Title, - Content: hrl.Content, - Footer: hrl.Footer, - StartTime: hrl.StartTime, - Interval: hrl.Frequency, - Count: hrl.Count, - CreateTime: hrl.CreateTime, - Priority: hrl.Priority, - MsgType: hrl.MsgType, - Platform: hrl.Platform, - State: hrl.State, - Target: hrl.Target, - StandSec: hrl.StandSec, - }) - if !cache { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "api EditNoticeMsg is error" - tNode.TransRep.RetFiels = pack - tNode.Resume() - return - } - } - pack.Tag = webapiproto.TagCode_SUCCESS - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("Marshal EditHorseRaceLamp response data error3:", err) - } - }), "EditHorseRaceLamp").Start() - - return common.ResponseTag_TransactYield, pack - })) - - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/RemoveHorseRaceLampById", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &webapiproto.SARemoveHorseRaceLampById{} - msg := &webapiproto.ASRemoveHorseRaceLampById{} - err := proto.Unmarshal(params, msg) - if err != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "数据序列化失败" + err.Error() - return common.ResponseTag_ParamError, pack - } - noticeKey := msg.GetHorseRaceId() - platform := msg.GetPlatform() - notice := HorseRaceLampMgrSington.HorseRaceLampMsgList[noticeKey] - if notice == nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "not find data" - return common.ResponseTag_Ok, pack - } - if len(platform) > 0 && notice.Platform != notice.Platform { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "not find data" - return common.ResponseTag_Ok, pack - } - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - return model.RemoveHorseRaceLamp(platform, noticeKey) - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - if data != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "RemoveNotice is error" + data.(error).Error() - tNode.TransRep.RetFiels = pack - tNode.Resume() - return - } - HorseRaceLampMgrSington.DelHorseRaceLampMsg(noticeKey) - pack.Tag = webapiproto.TagCode_SUCCESS - tNode.TransRep.RetFiels = pack - tNode.Resume() - }), "ResponseTag_TransactYield").Start() - return common.ResponseTag_TransactYield, pack - })) + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/CreateHorseRaceLamp", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &webapiproto.SACreateHorseRaceLamp{} + // msg := &webapiproto.ASCreateHorseRaceLamp{} + // err := proto.Unmarshal(params, msg) + // if err != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err.Error() + // return common.ResponseTag_ParamError, pack + // } + // platform := msg.Platform + // title := msg.Title + // content := msg.Content + // footer := msg.Footer + // count := msg.Count + // state := msg.State + // startTime := msg.StartTime + // priority := msg.Priority + // msgType := msg.MsgType + // standSec := msg.StandSec + // target := msg.Target + // var horseRaceLamp *model.HorseRaceLamp + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // horseRaceLamp = model.NewHorseRaceLamp("", platform, title, content, footer, startTime, standSec, count, + // priority, state, msgType, target, standSec) + // return model.InsertHorseRaceLamp(platform, horseRaceLamp) + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // if data != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = data.(error).Error() + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // return + // } + // HorseRaceLampMgrSingleton.AddHorseRaceLampMsg(horseRaceLamp.Id.Hex(), "", platform, title, content, footer, startTime, standSec, + // count, msgType, state, priority, horseRaceLamp.CreateTime, target, standSec) + // pack.Tag = webapiproto.TagCode_SUCCESS + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // }), "CreateHorseRaceLamp").Start() + // return common.ResponseTag_TransactYield, pack + // })) + // + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/GetHorseRaceLampById", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &webapiproto.SAGetHorseRaceLampById{} + // msg := &webapiproto.ASGetHorseRaceLampById{} + // err := proto.Unmarshal(params, msg) + // if err != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err.Error() + // return common.ResponseTag_ParamError, pack + // } + // noticeKey := msg.NoticeId + // platform := msg.Platform + // horseRaceLamp := HorseRaceLampMgrSingleton.HorseRaceLampMsgList[noticeKey] + // if horseRaceLamp == nil || (len(platform) > 0 && horseRaceLamp.Platform != platform) { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "not find data" + // } else { + // pack.HorseRaceLamp = &webapiproto.HorseRaceLamp{ + // Id: noticeKey, + // Title: horseRaceLamp.Title, + // Content: horseRaceLamp.Content, + // Footer: horseRaceLamp.Footer, + // StartTime: horseRaceLamp.StartTime, + // Frequency: horseRaceLamp.Interval, + // Count: horseRaceLamp.Count, + // State: horseRaceLamp.State, + // CreateTime: horseRaceLamp.CreateTime, + // Priority: horseRaceLamp.Priority, + // MsgType: horseRaceLamp.MsgType, + // } + // pack.Tag = webapiproto.TagCode_SUCCESS + // } + // return common.ResponseTag_Ok, pack + // })) + // + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/EditHorseRaceLamp", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &webapiproto.SAEditHorseRaceLamp{} + // msg := &webapiproto.ASEditHorseRaceLamp{} + // err := proto.Unmarshal(params, msg) + // if err != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err.Error() + // return common.ResponseTag_ParamError, pack + // } + // noticeKey := msg.HorseRaceLamp.Id + // if len(noticeKey) == 0 { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "NoticeMsg id is nil" + // return common.ResponseTag_ParamError, pack + // } + // hrl := msg.HorseRaceLamp + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // notice, err2 := model.GetHorseRaceLamp(hrl.Platform, bson.ObjectIdHex(noticeKey)) + // if err2 != nil { + // logger.Logger.Error("api GetNotice is error", err2) + // return nil + // } + // model.EditHorseRaceLamp(&model.HorseRaceLamp{ + // Id: bson.ObjectIdHex(noticeKey), + // Channel: "", + // Title: hrl.Title, + // Content: hrl.Content, + // Footer: hrl.Footer, + // StartTime: hrl.StartTime, + // Interval: hrl.Frequency, + // Count: hrl.Count, + // CreateTime: hrl.CreateTime, + // Priority: hrl.Priority, + // MsgType: hrl.MsgType, + // Platform: hrl.Platform, + // State: hrl.State, + // Target: hrl.Target, + // StandSec: hrl.StandSec, + // }) + // return notice + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // if data == nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "api GetNotice is error" + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("Marshal EditHorseRaceLamp response data error1:", err) + // } + // return + // } else { + // cache := HorseRaceLampMgrSingleton.EditHorseRaceLampMsg(&HorseRaceLamp{ + // Key: noticeKey, + // Channel: "", + // Title: hrl.Title, + // Content: hrl.Content, + // Footer: hrl.Footer, + // StartTime: hrl.StartTime, + // Interval: hrl.Frequency, + // Count: hrl.Count, + // CreateTime: hrl.CreateTime, + // Priority: hrl.Priority, + // MsgType: hrl.MsgType, + // Platform: hrl.Platform, + // State: hrl.State, + // Target: hrl.Target, + // StandSec: hrl.StandSec, + // }) + // if !cache { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "api EditNoticeMsg is error" + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // return + // } + // } + // pack.Tag = webapiproto.TagCode_SUCCESS + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("Marshal EditHorseRaceLamp response data error3:", err) + // } + // }), "EditHorseRaceLamp").Start() + // + // return common.ResponseTag_TransactYield, pack + // })) + // + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Message/RemoveHorseRaceLampById", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &webapiproto.SARemoveHorseRaceLampById{} + // msg := &webapiproto.ASRemoveHorseRaceLampById{} + // err := proto.Unmarshal(params, msg) + // if err != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err.Error() + // return common.ResponseTag_ParamError, pack + // } + // noticeKey := msg.GetHorseRaceId() + // platform := msg.GetPlatform() + // notice := HorseRaceLampMgrSingleton.HorseRaceLampMsgList[noticeKey] + // if notice == nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "not find data" + // return common.ResponseTag_Ok, pack + // } + // if len(platform) > 0 && notice.Platform != notice.Platform { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "not find data" + // return common.ResponseTag_Ok, pack + // } + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // return model.RemoveHorseRaceLamp(platform, noticeKey) + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // if data != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "RemoveNotice is error" + data.(error).Error() + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // return + // } + // HorseRaceLampMgrSingleton.DelHorseRaceLampMsg(noticeKey) + // pack.Tag = webapiproto.TagCode_SUCCESS + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // }), "ResponseTag_TransactYield").Start() + // return common.ResponseTag_TransactYield, pack + // })) WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Ctrl/ResetEtcdData", WebAPIHandlerWrapper( func(tNode *transact.TransNode, params []byte) (int, proto.Message) {