fix can delete blogroll and about page & fix delete and readd article bug

This commit is contained in:
deepzz0
2018-01-07 20:30:14 +08:00
parent 3245c0e0d3
commit 405fbaf24f
2 changed files with 8 additions and 3 deletions

2
api.go
View File

@@ -152,7 +152,7 @@ func apiPostDelete(c *gin.Context) {
var i int
for _, v := range c.Request.PostForm["cid[]"] {
i, err = strconv.Atoi(v)
if err != nil || i < 1 {
if err != nil || int32(i) < setting.Conf.General.StartID {
err = errors.New("参数错误")
return
}

9
db.go
View File

@@ -402,8 +402,13 @@ func AddArticle(artc *Article) error {
}
}
err := mgo.Insert(DB, COLLECTION_ARTICLE, artc)
if err != nil {
return err
}
// 正式发布文章
if !artc.IsDraft {
// 正式发布文章
defer GenerateExcerptAndRender(artc)
Ei.MapArticles[artc.Slug] = artc
Ei.Articles = append([]*Article{artc}, Ei.Articles...)
@@ -417,7 +422,7 @@ func AddArticle(artc *Article) error {
Ei.CH <- SERIES_MD
}
}
return mgo.Insert(DB, COLLECTION_ARTICLE, artc)
return nil
}
// 删除文章,移入回收箱