MCPcopy Create free account
hub / github.com/TruthHun/BookStack / DeleteComment

Method DeleteComment

models/comments.go:178–190  ·  view source on GitHub ↗

删除评论

(id int)

Source from the content-addressed store, hash-verified

176
177// 删除评论
178func (this *Comments) DeleteComment(id int) {
179 m := &Comments{}
180 o := orm.NewOrm()
181 o.QueryTable(m).Filter("id", id).One(m, "book_id")
182 if m.BookId > 0 && m.DocId == 0 {
183 o.QueryTable(m).Filter("id", id).Delete()
184 sql := "update md_books set cnt_comment = cnt_comment - 1 where cnt_comment > 0 and book_id = ?"
185 _, err := o.Raw(sql, m.BookId).Exec()
186 if err != nil {
187 beego.Error(err.Error())
188 }
189 }
190}
191
192func (this *Comments) Count(bookId int, status ...int) (int64, error) {
193 query := orm.NewOrm().QueryTable(this)

Callers

nothing calls this directly

Calls 1

DeleteMethod · 0.45

Tested by

no test coverage detected