From 5194fcd93aa7ae1fceb83e19b372bf81d04a3df7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 5 Jun 2024 13:46:40 +0800 Subject: [PATCH] 1 --- server/adminserver/task/taskmgr.go | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/server/adminserver/task/taskmgr.go b/server/adminserver/task/taskmgr.go index 681fd875..0d25b5d7 100644 --- a/server/adminserver/task/taskmgr.go +++ b/server/adminserver/task/taskmgr.go @@ -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 +}