蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
747 B

  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  6. "github.com/gin-gonic/gin"
  7. "html/template"
  8. "net/http"
  9. )
  10. func ArticleHtml(c *gin.Context) {
  11. articleId := c.Query("article_id")
  12. if articleId == "" {
  13. e.OutErr(c, e.ERR_INVALID_ARGS)
  14. return
  15. }
  16. NewArticleDb := implement.NewArticleDb(db.Db)
  17. article, err := NewArticleDb.GetArticle(articleId)
  18. if err != nil {
  19. e.OutErr(c, e.ERR_DB_ORM)
  20. return
  21. }
  22. if article.Id == 0 {
  23. e.OutErr(c, e.ERR_NO_DATA)
  24. return
  25. }
  26. article.WatchCount++
  27. db.Db.Where("id=?", article.Id).Cols("watch_count").Update(article)
  28. c.HTML(http.StatusOK, "article.html", gin.H{
  29. "title": template.HTML(article.Title),
  30. "content": article.Content,
  31. })
  32. }