This commit is contained in:
aozhiwei 2024-06-05 13:46:40 +08:00
parent a5088a47cc
commit 5194fcd93a

View File

@ -52,8 +52,72 @@ func (this *taskMgr) syncSysMail() {
}
}()
for true {
this.pullSysMail()
this.syncSysMailCond.L.Lock()
this.syncSysMailCond.Wait()
this.syncSysMailCond.L.Unlock()
}
}
func (this *taskMgr) pullSysMail() {
f5.GetGoStyleDb().SelectCustomQuery(
constant.MAIL_DB,
fmt.Sprintf("SELECT * FROM t_sys_mail WHERE idx>%d LIMIT 1000;", this.lastSyncSysMailIdx),
func (err error, ds *f5.DataSet) {
if err != nil {
f5.GetSysLog().Warning("pullSysMail %s", err)
return
}
for ds.Next() {
idx := q5.ToInt64(ds.GetByName("idx"))
if !this.writeMail(ds) {
return
}
if idx > this.lastSyncSysMailIdx {
this.lastSyncSysMailIdx = idx
}
}
})
}
func (this *taskMgr) writeMail(ds *f5.DataSet) bool {
unikey := ds.GetByName("unikey")
subject := ds.GetByName("subject")
content := ds.GetByName("content")
recipients := ds.GetByName("recipients")
attachments := ds.GetByName("attachments")
tag1 := q5.ToInt32(ds.GetByName("tag1"))
tag2 := q5.ToInt32(ds.GetByName("tag2"))
sendTime := q5.ToInt32(ds.GetByName("sendtime"))
expireTime := q5.ToInt32(ds.GetByName("expiretime"))
userRegStartTime := q5.ToInt32(ds.GetByName("user_reg_start_time"))
userRegEndTime := q5.ToInt32(ds.GetByName("user_reg_end_time"))
var ok = false
f5.GetGoStyleDb().Upsert(
constant.MAIL_DB,
"t_mail",
[][]string{
{"unikey", unikey},
},
[][]string{
},
[][]string{
{"mail_id", q5.ToString(f5.GetApp().NewLockNodeUuid())},
{"mail_type", q5.ToString(constant.MAIL_TYPE_GROUP)},
{"unikey", unikey},
{"subject", subject},
{"content", content},
{"recipients", recipients},
{"attachments", attachments},
{"sendtime", q5.ToString(sendTime)},
{"user_reg_start_time", q5.ToString(userRegStartTime)},
{"user_reg_end_time", q5.ToString(userRegEndTime)},
{"tag1", q5.ToString(tag1)},
{"tag2", q5.ToString(tag2)},
{"expiretime", q5.ToString(expireTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
ok = err == nil
})
return ok
}