feat 初始化
This commit is contained in:
85
template/notice/constant.go
Normal file
85
template/notice/constant.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package notice
|
||||
|
||||
import "git.hlsq.asia/alex/proto/topic"
|
||||
|
||||
const (
|
||||
// 在线比赛通知
|
||||
|
||||
onlineMatchNoticeStart = iota // 在线比赛开始提醒
|
||||
|
||||
// 锦标赛通知
|
||||
|
||||
tournamentMatchRemind // 比赛提醒
|
||||
tournamentMatchScoreAnnouncementPromoted // 成绩公告-晋级决赛
|
||||
tournamentMatchScoreAnnouncementNotPromoted // 成绩公告-未晋级决赛
|
||||
tournamentMatchScoreAnnouncementFinalEnd // 成绩公告-决赛结束后
|
||||
tournamentMatchRewardDistribute // 奖励发放
|
||||
tournamentMatchViolateNotice // 违规通报
|
||||
)
|
||||
|
||||
type TemplateNoticeLang string
|
||||
|
||||
const (
|
||||
ZhCN TemplateNoticeLang = "zh-CN"
|
||||
)
|
||||
|
||||
var defaultLang = ZhCN
|
||||
|
||||
var noticeTemplate = map[int32]map[TemplateNoticeLang]topic.TemplateNoticeData{
|
||||
onlineMatchNoticeStart: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "",
|
||||
Msg: "您的队友正在等待您开局,点击返回>>",
|
||||
XiaomiTemplateId: "P20513",
|
||||
CustomParam: `{"type":1, "param":[]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchRemind: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "比赛提醒",
|
||||
Msg: "%v锦标赛第%v轮将于明天开启,记得前来参赛!",
|
||||
XiaomiTemplateId: "P20086",
|
||||
CustomParam: `{"type":2, "param":["%v", "1", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchScoreAnnouncementPromoted: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "成绩公告",
|
||||
Msg: "恭喜您在%v锦标赛晋级赛获得第%v名,成功晋级决赛!",
|
||||
XiaomiTemplateId: "P20088",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchScoreAnnouncementNotPromoted: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "成绩公告",
|
||||
Msg: "很遗憾,您在%v锦标赛晋级赛中未能进入下一阶段比赛。感谢您的参与!",
|
||||
XiaomiTemplateId: "P20088",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchScoreAnnouncementFinalEnd: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "成绩公告",
|
||||
Msg: "恭喜您在%v锦标赛决赛获得第%v名!",
|
||||
XiaomiTemplateId: "P20088",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchRewardDistribute: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "奖励发放",
|
||||
Msg: "%v锦标赛于%v月%v日成功完赛,点击查看最终排名!",
|
||||
XiaomiTemplateId: "P20084",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchViolateNotice: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "违规通报",
|
||||
Msg: "后台检测到您在%v锦标赛第%v轮比赛中存在违规情况,本次比赛成绩无效,有任何疑问请联系客服。",
|
||||
XiaomiTemplateId: "P20085",
|
||||
CustomParam: `{"type":0, "param":[]}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
120
template/notice/notice.go
Normal file
120
template/notice/notice.go
Normal file
@@ -0,0 +1,120 @@
|
||||
package notice
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/proto/topic"
|
||||
)
|
||||
|
||||
// GetOnlineMatchNoticeStart 在线比赛开始通知
|
||||
// lang 语言
|
||||
func GetOnlineMatchNoticeStart(lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
return noticeTemplate[onlineMatchNoticeStart][defaultLang]
|
||||
}
|
||||
|
||||
// GetTournamentMatchRemind 比赛提醒
|
||||
// name 锦标赛名称
|
||||
// wheel 锦标赛轮次
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchRemind(name string, wheel int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchRemind][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchScoreAnnouncementPromoted 成绩公告-晋级决赛
|
||||
// name 锦标赛名称
|
||||
// ranking 排名
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchScoreAnnouncementPromoted(name string, ranking int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchScoreAnnouncementPromoted][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchScoreAnnouncementNotPromoted 成绩公告-未晋级决赛
|
||||
// name 锦标赛名称
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchScoreAnnouncementNotPromoted(name string, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchScoreAnnouncementNotPromoted][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchScoreAnnouncementFinalEnd 成绩公告-决赛结束后
|
||||
// name 锦标赛名称
|
||||
// ranking 排名
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchScoreAnnouncementFinalEnd(name string, ranking int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchScoreAnnouncementFinalEnd][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchRewardDistribute 奖励发放
|
||||
// name 锦标赛名称
|
||||
// month 月份
|
||||
// day 日
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchRewardDistribute(name string, month, day int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchRewardDistribute][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, month, day)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchViolateNotice 违规通报
|
||||
// name 锦标赛名称
|
||||
// wheel 锦标赛轮次
|
||||
func GetTournamentMatchViolateNotice(name string, wheel int32, lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchViolateNotice][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
|
||||
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user