diff --git a/controllers/notify_tpl.go b/controllers/notify_tpl.go index 1159936..b442a0e 100644 --- a/controllers/notify_tpl.go +++ b/controllers/notify_tpl.go @@ -56,7 +56,7 @@ func (self *NotifyTplController) AjaxSave() { notifyTpl.Content = strings.TrimSpace(self.GetString("content")) notifyTpl.CreateId = self.userId notifyTpl.CreateTime = time.Now().Unix() - notifyTpl.Type = "default" + notifyTpl.Type = models.NotifyTplTypeDefault notifyTpl.Status, _ = self.GetInt("status") if notifyTpl.TplType == 1 { @@ -93,7 +93,7 @@ func (self *NotifyTplController) AjaxSave() { } } - if notifyTpl.Type == "system" { + if notifyTpl.Type == models.NotifyTplTypeSystem { self.ajaxMsg("系统模板禁止更新", MSG_ERR) } @@ -107,7 +107,7 @@ func (self *NotifyTplController) AjaxDel() { id, _ := self.GetInt("id") notifyTpl, _ := models.NotifyTplGetById(id) - if notifyTpl.Type == "system" { + if notifyTpl.Type == models.NotifyTplTypeSystem { self.ajaxMsg("系统模板禁止删除", MSG_ERR) } diff --git a/jobs/job.go b/jobs/job.go index 6496ef0..fc8b65c 100644 --- a/jobs/job.go +++ b/jobs/job.go @@ -306,7 +306,7 @@ func (j *Job) Run() { var content = "" notifyTpl, err := models.NotifyTplGetById(j.task.NotifyTplId) if err != nil { - notifyTpl, err := models.NotifyTplGetByTplType(j.task.NotifyType, "system") + notifyTpl, err := models.NotifyTplGetByTplType(j.task.NotifyType, models.NotifyTplTypeSystem) if err == nil { title = notifyTpl.Title content = notifyTpl.Content diff --git a/models/notify_tpl.go b/models/notify_tpl.go index 237415b..3d549de 100644 --- a/models/notify_tpl.go +++ b/models/notify_tpl.go @@ -13,6 +13,11 @@ import ( "time" ) +const ( + NotifyTplTypeSystem = "system" + NotifyTplTypeDefault = "default" +) + type NotifyTpl struct { Id int Type string