mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-12-20 04:00:05 +08:00
chore: clean import errors for beego update
This commit is contained in:
@@ -13,8 +13,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/adapter/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
@@ -50,12 +51,12 @@ func (c *BlogController) Index() {
|
||||
}
|
||||
|
||||
if c.Ctx.Input.IsPost() {
|
||||
password := c.GetString("password");
|
||||
password := c.GetString("password")
|
||||
if blog.BlogStatus == "password" && password != blog.Password {
|
||||
c.JsonResult(6001, "文章密码不正确")
|
||||
} else if blog.BlogStatus == "password" && password == blog.Password {
|
||||
//如果密码输入正确,则存入session中
|
||||
_ = c.CruSession.Set( context.TODO(),blogReadSession, blogId)
|
||||
_ = c.CruSession.Set(context.TODO(), blogReadSession, blogId)
|
||||
c.JsonResult(0, "OK")
|
||||
}
|
||||
c.JsonResult(0, "OK")
|
||||
@@ -251,7 +252,7 @@ func (c *BlogController) ManageSetting() {
|
||||
blog.Password = blogPassword
|
||||
|
||||
if err := blog.Save(); err != nil {
|
||||
beego.Error("保存文章失败 -> ", err)
|
||||
logs.Error("保存文章失败 -> ", err)
|
||||
c.JsonResult(6011, "保存文章失败")
|
||||
} else {
|
||||
c.JsonResult(0, "ok", blog)
|
||||
@@ -264,7 +265,7 @@ func (c *BlogController) ManageSetting() {
|
||||
}
|
||||
blogId, err := strconv.Atoi(c.Ctx.Input.Param(":id"))
|
||||
|
||||
c.Data["DocumentIdentify"] = "";
|
||||
c.Data["DocumentIdentify"] = ""
|
||||
if err == nil {
|
||||
blog, err := models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId)
|
||||
if err != nil {
|
||||
@@ -302,7 +303,7 @@ func (c *BlogController) ManageEdit() {
|
||||
blog, err = models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId)
|
||||
}
|
||||
if err != nil {
|
||||
beego.Error("查询文章失败 ->", err)
|
||||
logs.Error("查询文章失败 ->", err)
|
||||
c.JsonResult(6002, "查询文章失败")
|
||||
}
|
||||
if version > 0 && blog.Version != version && cover != "yes" {
|
||||
@@ -312,7 +313,7 @@ func (c *BlogController) ManageEdit() {
|
||||
if blog.BlogType == 1 {
|
||||
doc, err := models.NewDocument().Find(blog.DocumentId)
|
||||
if err != nil {
|
||||
beego.Error("查询关联项目文档时出错 ->", err)
|
||||
logs.Error("查询关联项目文档时出错 ->", err)
|
||||
c.JsonResult(6003, "查询关联项目文档时出错")
|
||||
}
|
||||
book, err := models.NewBook().Find(doc.BookId)
|
||||
@@ -325,7 +326,7 @@ func (c *BlogController) ManageEdit() {
|
||||
bookResult, err := models.NewBookResult().FindByIdentify(book.Identify, c.Member.MemberId)
|
||||
|
||||
if err != nil || bookResult.RoleId == conf.BookObserver {
|
||||
beego.Error("FindByIdentify => ", err)
|
||||
logs.Error("FindByIdentify => ", err)
|
||||
c.JsonResult(6002, "关联文档不存在或权限不足")
|
||||
}
|
||||
}
|
||||
@@ -336,7 +337,7 @@ func (c *BlogController) ManageEdit() {
|
||||
doc.ModifyTime = time.Now()
|
||||
doc.ModifyAt = c.Member.MemberId
|
||||
if err := doc.InsertOrUpdate("markdown", "release", "content", "modify_time", "modify_at"); err != nil {
|
||||
beego.Error("保存关联文档时出错 ->", err)
|
||||
logs.Error("保存关联文档时出错 ->", err)
|
||||
c.JsonResult(6004, "保存关联文档时出错")
|
||||
}
|
||||
}
|
||||
@@ -347,7 +348,7 @@ func (c *BlogController) ManageEdit() {
|
||||
blog.Modified = time.Now()
|
||||
|
||||
if err := blog.Save("blog_content", "blog_release", "modify_at", "modify_time", "version"); err != nil {
|
||||
beego.Error("保存文章失败 -> ", err)
|
||||
logs.Error("保存文章失败 -> ", err)
|
||||
c.JsonResult(6011, "保存文章失败")
|
||||
} else {
|
||||
c.JsonResult(0, "ok", blog)
|
||||
@@ -375,7 +376,7 @@ func (c *BlogController) ManageEdit() {
|
||||
if len(blog.AttachList) > 0 {
|
||||
returnJSON, err := json.Marshal(blog.AttachList)
|
||||
if err != nil {
|
||||
beego.Error("序列化文章附件时出错 ->", err)
|
||||
logs.Error("序列化文章附件时出错 ->", err)
|
||||
} else {
|
||||
c.Data["AttachList"] = template.JS(string(returnJSON))
|
||||
}
|
||||
@@ -385,7 +386,7 @@ func (c *BlogController) ManageEdit() {
|
||||
if conf.GetUploadFileSize() > 0 {
|
||||
c.Data["UploadFileSize"] = conf.GetUploadFileSize()
|
||||
} else {
|
||||
c.Data["UploadFileSize"] = "undefined";
|
||||
c.Data["UploadFileSize"] = "undefined"
|
||||
}
|
||||
c.Data["Model"] = blog
|
||||
}
|
||||
@@ -467,7 +468,7 @@ func (c *BlogController) Upload() {
|
||||
c.JsonResult(6003, "无法解析文件的格式")
|
||||
}
|
||||
//如果文件类型设置为 * 标识不限制文件类型
|
||||
if beego.AppConfig.DefaultString("upload_file_ext", "") != "*" {
|
||||
if web.AppConfig.DefaultString("upload_file_ext", "") != "*" {
|
||||
if !conf.IsAllowUploadFileExt(ext) {
|
||||
c.JsonResult(6004, "不允许的文件类型")
|
||||
}
|
||||
@@ -485,7 +486,7 @@ func (c *BlogController) Upload() {
|
||||
_, err := models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("查询文章时出错 -> ", err)
|
||||
logs.Error("查询文章时出错 -> ", err)
|
||||
if err == orm.ErrNoRows {
|
||||
c.JsonResult(6006, "权限不足")
|
||||
}
|
||||
@@ -505,7 +506,7 @@ func (c *BlogController) Upload() {
|
||||
err = c.SaveToFile(name, filePath)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("SaveToFile => ", err)
|
||||
logs.Error("SaveToFile => ", err)
|
||||
c.JsonResult(6005, "保存文件失败")
|
||||
}
|
||||
|
||||
@@ -538,14 +539,14 @@ func (c *BlogController) Upload() {
|
||||
|
||||
if err := attachment.Insert(); err != nil {
|
||||
os.Remove(filePath)
|
||||
beego.Error("保存文件附件失败 -> ", err)
|
||||
logs.Error("保存文件附件失败 -> ", err)
|
||||
c.JsonResult(6006, "文件保存失败")
|
||||
}
|
||||
if attachment.HttpPath == "" {
|
||||
attachment.HttpPath = conf.URLForNotHost("BlogController.Download", ":id", blogId, ":attach_id", attachment.AttachmentId)
|
||||
|
||||
if err := attachment.Update(); err != nil {
|
||||
beego.Error("保存文件失败 -> ",attachment.FilePath, err)
|
||||
logs.Error("保存文件失败 -> ", attachment.FilePath, err)
|
||||
c.JsonResult(6005, "保存文件失败")
|
||||
}
|
||||
}
|
||||
@@ -582,7 +583,7 @@ func (c *BlogController) RemoveAttachment() {
|
||||
attach, err := models.NewAttachment().Find(attachId)
|
||||
|
||||
if err != nil {
|
||||
beego.Error(err)
|
||||
logs.Error(err)
|
||||
c.JsonResult(6002, "附件不存在")
|
||||
}
|
||||
|
||||
@@ -590,7 +591,7 @@ func (c *BlogController) RemoveAttachment() {
|
||||
_, err := models.NewBlog().FindByIdAndMemberId(attach.DocumentId, c.Member.MemberId)
|
||||
|
||||
if err != nil {
|
||||
beego.Error(err)
|
||||
logs.Error(err)
|
||||
c.JsonResult(6003, "文档不存在")
|
||||
}
|
||||
}
|
||||
@@ -602,7 +603,7 @@ func (c *BlogController) RemoveAttachment() {
|
||||
}
|
||||
|
||||
if err := attach.Delete(); err != nil {
|
||||
beego.Error(err)
|
||||
logs.Error(err)
|
||||
c.JsonResult(6005, "删除失败")
|
||||
}
|
||||
|
||||
@@ -640,7 +641,7 @@ func (c *BlogController) Download() {
|
||||
if err == orm.ErrNoRows {
|
||||
c.ShowErrorPage(404, "附件不存在")
|
||||
} else {
|
||||
beego.Error("查询附件时出现异常 -> ", err)
|
||||
logs.Error("查询附件时出现异常 -> ", err)
|
||||
c.ShowErrorPage(500, "查询附件时出现异常")
|
||||
}
|
||||
}
|
||||
@@ -648,7 +649,7 @@ func (c *BlogController) Download() {
|
||||
//如果是链接的文章,需要校验文档ID是否一致,如果不是,需要保证附件的项目ID为0且文档的ID等于博文ID
|
||||
if blog.BlogType == 1 && attachment.DocumentId != blog.DocumentId {
|
||||
c.ShowErrorPage(404, "附件不存在")
|
||||
} else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId ) {
|
||||
} else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId) {
|
||||
c.ShowErrorPage(404, "附件不存在")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user