You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: notify_tpl.go
    path of file: ./repos/PPGo_Job/controllers
    
    the code of the file until where you have to start completion: /************************************************************
** @Description: controllers
** @Author: Bee
** @Date:   2019-02-15 20:21
** @Last Modified by:   Bee
** @Last Modified time: 2019-02-15 20:21
*************************************************************/
package controllers

import (
	"encoding/json"
	"github.com/astaxie/beego"
	"github.com/george518/PPGo_Job/models"
	"strings"
	"time"
)

type NotifyTplController struct {
	BaseController
}

func (self *NotifyTplController) List() {
	self.Data["pageTitle"] = "通知模板"
	self.display()
}

func (self *NotifyTplController) Add() {
	self.Data["pageTitle"] = "新增通知模板"
	self.Data["serverGroup"] = serverGroupLists(self.serverGroups, self.userId)
	self.display()
}

func (self *NotifyTplController) Edit() {
	self.Data["pageTitle"] = "编辑通知模板"

	id, _ := self.GetInt("id", 0)
	notifyTpl, _ := models.NotifyTplGetById(id)
	row := make(map[string]interface{})
	row["id"] = notifyTpl.Id
	row["tpl_name"] = notifyTpl.TplName
	row["tpl_type"] = notifyTpl.TplType
	row["title"] = notifyTpl.Title
	row["content"] = notifyTpl.Content
	row["s
    
func (self *NotifyTplController) AjaxSave() {
	tpl_id, _ := self.GetInt("id")
	if tpl_id == 0 {
		notifyTpl := new(models.NotifyTpl)
		notifyTpl.TplName = strings.TrimSpace(self.GetString("tpl_name"))
		notifyTpl.TplType, _ = self.GetInt("tpl_type")
		notifyTpl.Title = strings.TrimSpace(self.GetString("title"))
		notifyTpl.Content = strings.TrimSpace(self.GetString("content"))
		notifyTpl.CreateId = self.userId
		notifyTpl.CreateTime = time.Now().Unix()
		notifyTpl.Type = models.NotifyTplTypeDefault
		notifyTpl.Status, _ = self.GetInt("status")

		if notifyTpl.TplType == 1 || notifyTpl.TplType == 2 || notifyTpl.TplType == 3 {
			m := make(map[string]string)
			err := json.Unmarshal([]byte(notifyTpl.Content), &m)
			if err != nil {
				self.ajaxMsg("模板内容格式错误,"+err.Error(), MSG_ERR)
			}
		}

		if _, err := models.NotifyTplAdd(notifyTpl); err != nil {
			self.ajaxMsg(err.Error(), MSG_ERR)
		}
		self.ajaxMsg("", MSG_OK)
	}

	notifyTpl, _ := models.NotifyTplGetById(tpl_id)
	//修改
	notifyTpl.Id = tpl_id
	notifyTpl.UpdateId = self.userId
	notifyTpl.UpdateTime = time.Now().Unix()

	notifyTpl.TplName = strings.TrimSpace(self.GetString("tpl_name"))
	notifyTpl.TplType, _ = self.GetInt("tpl_type")
	notifyTpl.Title = strings.TrimSpace(self.GetString("title"))
	notifyTpl.Content = strings.TrimSpace(self.GetString("content"))
	notifyTpl.Status, _ = self.GetInt("status")

	if notifyTpl.Type == models.NotifyTplTypeSystem {
		self.ajaxMsg("系统模板禁止更新", MSG_ERR)
	}

	if notifyTpl.TplType == 1 || notifyTpl.TplType == 2 || notifyTpl.TplType == 3 {
		m := make(map[string]string)
		err := json.Unmarshal([]byte(notifyTpl.Content), &m)
		if err != nil {
			self.ajaxMsg("模板内容格式错误,"+err.Error(), MSG_ERR)
		}
	}

	if err := notifyTpl.Update(); err != nil {
		self.ajaxMsg("更新失败,"+err.Error(), MSG_ERR)
	}
	self.ajaxMsg("", MSG_OK)
}