update i18n(template)

pull/680/head
shiqstone 2021-04-21 13:37:47 +08:00
parent a92739d4a0
commit 883fcec5b2
1 changed files with 48 additions and 48 deletions

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
"github.com/astaxie/beego/orm" "github.com/astaxie/beego/orm"
"github.com/beego/i18n"
"github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/conf"
"github.com/mindoc-org/mindoc/models" "github.com/mindoc-org/mindoc/models"
) )
@ -14,13 +15,13 @@ type TemplateController struct {
BookId int BookId int
} }
func (c *TemplateController) isPermission() (error) { func (c *TemplateController) isPermission() error {
c.Prepare() c.Prepare()
bookIdentify := c.GetString("identify", "") bookIdentify := c.GetString("identify", "")
if bookIdentify == "" { if bookIdentify == "" {
return errors.New("参数错误") return errors.New(i18n.Tr(c.Lang, "message.param_error"))
} }
if !c.Member.IsAdministrator() { if !c.Member.IsAdministrator() {
@ -44,6 +45,7 @@ func (c *TemplateController) isPermission() (error) {
} }
return nil return nil
} }
//获取指定模板信息 //获取指定模板信息
func (c *TemplateController) Get() { func (c *TemplateController) Get() {
if err := c.isPermission(); err != nil { if err := c.isPermission(); err != nil {
@ -100,9 +102,8 @@ func (c *TemplateController) Add() {
} }
template := models.NewTemplate() template := models.NewTemplate()
if templateId > 0 { if templateId > 0 {
t,err := template.Find(templateId); t, err := template.Find(templateId)
if err != nil { if err != nil {
c.JsonResult(500, "模板不存在") c.JsonResult(500, "模板不存在")
} }
@ -111,7 +112,6 @@ func (c *TemplateController) Add() {
template.ModifyAt = c.Member.MemberId template.ModifyAt = c.Member.MemberId
} }
template.TemplateId = templateId template.TemplateId = templateId
template.BookId = c.BookId template.BookId = c.BookId
template.TemplateContent = content template.TemplateContent = content