1
This commit is contained in:
parent
99a609e66f
commit
3fd6e2b00f
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user