From 3fd6e2b00f1c291d79bfcad191aa950809358268 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 24 Jun 2024 16:22:45 +0800 Subject: [PATCH] 1 --- server/backtask/mt/Mail.go | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/server/backtask/mt/Mail.go b/server/backtask/mt/Mail.go index 10873f7a..19f73dad 100644 --- a/server/backtask/mt/Mail.go +++ b/server/backtask/mt/Mail.go @@ -1,12 +1,26 @@ package mt import ( + "q5" + "main/constant" + "fmt" ) type Mail struct { + title string + content string +} + +func (this *Mail) GetTitle() string { + return this.title +} + +func (this *Mail) GetContent() string { + return this.content } type MailTable struct { + nameHash *q5.ConcurrentMap[string, *Mail] } func (this *MailTable) IsNoLoad() bool { @@ -14,6 +28,14 @@ func (this *MailTable) IsNoLoad() bool { } func (this *MailTable) Load() { + this.nameHash = new(q5.ConcurrentMap[string, *Mail]) + this.loadMail(constant.MAIL_HERO_MINT) + this.loadMail(constant.MAIL_HERO_LOCK) + this.loadMail(constant.MAIL_HERO_UNLOCK) + + this.loadMail(constant.MAIL_HERO_MINT) + this.loadMail(constant.MAIL_HERO_LOCK) + this.loadMail(constant.MAIL_HERO_UNLOCK) } func (this *MailTable) PreInit1() { @@ -27,3 +49,25 @@ func (this *MailTable) ElementsInit(int) { func (this *MailTable) PostInit1() { } + +func (this *MailTable) loadMail(mailName string) { + p := new(Mail) + tmpStrings := q5.StrSplit(mailName, ".") + { + fileName := fmt.Sprintf("../config/%s/%s.title.txt", tmpStrings[0], tmpStrings[1]) + if data, err := q5.LoadFileAsString(fileName); err == nil { + p.title = data + } else { + panic(fmt.Sprintf("load mail title %s error %s", mailName, err)) + } + } + { + fileName := fmt.Sprintf("../config/%s/%s.content.txt", tmpStrings[0], tmpStrings[1]) + if data, err := q5.LoadFileAsString(fileName); err == nil { + p.content = data + } else { + panic(fmt.Sprintf("load mail content %s error %s", mailName, err)) + } + } + this.nameHash.Store(mailName, p) +}