user viper
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"go_blog/models"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ShowPost(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "home.html", gin.H{
|
||||
"title": "首页",
|
||||
})
|
||||
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 32)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var content = models.Content{Cid: int32(id)}
|
||||
models.DB.First(&content)
|
||||
c.HTML(http.StatusOK, "post.tmpl", content)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user