mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-18 17:48:00 +08:00
增加删除评论
This commit is contained in:
@@ -16,16 +16,14 @@ type CommentController struct {
|
||||
}
|
||||
|
||||
func (c *CommentController) Lists() {
|
||||
|
||||
docid, _ := c.GetInt("docid", 0)
|
||||
pageIndex, _ := c.GetInt("page", 1)
|
||||
|
||||
beego.Info("CommentController.Lists", docid, pageIndex)
|
||||
|
||||
// 获取评论、分页
|
||||
comments, count := models.NewComment().QueryCommentByDocumentId(docid, pageIndex, conf.PageSize)
|
||||
comments, count, pageIndex := models.NewComment().QueryCommentByDocumentId(docid, pageIndex, conf.PageSize, c.Member.MemberId)
|
||||
page := pagination.PageUtil(int(count), pageIndex, conf.PageSize, comments)
|
||||
beego.Info("docid=", docid, "Page", page)
|
||||
|
||||
var data struct {
|
||||
DocId int `json:"doc_id"`
|
||||
@@ -57,11 +55,30 @@ func (c *CommentController) Create() {
|
||||
beego.Info(m)
|
||||
m.Insert()
|
||||
|
||||
c.JsonResult(0, "ok")
|
||||
var data struct {
|
||||
DocId int `json:"doc_id"`
|
||||
}
|
||||
data.DocId = id
|
||||
|
||||
c.JsonResult(0, "ok", data)
|
||||
}
|
||||
|
||||
func (c *CommentController) Index() {
|
||||
|
||||
c.Prepare()
|
||||
c.TplName = "comment/index.tpl"
|
||||
}
|
||||
|
||||
func (c *CommentController) Delete() {
|
||||
if c.Ctx.Input.IsPost() {
|
||||
id, _ := c.GetInt("id", 0)
|
||||
beego.Info("delete id=", id)
|
||||
m := models.NewComment()
|
||||
m.CommentId = id
|
||||
err := m.Delete()
|
||||
if err != nil {
|
||||
c.JsonResult(1, "删除错误")
|
||||
} else {
|
||||
c.JsonResult(0, "ok")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -70,10 +70,9 @@ func (c *DocumentController) Index() {
|
||||
c.Data["DocumentId"] = doc.DocumentId
|
||||
|
||||
// 获取评论、分页
|
||||
comments, count := models.NewComment().QueryCommentByDocumentId(doc.DocumentId, 1, conf.PageSize)
|
||||
comments, count, _ := models.NewComment().QueryCommentByDocumentId(doc.DocumentId, 1, conf.PageSize, c.Member.MemberId)
|
||||
page := pagination.PageUtil(int(count), 1, conf.PageSize, comments)
|
||||
c.Data["Page"] = page
|
||||
beego.Info("docid=", doc.DocumentId, "Page", page)
|
||||
}
|
||||
} else {
|
||||
c.Data["Title"] = "概要"
|
||||
@@ -156,10 +155,9 @@ func (c *DocumentController) Read() {
|
||||
c.Data["ViewCount"] = doc.ViewCount + 1
|
||||
|
||||
// 获取评论、分页
|
||||
comments, count := models.NewComment().QueryCommentByDocumentId(doc.DocumentId, 1, conf.PageSize)
|
||||
comments, count, _ := models.NewComment().QueryCommentByDocumentId(doc.DocumentId, 1, conf.PageSize, c.Member.MemberId)
|
||||
page := pagination.PageUtil(int(count), 1, conf.PageSize, comments)
|
||||
c.Data["Page"] = page
|
||||
beego.Info("docid=", doc.DocumentId, "Page", page)
|
||||
|
||||
if c.IsAjax() {
|
||||
var data struct {
|
||||
|
Reference in New Issue
Block a user