save
This commit is contained in:
parent
1e49bc8869
commit
14223c4f96
@ -42,22 +42,19 @@ func NewMail() *Mail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mail) ParseAttachments(attachmentsStr string) {
|
func (m *Mail) ParseAttachments(attachmentsStr string) {
|
||||||
if len(attachmentsStr) <= 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
attachmentStrList := strings.Split(attachmentsStr, "|")
|
attachmentStrList := strings.Split(attachmentsStr, "|")
|
||||||
m.ATT = make([]*Attachment, 0, len(attachmentStrList))
|
m.ATT = make([]*Attachment, 0, len(attachmentStrList))
|
||||||
for _, attachmentStr := range attachmentStrList {
|
for _, attachmentStr := range attachmentStrList {
|
||||||
if len(attachmentStr) <= 0 {
|
if len(attachmentStr) <= 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
parts := strings.Split(attachmentStr, ":")
|
itemParts := strings.Split(attachmentStr, ":")
|
||||||
if len(parts) != 2 {
|
if len(itemParts) != 2 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
attachment := &Attachment{
|
attachment := &Attachment{
|
||||||
ItemId: q5.ToInt(parts[0]),
|
ItemId: q5.ToInt(itemParts[0]),
|
||||||
ItemNum: q5.ToInt(parts[1]),
|
ItemNum: q5.ToInt(itemParts[1]),
|
||||||
}
|
}
|
||||||
m.ATT = append(m.ATT, attachment)
|
m.ATT = append(m.ATT, attachment)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (mm *MailMgr) GetMail(mailId int64) *Mail {
|
|||||||
|
|
||||||
func (mm *MailMgr) FetchMailFromDB() {
|
func (mm *MailMgr) FetchMailFromDB() {
|
||||||
timer := f5.GetTimer()
|
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 {
|
if e == q5.TIMER_EXEC_EVENT {
|
||||||
mm.LoadFromDB()
|
mm.LoadFromDB()
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func (mm *MailMgr) LoadFromDB() {
|
|||||||
func(err error, rows *f5.DataSet) {
|
func(err error, rows *f5.DataSet) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f5.GetSysLog().Info("LoadFromDB Error:%v \n", err)
|
f5.GetSysLog().Info("LoadFromDB Error:%v \n", err)
|
||||||
panic(err)
|
done = true
|
||||||
}
|
}
|
||||||
empty := true
|
empty := true
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
@ -79,7 +79,10 @@ func (mm *MailMgr) LoadFromDB() {
|
|||||||
m.ExpireTime = q5.ToInt32(*rows.GetByName("expiretime"))
|
m.ExpireTime = q5.ToInt32(*rows.GetByName("expiretime"))
|
||||||
m.CreateTime = q5.ToInt32(*rows.GetByName("createtime"))
|
m.CreateTime = q5.ToInt32(*rows.GetByName("createtime"))
|
||||||
// parse ATT
|
// 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)
|
mm.AddMail(m)
|
||||||
lastIdx = q5.ToInt64(*rows.GetByName("idx"))
|
lastIdx = q5.ToInt64(*rows.GetByName("idx"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user