|
@@ -1,6 +1,7 @@
|
|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
+ "context"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"html/template"
|
|
@@ -14,9 +15,9 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
- "github.com/astaxie/beego"
|
|
|
"github.com/astaxie/beego/logs"
|
|
|
- "github.com/astaxie/beego/orm"
|
|
|
+ "github.com/beego/beego/v2/adapter"
|
|
|
+ "github.com/beego/beego/v2/adapter/orm"
|
|
|
"github.com/boombuler/barcode"
|
|
|
"github.com/boombuler/barcode/qr"
|
|
|
"github.com/mindoc-org/mindoc/conf"
|
|
@@ -77,7 +78,7 @@ func (c *DocumentController) Index() {
|
|
|
if err == orm.ErrNoRows {
|
|
|
c.ShowErrorPage(404, "当前项目没有文档")
|
|
|
} else {
|
|
|
- beego.Error("生成项目文档树时出错 -> ", err)
|
|
|
+ logs.Error("生成项目文档树时出错 -> ", err)
|
|
|
c.ShowErrorPage(500, "生成项目文档树时出错")
|
|
|
}
|
|
|
}
|
|
@@ -115,7 +116,7 @@ func (c *DocumentController) Read() {
|
|
|
if docId, err := strconv.Atoi(id); err == nil {
|
|
|
doc, err = doc.FromCacheById(docId)
|
|
|
if err != nil || doc == nil {
|
|
|
- beego.Error("从缓存中读取文档时失败 ->", err)
|
|
|
+ logs.Error("从缓存中读取文档时失败 ->", err)
|
|
|
c.ShowErrorPage(404, "文档不存在或已删除")
|
|
|
return
|
|
|
}
|
|
@@ -125,7 +126,7 @@ func (c *DocumentController) Read() {
|
|
|
if err == orm.ErrNoRows {
|
|
|
c.ShowErrorPage(404, "文档不存在或已删除")
|
|
|
} else {
|
|
|
- beego.Error("从缓存查询文档时出错 ->", err)
|
|
|
+ logs.Error("从缓存查询文档时出错 ->", err)
|
|
|
c.ShowErrorPage(500, "未知异常")
|
|
|
}
|
|
|
return
|
|
@@ -161,7 +162,7 @@ func (c *DocumentController) Read() {
|
|
|
tree, err := models.NewDocument().CreateDocumentTreeForHtml(bookResult.BookId, doc.DocumentId)
|
|
|
|
|
|
if err != nil && err != orm.ErrNoRows {
|
|
|
- beego.Error("生成项目文档树时出错 ->", err)
|
|
|
+ logs.Error("生成项目文档树时出错 ->", err)
|
|
|
|
|
|
c.ShowErrorPage(500, "生成项目文档树时出错")
|
|
|
}
|
|
@@ -201,7 +202,7 @@ func (c *DocumentController) Edit() {
|
|
|
if err == orm.ErrNoRows || err == models.ErrPermissionDenied {
|
|
|
c.ShowErrorPage(403, "项目不存在或没有权限")
|
|
|
} else {
|
|
|
- beego.Error("查询项目时出错 -> ", err)
|
|
|
+ logs.Error("查询项目时出错 -> ", err)
|
|
|
c.ShowErrorPage(500, "查询项目时出错")
|
|
|
}
|
|
|
return
|
|
@@ -231,7 +232,7 @@ func (c *DocumentController) Edit() {
|
|
|
trees, err := models.NewDocument().FindDocumentTree(bookResult.BookId)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error("FindDocumentTree => ", err)
|
|
|
+ logs.Error("FindDocumentTree => ", err)
|
|
|
} else {
|
|
|
if len(trees) > 0 {
|
|
|
if jtree, err := json.Marshal(trees); err == nil {
|
|
@@ -242,12 +243,12 @@ func (c *DocumentController) Edit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- c.Data["BaiDuMapKey"] = beego.AppConfig.DefaultString("baidumapkey", "")
|
|
|
+ c.Data["BaiDuMapKey"] = adapter.AppConfig.DefaultString("baidumapkey", "")
|
|
|
|
|
|
if conf.GetUploadFileSize() > 0 {
|
|
|
c.Data["UploadFileSize"] = conf.GetUploadFileSize()
|
|
|
} else {
|
|
|
- c.Data["UploadFileSize"] = "undefined";
|
|
|
+ c.Data["UploadFileSize"] = "undefined"
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -274,7 +275,7 @@ func (c *DocumentController) Create() {
|
|
|
if c.Member.IsAdministrator() {
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -283,7 +284,7 @@ func (c *DocumentController) Create() {
|
|
|
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
|
|
|
if err != nil || bookResult.RoleId == conf.BookObserver {
|
|
|
- beego.Error("FindByIdentify => ", err)
|
|
|
+ logs.Error("FindByIdentify => ", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -327,7 +328,7 @@ func (c *DocumentController) Create() {
|
|
|
}
|
|
|
|
|
|
if err := document.InsertOrUpdate(); err != nil {
|
|
|
- beego.Error("添加或更新文档时出错 -> ", err)
|
|
|
+ logs.Error("添加或更新文档时出错 -> ", err)
|
|
|
c.JsonResult(6005, "保存失败")
|
|
|
} else {
|
|
|
c.JsonResult(0, "ok", document)
|
|
@@ -395,7 +396,7 @@ func (c *DocumentController) Upload() {
|
|
|
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error("DocumentController.Edit => ", err)
|
|
|
+ logs.Error("DocumentController.Edit => ", err)
|
|
|
if err == orm.ErrNoRows {
|
|
|
c.JsonResult(6006, "权限不足")
|
|
|
}
|
|
@@ -439,7 +440,7 @@ func (c *DocumentController) Upload() {
|
|
|
err = c.SaveToFile(name, filePath)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error("保存文件失败 -> ", err)
|
|
|
+ logs.Error("保存文件失败 -> ", err)
|
|
|
c.JsonResult(6005, "保存文件失败")
|
|
|
}
|
|
|
|
|
@@ -472,7 +473,7 @@ func (c *DocumentController) Upload() {
|
|
|
|
|
|
if err != nil {
|
|
|
os.Remove(filePath)
|
|
|
- beego.Error("文件保存失败 ->", err)
|
|
|
+ logs.Error("文件保存失败 ->", err)
|
|
|
c.JsonResult(6006, "文件保存失败")
|
|
|
}
|
|
|
|
|
@@ -480,7 +481,7 @@ func (c *DocumentController) Upload() {
|
|
|
attachment.HttpPath = conf.URLForNotHost("DocumentController.DownloadAttachment", ":key", identify, ":attach_id", attachment.AttachmentId)
|
|
|
|
|
|
if err := attachment.Update(); err != nil {
|
|
|
- beego.Error("保存文件失败 ->", err)
|
|
|
+ logs.Error("保存文件失败 ->", err)
|
|
|
c.JsonResult(6005, "保存文件失败")
|
|
|
}
|
|
|
}
|
|
@@ -525,7 +526,7 @@ func (c *DocumentController) DownloadAttachment() {
|
|
|
if err == orm.ErrNoRows {
|
|
|
c.ShowErrorPage(404, "项目不存在或已删除")
|
|
|
} else {
|
|
|
- beego.Error("查找项目时出错 ->", err)
|
|
|
+ logs.Error("查找项目时出错 ->", err)
|
|
|
c.ShowErrorPage(500, "系统错误")
|
|
|
}
|
|
|
}
|
|
@@ -547,7 +548,7 @@ func (c *DocumentController) DownloadAttachment() {
|
|
|
attachment, err := models.NewAttachment().Find(attachId)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error("查找附件时出错 -> ", err)
|
|
|
+ logs.Error("查找附件时出错 -> ", err)
|
|
|
if err == orm.ErrNoRows {
|
|
|
c.ShowErrorPage(404, "附件不存在或已删除")
|
|
|
} else {
|
|
@@ -575,21 +576,21 @@ func (c *DocumentController) RemoveAttachment() {
|
|
|
attach, err := models.NewAttachment().Find(attachId)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6002, "附件不存在")
|
|
|
}
|
|
|
|
|
|
document, err := models.NewDocument().Find(attach.DocumentId)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6003, "文档不存在")
|
|
|
}
|
|
|
|
|
|
if c.Member.Role != conf.MemberSuperRole {
|
|
|
rel, err := models.NewRelationship().FindByBookIdAndMemberId(document.BookId, c.Member.MemberId)
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6004, "权限不足")
|
|
|
}
|
|
|
|
|
@@ -600,7 +601,7 @@ func (c *DocumentController) RemoveAttachment() {
|
|
|
|
|
|
err = attach.Delete()
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6005, "删除失败")
|
|
|
}
|
|
|
|
|
@@ -622,7 +623,7 @@ func (c *DocumentController) Delete() {
|
|
|
if c.Member.IsAdministrator() {
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
if err != nil {
|
|
|
- beego.Error("FindByIdentify => ", err)
|
|
|
+ logs.Error("FindByIdentify => ", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -631,7 +632,7 @@ func (c *DocumentController) Delete() {
|
|
|
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
|
|
|
if err != nil || bookResult.RoleId == conf.BookObserver {
|
|
|
- beego.Error("FindByIdentify => ", err)
|
|
|
+ logs.Error("FindByIdentify => ", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -645,7 +646,7 @@ func (c *DocumentController) Delete() {
|
|
|
doc, err := models.NewDocument().Find(docId)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error("Delete => ", err)
|
|
|
+ logs.Error("Delete => ", err)
|
|
|
c.JsonResult(6003, "删除失败")
|
|
|
}
|
|
|
// 如果文档所属项目错误
|
|
@@ -692,7 +693,7 @@ func (c *DocumentController) Content() {
|
|
|
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
|
|
|
if err != nil || bookResult.RoleId == conf.BookObserver {
|
|
|
- beego.Error("项目不存在或权限不足 -> ", err)
|
|
|
+ logs.Error("项目不存在或权限不足 -> ", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -722,7 +723,7 @@ func (c *DocumentController) Content() {
|
|
|
}
|
|
|
|
|
|
if doc.Version != version && !strings.EqualFold(isCover, "yes") {
|
|
|
- beego.Info("%d|", version, doc.Version)
|
|
|
+ logs.Info("%d|", version, doc.Version)
|
|
|
c.JsonResult(6005, "文档已被修改确定要覆盖吗?")
|
|
|
}
|
|
|
|
|
@@ -749,7 +750,7 @@ func (c *DocumentController) Content() {
|
|
|
doc.ModifyAt = c.Member.MemberId
|
|
|
|
|
|
if err := doc.InsertOrUpdate(); err != nil {
|
|
|
- beego.Error("InsertOrUpdate => ", err)
|
|
|
+ logs.Error("InsertOrUpdate => ", err)
|
|
|
c.JsonResult(6006, "保存失败")
|
|
|
}
|
|
|
|
|
@@ -759,7 +760,7 @@ func (c *DocumentController) Content() {
|
|
|
if c.EnableDocumentHistory && cryptil.Md5Crypt(history.Markdown) != cryptil.Md5Crypt(doc.Markdown) {
|
|
|
_, err = history.InsertOrUpdate()
|
|
|
if err != nil {
|
|
|
- beego.Error("DocumentHistory InsertOrUpdate => ", err)
|
|
|
+ logs.Error("DocumentHistory InsertOrUpdate => ", err)
|
|
|
}
|
|
|
}
|
|
|
}(history)
|
|
@@ -819,7 +820,7 @@ func (c *DocumentController) Export() {
|
|
|
if err == orm.ErrNoRows {
|
|
|
c.ShowErrorPage(404, "项目不存在")
|
|
|
} else {
|
|
|
- beego.Error("查找项目时出错 ->", err)
|
|
|
+ logs.Error("查找项目时出错 ->", err)
|
|
|
c.ShowErrorPage(500, "查找项目时出错")
|
|
|
}
|
|
|
}
|
|
@@ -839,7 +840,7 @@ func (c *DocumentController) Export() {
|
|
|
if bookResult.Editor != "markdown" {
|
|
|
c.ShowErrorPage(500, "当前项目不支持Markdown编辑器")
|
|
|
}
|
|
|
- p, err := bookResult.ExportMarkdown(c.CruSession.SessionID())
|
|
|
+ p, err := bookResult.ExportMarkdown(c.CruSession.SessionID(context.TODO()))
|
|
|
|
|
|
if err != nil {
|
|
|
c.ShowErrorPage(500, "导出文档失败")
|
|
@@ -874,7 +875,7 @@ func (c *DocumentController) Export() {
|
|
|
c.Abort("200")
|
|
|
|
|
|
} else if output == "pdf" || output == "epub" || output == "docx" || output == "mobi" {
|
|
|
- if err := models.BackgroundConvert(c.CruSession.SessionID(), bookResult); err != nil && err != gopool.ErrHandlerIsExist {
|
|
|
+ if err := models.BackgroundConvert(c.CruSession.SessionID(context.TODO()), bookResult); err != nil && err != gopool.ErrHandlerIsExist {
|
|
|
c.ShowErrorPage(500, "导出失败,请查看系统日志")
|
|
|
}
|
|
|
|
|
@@ -900,13 +901,13 @@ func (c *DocumentController) QrCode() {
|
|
|
uri := conf.URLFor("DocumentController.Index", ":key", identify)
|
|
|
code, err := qr.Encode(uri, qr.L, qr.Unicode)
|
|
|
if err != nil {
|
|
|
- beego.Error("生成二维码失败 ->", err)
|
|
|
+ logs.Error("生成二维码失败 ->", err)
|
|
|
c.ShowErrorPage(500, "生成二维码失败")
|
|
|
}
|
|
|
|
|
|
code, err = barcode.Scale(code, 150, 150)
|
|
|
if err != nil {
|
|
|
- beego.Error("生成二维码失败 ->", err)
|
|
|
+ logs.Error("生成二维码失败 ->", err)
|
|
|
c.ShowErrorPage(500, "生成二维码失败")
|
|
|
}
|
|
|
|
|
@@ -916,7 +917,7 @@ func (c *DocumentController) QrCode() {
|
|
|
|
|
|
err = png.Encode(c.Ctx.ResponseWriter, code)
|
|
|
if err != nil {
|
|
|
- beego.Error("生成二维码失败 ->", err)
|
|
|
+ logs.Error("生成二维码失败 ->", err)
|
|
|
c.ShowErrorPage(500, "生成二维码失败")
|
|
|
}
|
|
|
}
|
|
@@ -942,7 +943,7 @@ func (c *DocumentController) Search() {
|
|
|
|
|
|
docs, err := models.NewDocumentSearchResult().SearchDocument(keyword, bookResult.BookId)
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6002, "搜索结果错误")
|
|
|
}
|
|
|
|
|
@@ -976,7 +977,7 @@ func (c *DocumentController) History() {
|
|
|
if c.Member.IsAdministrator() {
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
if err != nil {
|
|
|
- beego.Error("查找项目失败 ->", err)
|
|
|
+ logs.Error("查找项目失败 ->", err)
|
|
|
c.Data["ErrorMessage"] = "项目不存在或权限不足"
|
|
|
return
|
|
|
}
|
|
@@ -986,7 +987,7 @@ func (c *DocumentController) History() {
|
|
|
} else {
|
|
|
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
if err != nil || bookResult.RoleId == conf.BookObserver {
|
|
|
- beego.Error("查找项目失败 ->", err)
|
|
|
+ logs.Error("查找项目失败 ->", err)
|
|
|
c.Data["ErrorMessage"] = "项目不存在或权限不足"
|
|
|
return
|
|
|
}
|
|
@@ -1002,7 +1003,7 @@ func (c *DocumentController) History() {
|
|
|
|
|
|
doc, err := models.NewDocument().Find(docId)
|
|
|
if err != nil {
|
|
|
- beego.Error("Delete => ", err)
|
|
|
+ logs.Error("Delete => ", err)
|
|
|
c.Data["ErrorMessage"] = "获取历史失败"
|
|
|
return
|
|
|
}
|
|
@@ -1015,7 +1016,7 @@ func (c *DocumentController) History() {
|
|
|
|
|
|
histories, totalCount, err := models.NewDocumentHistory().FindToPager(docId, pageIndex, conf.PageSize)
|
|
|
if err != nil {
|
|
|
- beego.Error("分页查找文档历史失败 ->", err)
|
|
|
+ logs.Error("分页查找文档历史失败 ->", err)
|
|
|
c.Data["ErrorMessage"] = "获取历史失败"
|
|
|
return
|
|
|
}
|
|
@@ -1049,7 +1050,7 @@ func (c *DocumentController) DeleteHistory() {
|
|
|
if c.Member.IsAdministrator() {
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
if err != nil {
|
|
|
- beego.Error("查找项目失败 ->", err)
|
|
|
+ logs.Error("查找项目失败 ->", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -1057,7 +1058,7 @@ func (c *DocumentController) DeleteHistory() {
|
|
|
} else {
|
|
|
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
if err != nil || bookResult.RoleId == conf.BookObserver {
|
|
|
- beego.Error("查找项目失败 ->", err)
|
|
|
+ logs.Error("查找项目失败 ->", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -1070,7 +1071,7 @@ func (c *DocumentController) DeleteHistory() {
|
|
|
|
|
|
doc, err := models.NewDocument().Find(docId)
|
|
|
if err != nil {
|
|
|
- beego.Error("Delete => ", err)
|
|
|
+ logs.Error("Delete => ", err)
|
|
|
c.JsonResult(6001, "获取历史失败")
|
|
|
}
|
|
|
|
|
@@ -1081,7 +1082,7 @@ func (c *DocumentController) DeleteHistory() {
|
|
|
|
|
|
err = models.NewDocumentHistory().Delete(historyId, docId)
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6002, "删除失败")
|
|
|
}
|
|
|
|
|
@@ -1107,7 +1108,7 @@ func (c *DocumentController) RestoreHistory() {
|
|
|
if c.Member.IsAdministrator() {
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
if err != nil {
|
|
|
- beego.Error("FindByIdentify => ", err)
|
|
|
+ logs.Error("FindByIdentify => ", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -1115,7 +1116,7 @@ func (c *DocumentController) RestoreHistory() {
|
|
|
} else {
|
|
|
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
if err != nil || bookResult.RoleId == conf.BookObserver {
|
|
|
- beego.Error("FindByIdentify => ", err)
|
|
|
+ logs.Error("FindByIdentify => ", err)
|
|
|
c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
}
|
|
|
|
|
@@ -1128,7 +1129,7 @@ func (c *DocumentController) RestoreHistory() {
|
|
|
|
|
|
doc, err := models.NewDocument().Find(docId)
|
|
|
if err != nil {
|
|
|
- beego.Error("Delete => ", err)
|
|
|
+ logs.Error("Delete => ", err)
|
|
|
c.JsonResult(6001, "获取历史失败")
|
|
|
}
|
|
|
|
|
@@ -1139,7 +1140,7 @@ func (c *DocumentController) RestoreHistory() {
|
|
|
|
|
|
err = models.NewDocumentHistory().Restore(historyId, docId, c.Member.MemberId)
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.JsonResult(6002, "删除失败")
|
|
|
}
|
|
|
|
|
@@ -1161,7 +1162,7 @@ func (c *DocumentController) Compare() {
|
|
|
if c.Member.IsAdministrator() {
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
if err != nil {
|
|
|
- beego.Error("DocumentController.Compare => ", err)
|
|
|
+ logs.Error("DocumentController.Compare => ", err)
|
|
|
c.ShowErrorPage(403, "权限不足")
|
|
|
return
|
|
|
}
|
|
@@ -1172,7 +1173,7 @@ func (c *DocumentController) Compare() {
|
|
|
} else {
|
|
|
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
if err != nil || bookResult.RoleId == conf.BookObserver {
|
|
|
- beego.Error("FindByIdentify => ", err)
|
|
|
+ logs.Error("FindByIdentify => ", err)
|
|
|
c.ShowErrorPage(403, "权限不足")
|
|
|
return
|
|
|
}
|
|
@@ -1188,7 +1189,7 @@ func (c *DocumentController) Compare() {
|
|
|
|
|
|
history, err := models.NewDocumentHistory().Find(historyId)
|
|
|
if err != nil {
|
|
|
- beego.Error("DocumentController.Compare => ", err)
|
|
|
+ logs.Error("DocumentController.Compare => ", err)
|
|
|
c.ShowErrorPage(60003, err.Error())
|
|
|
}
|
|
|
|
|
@@ -1215,7 +1216,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
|
|
|
if err != nil {
|
|
|
- beego.Error(err)
|
|
|
+ logs.Error(err)
|
|
|
c.ShowErrorPage(500, "项目不存在")
|
|
|
}
|
|
|
bookResult := models.NewBookResult().ToBookResult(*book)
|
|
@@ -1240,7 +1241,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|
|
if token != "" && strings.EqualFold(token, book.PrivateToken) {
|
|
|
c.SetSession(identify, token)
|
|
|
} else if token, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(token, book.PrivateToken) {
|
|
|
- beego.Info("尝试访问文档但权限不足 ->", identify, token)
|
|
|
+ logs.Info("尝试访问文档但权限不足 ->", identify, token)
|
|
|
c.ShowErrorPage(403, "权限不足")
|
|
|
}
|
|
|
} else if password := c.GetString("bPassword", ""); !isOk && book.BookPassword != "" && password != "" {
|
|
@@ -1258,14 +1259,14 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|
|
if book.BookPassword != "" {
|
|
|
//判断已存在的密码是否正确
|
|
|
if password, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(password, book.BookPassword) {
|
|
|
- body, err := c.ExecuteViewPathTemplate("document/document_password.tpl", map[string]string{"Identify": book.Identify});
|
|
|
+ body, err := c.ExecuteViewPathTemplate("document/document_password.tpl", map[string]string{"Identify": book.Identify})
|
|
|
if err != nil {
|
|
|
- beego.Error("显示密码页面失败 ->", err)
|
|
|
+ logs.Error("显示密码页面失败 ->", err)
|
|
|
}
|
|
|
c.CustomAbort(200, body)
|
|
|
}
|
|
|
} else {
|
|
|
- beego.Info("尝试访问文档但权限不足 ->", identify, token)
|
|
|
+ logs.Info("尝试访问文档但权限不足 ->", identify, token)
|
|
|
c.ShowErrorPage(403, "权限不足")
|
|
|
}
|
|
|
}
|
|
@@ -1276,8 +1277,8 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|
|
}
|
|
|
|
|
|
func promptUserToLogIn(c *DocumentController) {
|
|
|
- beego.Info("Access " + c.Ctx.Request.URL.RequestURI() + " not permitted.")
|
|
|
- beego.Info(" Access will be redirected to login page(SessionId: " + c.CruSession.SessionID() + ").")
|
|
|
+ logs.Info("Access " + c.Ctx.Request.URL.RequestURI() + " not permitted.")
|
|
|
+ logs.Info(" Access will be redirected to login page(SessionId: " + c.CruSession.SessionID(context.TODO()) + ").")
|
|
|
|
|
|
if c.IsAjax() {
|
|
|
c.JsonResult(6000, "请重新登录。")
|