From c3fbd7a32170cb5e71e0b1ee862a12080a856af8 Mon Sep 17 00:00:00 2001 From: linxiaozhi Date: Sat, 16 Feb 2019 22:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5-=E6=9C=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=80=9A=E7=9F=A5=E6=A8=A1=E6=9D=BF=E6=88=96?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=B8=8D=E5=AD=98=E4=BD=BF=E7=94=A8=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jobs/job.go | 8 +++++++- models/notify_tpl.go | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/jobs/job.go b/jobs/job.go index adb8f54..6496ef0 100644 --- a/jobs/job.go +++ b/jobs/job.go @@ -305,7 +305,13 @@ func (j *Job) Run() { var title = "" var content = "" notifyTpl, err := models.NotifyTplGetById(j.task.NotifyTplId) - if err == nil { + if err != nil { + notifyTpl, err := models.NotifyTplGetByTplType(j.task.NotifyType, "system") + if err == nil { + title = notifyTpl.Title + content = notifyTpl.Content + } + } else { title = notifyTpl.Title content = notifyTpl.Content } diff --git a/models/notify_tpl.go b/models/notify_tpl.go index adde96f..237415b 100644 --- a/models/notify_tpl.go +++ b/models/notify_tpl.go @@ -63,6 +63,16 @@ func NotifyTplAdd(obj *NotifyTpl) (int64, error) { return orm.NewOrm().Insert(obj) } +func NotifyTplGetByTplType(tpl_type int, typestr string) (NotifyTpl, error) { + var list NotifyTpl + err := orm.NewOrm().QueryTable(TableName("notify_tpl")).Filter("type", typestr).Filter("tpl_type", tpl_type).Filter("status", 1).Limit(1).One(&list) + if err != nil { + return list, err + } + + return list, nil +} + func NotifyTplGetById(id int) (*NotifyTpl, error) { obj := &NotifyTpl{ Id: id,