fix:修复链接文章的附件无法下载问题

This commit is contained in:
lifei6671 2019-01-22 18:51:39 +08:00
parent 11634d8c5b
commit 34487947ba

View File

@ -632,16 +632,18 @@ func (c *BlogController) Download() {
attachment, err := models.NewAttachment().Find(attachId)
if err != nil {
beego.Error("DownloadAttachment => ", err)
if err == orm.ErrNoRows {
c.ShowErrorPage(404, "附件不存在")
} else {
beego.Error("查询附件时出现异常 -> ", err)
c.ShowErrorPage(500, "查询附件时出现异常")
}
}
if blog.BlogType == 1 && attachment.BookId != blog.BookId && attachment.DocumentId != blog.DocumentId {
//如果是链接的文章需要校验文档ID是否一致如果不是需要保证附件的项目ID为0且文档的ID等于博文ID
if blog.BlogType == 1 && attachment.DocumentId != blog.DocumentId {
c.ShowErrorPage(404, "附件不存在")
} else if attachment.BookId != 0 || attachment.DocumentId != blogId {
} else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId ) {
c.ShowErrorPage(404, "附件不存在")
}