消息通知-未定义通知模板或模板不存使用默认模板
This commit is contained in:
@@ -305,7 +305,13 @@ func (j *Job) Run() {
|
|||||||
var title = ""
|
var title = ""
|
||||||
var content = ""
|
var content = ""
|
||||||
notifyTpl, err := models.NotifyTplGetById(j.task.NotifyTplId)
|
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
|
title = notifyTpl.Title
|
||||||
content = notifyTpl.Content
|
content = notifyTpl.Content
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,16 @@ func NotifyTplAdd(obj *NotifyTpl) (int64, error) {
|
|||||||
return orm.NewOrm().Insert(obj)
|
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) {
|
func NotifyTplGetById(id int) (*NotifyTpl, error) {
|
||||||
obj := &NotifyTpl{
|
obj := &NotifyTpl{
|
||||||
Id: id,
|
Id: id,
|
||||||
|
|||||||
Reference in New Issue
Block a user