消息通知-未定义通知模板或模板不存使用默认模板

This commit is contained in:
linxiaozhi
2019-02-16 22:30:10 +08:00
parent c6bb435f15
commit c3fbd7a321
2 changed files with 17 additions and 1 deletions

View File

@@ -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
}

View File

@@ -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,