[ADD]文章详情

This commit is contained in:
2019-06-28 12:37:42 +08:00
parent de5b6e207c
commit fc2cb83bfd
6 changed files with 54 additions and 73 deletions

View File

@@ -1,6 +1,9 @@
package controllers
import "liteblog/models"
import (
"liteblog/models"
"liteblog/syserrors"
)
type IndexController struct {
BaseController
@@ -40,6 +43,24 @@ func (c *IndexController) Get() {
c.TplName = "index.html"
}
// 显示文章
// @router /details/:key [get]
func (c *IndexController) GetDetail() {
// 得到页面传过来的key
key := c.Ctx.Input.Param(":key")
// 到数据查询对应key的文章
note, err := models.QueryNoteByKey(key)
if err != nil {
c.Abort500(syserrors.NewError("文章不存在", err))
}
c.Data["note"] = note
c.TplName = "details.html"
}
//留言
// @router /message [get]
func (c *IndexController) GetMessage() {