diff --git a/README.md b/README.md index 286a2b0d2..1cbd48d20 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,11 @@ go build -ldflags "-w" -o mindoc main.go bee run ``` +## 旧版本运行 可更新部分数据库配置 +```base +./mindoc update +``` + MinDoc 如果使用MySQL储存数据,则编码必须是`utf8mb4_general_ci`。请在安装前,把数据库配置填充到项目目录下的 `conf/app.conf` 中。 如果使用 `SQLite` 数据库,则直接在配置文件中配置数据库路径即可. @@ -189,39 +194,44 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP **创建项目** -![创建项目](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204438.png) +![创建项目](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/create.png?raw=true) **项目列表** -![项目列表](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203542.png) +![项目列表](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/project_list.png?raw=true) **项目概述** -![项目概述](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203619.png) +![项目概述](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/intro.png?raw=true) **项目成员** -![项目成员](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203637.png) +![项目成员](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/member.png?raw=true) **项目设置** -![项目设置](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203656.png) +![项目设置](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/project_setting.png?raw=true) **基于Editor.md开发的Markdown编辑器** -![基于Editor.md开发的Markdown编辑器](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203854.png) +![基于Editor.md开发的Markdown编辑器](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/editor_md.png?raw=true) **基于wangEditor开发的富文本编辑器** -![基于wangEditor开发的富文本编辑器](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204651.png) +![基于wangEditor开发的富文本编辑器](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/wang_editor.png?raw=true) + + +**基于cherryMarkdown开发的编辑器** + +![基于cherry-markdown开发的编辑器](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/cheery-markdown.png?raw=true) **项目预览** -![项目预览](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204609.png) +![项目预览](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/preview.png?raw=true) **超级管理员后台** -![超级管理员后台](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204710.png) +![超级管理员后台](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/admin.png?raw=true) # 使用的技术(TODO: 最新技术栈整理中,使用的第三方库升级中) @@ -229,6 +239,7 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP - [Beego](https://github.com/beego/beego) ~~1.10.0~~ - MySQL 5.6 - [editor.md](https://github.com/pandao/editor.md) Markdown 编辑器 +- [cherry-markdown](https://github.com/Tencent/cherry-markdown) Cherry Markdown Writer - [Bootstrap](https://github.com/twbs/bootstrap) 3.2 - [jQuery](https://github.com/jquery/jquery) 库 - [WebUploader](https://github.com/fex-team/webuploader) 文件上传框架 @@ -250,13 +261,13 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP # 主要功能 -- 项目管理,可以对项目进行编辑更改,成员添加等。 +- 项目管理,可以对项目进行编辑更改,成员添加, 项目排序等。 - 文档管理,添加和删除文档等。 - 评论管理,可以管理文档评论和自己发布的评论。 - 用户管理,添加和禁用用户,个人资料更改等。 - 用户权限管理 , 实现用户角色的变更。 - 项目加密,可以设置项目公开状态,私有项目需要通过Token访问。 -- 站点配置,可开启匿名访问、验证码等。 +- 站点配置,多语言切换, 可开启匿名访问、验证码等。 # 参与开发 diff --git a/commands/command.go b/commands/command.go index 63a01a2a7..dbe2b9c9f 100644 --- a/commands/command.go +++ b/commands/command.go @@ -143,6 +143,11 @@ func RegisterModel() { gob.Register(models.Document{}) gob.Register(models.Template{}) //migrate.RegisterMigration() + err := orm.RunSyncdb("default", false, true) + if err != nil { + logs.Error("注册Model失败 ->", err) + os.Exit(1) + } } // RegisterLogger 注册日志 @@ -229,6 +234,9 @@ func RegisterCommand() { } else if len(os.Args) >= 2 && os.Args[1] == "version" { CheckUpdate() os.Exit(0) + } else if len(os.Args) >= 2 && os.Args[1] == "update" { + Update() + os.Exit(0) } } diff --git a/commands/update.go b/commands/update.go index 205d39cbe..ae2f99e63 100644 --- a/commands/update.go +++ b/commands/update.go @@ -3,15 +3,17 @@ package commands import ( "encoding/json" "fmt" + "github.com/mindoc-org/mindoc/models" "io/ioutil" "net/http" "os" + "github.com/beego/beego/v2/client/orm" "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" ) -//检查最新版本. +// 检查最新版本. func CheckUpdate() { fmt.Println("MinDoc current version => ", conf.VERSION) @@ -47,3 +49,23 @@ func CheckUpdate() { os.Exit(0) } + +func Update() { + fmt.Println("Update...") + RegisterDataBase() + RegisterModel() + err := orm.RunSyncdb("default", false, true) + if err == nil { + UpdateInitialization() + } else { + panic(err.Error()) + } + fmt.Println("Update Successfully!") + os.Exit(0) +} +func UpdateInitialization() { + err := models.NewOption().Update() + if err != nil { + panic(err.Error()) + } +} diff --git a/conf/app.conf.example b/conf/app.conf.example index afa11c76f..58d4ab017 100644 --- a/conf/app.conf.example +++ b/conf/app.conf.example @@ -79,7 +79,7 @@ avatar=/static/images/headimgurl.jpg token_size=12 #上传文件的后缀,如果不限制后缀可以设置为 * -upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif +upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif|mp4|webm|avi #上传的文件大小限制 # - 如果不填写, 则默认1GB,如果希望超过1GB,必须带单位 diff --git a/conf/enumerate.go b/conf/enumerate.go index c4a986b06..3a66afa35 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -106,9 +106,9 @@ func GetDefaultCover() string { return URLForWithCdnImage(web.AppConfig.DefaultString("cover", "/static/images/book.jpg")) } -// 获取允许的商城文件的类型. +// 获取允许的上传文件的类型. func GetUploadFileExt() []string { - ext := web.AppConfig.DefaultString("upload_file_ext", "png|jpg|jpeg|gif|txt|doc|docx|pdf") + ext := web.AppConfig.DefaultString("upload_file_ext", "png|jpg|jpeg|gif|txt|doc|docx|pdf|mp4") temp := strings.Split(ext, "|") @@ -201,7 +201,7 @@ func GetExportOutputPath() string { return exportOutputPath } -// 判断是否是允许商城的文件类型. +// 判断是否是允许上传的文件类型. func IsAllowUploadFileExt(ext string) bool { if strings.HasPrefix(ext, ".") { diff --git a/conf/lang/en-us.ini b/conf/lang/en-us.ini index 04d9da113..b5935cb65 100644 --- a/conf/lang/en-us.ini +++ b/conf/lang/en-us.ini @@ -318,6 +318,7 @@ next = next no = no edit_title = Edit Blog private_blog_tips = Private blog, please enter password to access +print_text = Enable Printing [doc] modify_doc = Modify Document @@ -501,6 +502,9 @@ edit_user = Edit User pwd_tips = Please leave it blank if you do not change the password, only local users can change the password [mgr] +language = Default Language +zh_cn = 简体中文 +en_us = English dashboard_menu = Dashboard user_menu = User team_menu = Team diff --git a/conf/lang/zh-cn.ini b/conf/lang/zh-cn.ini index 0dd2e2544..d44b2c3c7 100644 --- a/conf/lang/zh-cn.ini +++ b/conf/lang/zh-cn.ini @@ -318,6 +318,7 @@ next = 下一篇 no = 无 edit_title = 编辑文章 private_blog_tips = 加密文章,请输入密码访问 +print_text = 开启打印 [doc] modify_doc = 修改文档 @@ -501,6 +502,9 @@ edit_user = 编辑用户 pwd_tips = 不修改密码请留空,只支持本地用户修改密码 [mgr] +language = 默认语言 +zh_cn = 简体中文 +en_us = English dashboard_menu = 仪表盘 user_menu = 用户管理 team_menu = 团队管理 diff --git a/controllers/BaseController.go b/controllers/BaseController.go index 4d7d27dc3..0b8451d18 100644 --- a/controllers/BaseController.go +++ b/controllers/BaseController.go @@ -83,7 +83,7 @@ func (c *BaseController) Prepare() { c.SetLang() } -//判断用户是否登录. +// 判断用户是否登录. func (c *BaseController) isUserLoggedIn() bool { return c.Member != nil && c.Member.MemberId > 0 } @@ -127,7 +127,7 @@ func (c *BaseController) JsonResult(errCode int, errMsg string, data ...interfac c.StopRun() } -//如果错误不为空,则响应错误信息到浏览器. +// 如果错误不为空,则响应错误信息到浏览器. func (c *BaseController) CheckJsonError(code int, err error) { if err == nil { @@ -182,7 +182,7 @@ func (c *BaseController) BaseUrl() string { return baseUrl } -//显示错误信息页面. +// 显示错误信息页面. func (c *BaseController) ShowErrorPage(errCode int, errMsg string) { c.TplName = "errors/error.tpl" @@ -217,7 +217,11 @@ func (c *BaseController) SetLang() { } if len(lang) == 0 || !i18n.IsExist(lang) { - lang, _ = web.AppConfig.String("default_lang") + if c.Data["language"] != nil { + lang = c.Data["language"].(string) + } else { + lang, _ = web.AppConfig.String("default_lang") + } } if !hasCookie { c.Ctx.SetCookie("lang", lang, 1<<31-1, "/") diff --git a/controllers/BookController.go b/controllers/BookController.go index 06ec4465f..f636dd0db 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -122,6 +122,7 @@ func (c *BookController) Setting() { if book.PrivateToken != "" { book.PrivateToken = conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken) } + c.Data["Model"] = book } @@ -153,6 +154,7 @@ func (c *BookController) SaveBook() { isUseFirstDocument := strings.TrimSpace(c.GetString("is_use_first_document")) == "on" autoSave := strings.TrimSpace(c.GetString("auto_save")) == "on" itemId, _ := c.GetInt("itemId") + pringState := strings.TrimSpace(c.GetString("print_state")) == "on" if strings.Count(description, "") > 500 { c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_desc_tips")) @@ -211,6 +213,11 @@ func (c *BookController) SaveBook() { } else { book.AutoSave = 0 } + if pringState { + book.PrintSate = 1 + } else { + book.PrintSate = 0 + } if err := book.Update(); err != nil { c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed")) } @@ -456,6 +463,7 @@ func (c *BookController) Create() { description := strings.TrimSpace(c.GetString("description", "")) privatelyOwned, _ := strconv.Atoi(c.GetString("privately_owned")) commentStatus := c.GetString("comment_status") + editor := c.GetString("editor") itemId, _ := c.GetInt("itemId") if bookName == "" { @@ -522,6 +530,7 @@ func (c *BookController) Create() { book.CommentCount = 0 book.PrivatelyOwned = privatelyOwned book.CommentStatus = commentStatus + book.Identify = identify book.DocCount = 0 book.MemberId = c.Member.MemberId @@ -531,8 +540,7 @@ func (c *BookController) Create() { book.IsDownload = 1 book.AutoRelease = 0 book.ItemId = itemId - - book.Editor = "markdown" + book.Editor = editor book.Theme = "default" if err := book.Insert(c.Lang); err != nil { @@ -775,6 +783,10 @@ func (c *BookController) Release() { // 更新项目排序 func (c *BookController) UpdateBookOrder() { + if !c.Member.IsAdministrator() { + c.JsonResult(403, "权限不足") + return + } type Params struct { Ids string `form:"ids"` } diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index 087c57513..35e6f0c48 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -7,6 +7,7 @@ import ( "html/template" "image/png" "io" + "mime/multipart" "net/http" "net/url" "os" @@ -486,41 +487,23 @@ func (c *DocumentController) Upload() { c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } - name := "editormd-file-file" - - // file, moreFile, err := c.GetFile(name) - // if err == http.ErrMissingFile || moreFile == nil { - // name = "editormd-image-file" - // file, moreFile, err = c.GetFile(name) - // if err == http.ErrMissingFile || moreFile == nil { - // c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) - // return - // } - // } - // ****3xxx - files, err := c.GetFiles(name) - if err == http.ErrMissingFile { - name = "editormd-image-file" - files, err = c.GetFiles(name) - if err == http.ErrMissingFile { - // c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) - // return - name = "file" - files, err = c.GetFiles(name) - // logs.Info(files) - if err == http.ErrMissingFile { - c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) - return - } + names := []string{"editormd-file-file", "editormd-image-file", "file", "editormd-resource-file"} + var files []*multipart.FileHeader + for _, name := range names { + file, err := c.GetFiles(name) + if err != nil { + continue + } + if len(file) > 0 && err == nil { + files = append(files, file...) } } - // if err != nil { - // http.Error(w, err.Error(), http.StatusNoContent) - // return - // } - // jMap := make(map[string]interface{}) - // s := []map[int]interface{}{} + if len(files) == 0 { + c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) + return + } + result2 := []map[string]interface{}{} var result map[string]interface{} for i, _ := range files { @@ -528,24 +511,6 @@ func (c *DocumentController) Upload() { file, err := files[i].Open() defer file.Close() - // if err != nil { - // http.Error(w, err.Error(), http.StatusInternalServerError) - // return - // } - // //create destination file making sure the path is writeable. - // dst, err := os.Create("upload/" + files[i].Filename) - // defer dst.Close() - // if err != nil { - // http.Error(w, err.Error(), http.StatusInternalServerError) - // return - // } - // //copy the uploaded file to the destination file - // if _, err := io.Copy(dst, file); err != nil { - // http.Error(w, err.Error(), http.StatusInternalServerError) - // return - // } - // } - // **** if err != nil { c.JsonResult(6002, err.Error()) @@ -619,19 +584,25 @@ func (c *DocumentController) Upload() { filePath := filepath.Join(conf.WorkingDirectory, "uploads", identify) //将图片和文件分开存放 - // if filetil.IsImageExt(moreFile.Filename) { + attachment := models.NewAttachment() + var strategy filetil.FileTypeStrategy if filetil.IsImageExt(files[i].Filename) { - filePath = filepath.Join(filePath, "images", fileName+ext) + strategy = filetil.ImageStrategy{} + attachment.ResourceType = "image" + } else if filetil.IsVideoExt(files[i].Filename) { + strategy = filetil.VideoStrategy{} + attachment.ResourceType = "video" } else { - filePath = filepath.Join(filePath, "files", fileName+ext) + strategy = filetil.DefaultStrategy{} + attachment.ResourceType = "file" } + filePath = strategy.GetFilePath(filePath, fileName, ext) + path := filepath.Dir(filePath) _ = os.MkdirAll(path, os.ModePerm) - // err = c.SaveToFile(name, filePath) // frome beego controller.go: savetofile it only operates the first one of mutil-upload form file field. - //copy the uploaded file to the destination file dst, err := os.Create(filePath) defer dst.Close() @@ -640,12 +611,6 @@ func (c *DocumentController) Upload() { c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } - // if err != nil { - // logs.Error("保存文件失败 -> ", err) - // c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) - // } - - attachment := models.NewAttachment() attachment.BookId = bookId // attachment.FileName = moreFile.Filename attachment.FileName = files[i].Filename @@ -662,8 +627,7 @@ func (c *DocumentController) Upload() { attachment.DocumentId = docId } - // if filetil.IsImageExt(moreFile.Filename) { - if filetil.IsImageExt(files[i].Filename) { + if filetil.IsImageExt(files[i].Filename) || filetil.IsVideoExt(files[i].Filename) { attachment.HttpPath = "/" + strings.Replace(strings.TrimPrefix(filePath, conf.WorkingDirectory), "\\", "/", -1) if strings.HasPrefix(attachment.HttpPath, "//") { attachment.HttpPath = conf.URLForWithCdnImage(string(attachment.HttpPath[1:])) @@ -689,19 +653,20 @@ func (c *DocumentController) Upload() { } } result = map[string]interface{}{ - "errcode": 0, - "success": 1, - "message": "ok", - "url": attachment.HttpPath, - "link": attachment.HttpPath, - "alt": attachment.FileName, - "is_attach": isAttach, - "attach": attachment, + "errcode": 0, + "success": 1, + "message": "ok", + "url": attachment.HttpPath, + "link": attachment.HttpPath, + "alt": attachment.FileName, + "is_attach": isAttach, + "attach": attachment, + "resource_type": attachment.ResourceType, } result2 = append(result2, result) } - if name == "file" { - // froala单图片上传 + if len(files) == 1 { + // froala单文件上传 c.Ctx.Output.JSON(result, true, false) } else { c.Ctx.Output.JSON(result2, true, false) diff --git a/controllers/ManagerController.go b/controllers/ManagerController.go index 8a0657754..3abc43d0c 100644 --- a/controllers/ManagerController.go +++ b/controllers/ManagerController.go @@ -133,7 +133,7 @@ func (c *ManagerController) CreateMember() { c.JsonResult(0, "ok", member) } -//更新用户状态. +// 更新用户状态. func (c *ManagerController) UpdateMemberStatus() { c.Prepare() @@ -166,7 +166,7 @@ func (c *ManagerController) UpdateMemberStatus() { c.JsonResult(0, "ok", member) } -//变更用户权限. +// 变更用户权限. func (c *ManagerController) ChangeMemberRole() { c.Prepare() @@ -199,7 +199,7 @@ func (c *ManagerController) ChangeMemberRole() { c.JsonResult(0, "ok", member) } -//编辑用户信息. +// 编辑用户信息. func (c *ManagerController) EditMember() { c.Prepare() c.TplName = "manager/edit_users.tpl" @@ -251,7 +251,7 @@ func (c *ManagerController) EditMember() { c.Data["Model"] = member } -//删除一个用户,并将该用户的所有信息转移到超级管理员上. +// 删除一个用户,并将该用户的所有信息转移到超级管理员上. func (c *ManagerController) DeleteMember() { c.Prepare() member_id, _ := c.GetInt("id", 0) @@ -283,7 +283,7 @@ func (c *ManagerController) DeleteMember() { c.JsonResult(0, "ok") } -//项目列表. +// 项目列表. func (c *ManagerController) Books() { c.Prepare() c.TplName = "manager/books.tpl" @@ -313,7 +313,7 @@ func (c *ManagerController) Books() { c.Data["Lists"] = books } -//编辑项目. +// 编辑项目. func (c *ManagerController) EditBook() { c.Prepare() @@ -460,7 +460,7 @@ func (c *ManagerController) CreateToken() { } } -//项目设置. +// 项目设置. func (c *ManagerController) Setting() { c.Prepare() c.TplName = "manager/setting.tpl" @@ -541,7 +541,7 @@ func (c *ManagerController) Comments() { } -//DeleteComment 标记评论为已删除 +// DeleteComment 标记评论为已删除 func (c *ManagerController) DeleteComment() { c.Prepare() @@ -565,7 +565,7 @@ func (c *ManagerController) DeleteComment() { c.JsonResult(0, "ok", comment) } -//设置项目私有状态. +// 设置项目私有状态. func (c *ManagerController) PrivatelyOwned() { c.Prepare() status := c.GetString("status") @@ -603,7 +603,7 @@ func (c *ManagerController) PrivatelyOwned() { c.JsonResult(0, "ok") } -//附件列表. +// 附件列表. func (c *ManagerController) AttachList() { c.Prepare() c.TplName = "manager/attach_list.tpl" @@ -634,7 +634,7 @@ func (c *ManagerController) AttachList() { c.Data["Lists"] = attachList } -//附件清理. +// 附件清理. func (c *ManagerController) AttachClean() { c.Prepare() @@ -669,7 +669,7 @@ func (c *ManagerController) AttachClean() { c.JsonResult(0, "ok") } -//附件详情. +// 附件详情. func (c *ManagerController) AttachDetailed() { c.Prepare() c.TplName = "manager/attach_detailed.tpl" @@ -698,7 +698,7 @@ func (c *ManagerController) AttachDetailed() { c.Data["Model"] = attach } -//删除附件. +// 删除附件. func (c *ManagerController) AttachDelete() { c.Prepare() attachId, _ := c.GetInt("attach_id") @@ -721,7 +721,7 @@ func (c *ManagerController) AttachDelete() { c.JsonResult(0, "ok") } -//标签列表 +// 标签列表 func (c *ManagerController) LabelList() { c.Prepare() c.TplName = "manager/label_list.tpl" @@ -743,7 +743,7 @@ func (c *ManagerController) LabelList() { c.Data["Lists"] = labels } -//删除标签 +// 删除标签 func (c *ManagerController) LabelDelete() { labelId, err := strconv.Atoi(c.Ctx.Input.Param(":id")) if err != nil { @@ -936,7 +936,7 @@ func (c *ManagerController) TeamMemberList() { } } -//搜索团队用户. +// 搜索团队用户. func (c *ManagerController) TeamSearchMember() { c.Prepare() @@ -1015,7 +1015,7 @@ func (c *ManagerController) TeamChangeMemberRole() { } -//团队项目列表. +// 团队项目列表. func (c *ManagerController) TeamBookList() { c.Prepare() c.TplName = "manager/team_book_list.tpl" @@ -1062,7 +1062,7 @@ func (c *ManagerController) TeamBookList() { } } -//给团队增加项目. +// 给团队增加项目. func (c *ManagerController) TeamBookAdd() { c.Prepare() @@ -1086,7 +1086,7 @@ func (c *ManagerController) TeamBookAdd() { } } -//搜索未参与的项目. +// 搜索未参与的项目. func (c *ManagerController) TeamSearchBook() { c.Prepare() @@ -1106,7 +1106,7 @@ func (c *ManagerController) TeamSearchBook() { } -//删除团队项目. +// 删除团队项目. func (c *ManagerController) TeamBookDelete() { c.Prepare() teamRelationshipId, _ := c.GetInt("teamRelId") @@ -1123,7 +1123,7 @@ func (c *ManagerController) TeamBookDelete() { c.JsonResult(0, "OK") } -//项目空间列表. +// 项目空间列表. func (c *ManagerController) Itemsets() { c.Prepare() c.TplName = "manager/itemsets.tpl" @@ -1151,7 +1151,7 @@ func (c *ManagerController) Itemsets() { c.Data["Lists"] = items } -//编辑或添加项目空间. +// 编辑或添加项目空间. func (c *ManagerController) ItemsetsEdit() { c.Prepare() itemId, _ := c.GetInt("itemId") @@ -1186,7 +1186,7 @@ func (c *ManagerController) ItemsetsEdit() { c.JsonResult(0, "OK") } -//删除项目空间. +// 删除项目空间. func (c *ManagerController) ItemsetsDelete() { c.Prepare() itemId, _ := c.GetInt("itemId") diff --git a/models/AttachmentModel.go b/models/AttachmentModel.go index 0d382159e..4c84d7e95 100644 --- a/models/AttachmentModel.go +++ b/models/AttachmentModel.go @@ -33,6 +33,7 @@ type Attachment struct { FileExt string `orm:"column(file_ext);size(50);description(文件后缀)" json:"file_ext"` CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add;description(创建时间)" json:"create_time"` CreateAt int `orm:"column(create_at);type(int);description(创建人id)" json:"create_at"` + ResourceType string `orm:"-" json:"resource_type"` } // TableName 获取对应上传附件数据库表名. diff --git a/models/BookModel.go b/models/BookModel.go index d46d2ff5c..cfe7cfbc6 100644 --- a/models/BookModel.go +++ b/models/BookModel.go @@ -82,7 +82,8 @@ type Book struct { //是否使用第一篇文章项目为默认首页,0 否/1 是 IsUseFirstDocument int `orm:"column(is_use_first_document);type(int);default(0);description(是否使用第一篇文章项目为默认首页,0 否/1 是)" json:"is_use_first_document"` //是否开启自动保存:0 否/1 是 - AutoSave int `orm:"column(auto_save);type(tinyint);default(0);description(是否开启自动保存:0 否/1 是)" json:"auto_save"` + AutoSave int `orm:"column(auto_save);type(tinyint);default(0);description(是否开启自动保存:0 否/1 是)" json:"auto_save"` + PrintSate int `orm:"column(print_state);type(tinyint);default(1);description(启用打印:0 否/1 是)" json:"print_state"` } func (book *Book) String() string { diff --git a/models/BookResult.go b/models/BookResult.go index 0ea535bcb..de2ada581 100644 --- a/models/BookResult.go +++ b/models/BookResult.go @@ -71,6 +71,7 @@ type BookResult struct { IsDisplayComment bool `json:"is_display_comment"` IsDownload bool `json:"is_download"` AutoSave bool `json:"auto_save"` + PrintState bool `json:"print_state"` Lang string } @@ -213,6 +214,7 @@ func (m *BookResult) ToBookResult(book Book) *BookResult { m.HistoryCount = book.HistoryCount m.IsDownload = book.IsDownload == 0 m.AutoSave = book.AutoSave == 1 + m.PrintState = book.PrintSate == 1 m.ItemId = book.ItemId m.RoleId = conf.BookRoleNoSpecific diff --git a/models/DocumentTree.go b/models/DocumentTree.go index 11020dd75..504038d50 100644 --- a/models/DocumentTree.go +++ b/models/DocumentTree.go @@ -173,7 +173,7 @@ func getSelectedNode(array []*DocumentTree, parent_id int) int { } func getDocumentTree(array []*DocumentTree, parentId int, selectedId int, selectedParentId int, buf *bytes.Buffer) { - buf.WriteString("