[ADD]文章详情
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user