This commit is contained in:
殷勇 2023-10-30 11:47:27 +08:00
parent 1e49bc8869
commit 14223c4f96
2 changed files with 10 additions and 10 deletions

View File

@ -42,22 +42,19 @@ func NewMail() *Mail {
}
func (m *Mail) ParseAttachments(attachmentsStr string) {
if len(attachmentsStr) <= 0 {
return
}
attachmentStrList := strings.Split(attachmentsStr, "|")
m.ATT = make([]*Attachment, 0, len(attachmentStrList))
for _, attachmentStr := range attachmentStrList {
if len(attachmentStr) <= 0 {
continue
}
parts := strings.Split(attachmentStr, ":")
if len(parts) != 2 {
itemParts := strings.Split(attachmentStr, ":")
if len(itemParts) != 2 {
continue
}
attachment := &Attachment{
ItemId: q5.ToInt(parts[0]),
ItemNum: q5.ToInt(parts[1]),
ItemId: q5.ToInt(itemParts[0]),
ItemNum: q5.ToInt(itemParts[1]),
}
m.ATT = append(m.ATT, attachment)
}

View File

@ -38,7 +38,7 @@ func (mm *MailMgr) GetMail(mailId int64) *Mail {
func (mm *MailMgr) FetchMailFromDB() {
timer := f5.GetTimer()
timer.SetInterval(1000, func(e int32, args *q5.Args) {
timer.SetInterval(6000, func(e int32, args *q5.Args) {
if e == q5.TIMER_EXEC_EVENT {
mm.LoadFromDB()
}
@ -59,7 +59,7 @@ func (mm *MailMgr) LoadFromDB() {
func(err error, rows *f5.DataSet) {
if err != nil {
f5.GetSysLog().Info("LoadFromDB Error:%v \n", err)
panic(err)
done = true
}
empty := true
for rows.Next() {
@ -79,7 +79,10 @@ func (mm *MailMgr) LoadFromDB() {
m.ExpireTime = q5.ToInt32(*rows.GetByName("expiretime"))
m.CreateTime = q5.ToInt32(*rows.GetByName("createtime"))
// parse ATT
m.ParseAttachments(q5.ToString(*rows.GetByName("attachments")))
attachmentsStr := q5.ToString(*rows.GetByName("attachments"))
if len(attachmentsStr) > 0 {
m.ParseAttachments(attachmentsStr)
}
mm.AddMail(m)
lastIdx = q5.ToInt64(*rows.GetByName("idx"))