about.go 1012 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package controller
  2. import (
  3. "git.wanbits.cc/sin/flytalk/models"
  4. "github.com/gin-gonic/gin"
  5. )
  6. func GetAbout(c *gin.Context) {
  7. page := c.Query("page")
  8. if page == "" {
  9. page = "index"
  10. }
  11. about := models.FindAboutByPage(page)
  12. c.JSON(200, gin.H{
  13. "code": 200,
  14. "msg": "ok",
  15. "result": about,
  16. })
  17. }
  18. func PostAbout(c *gin.Context) {
  19. title_cn := c.PostForm("title_cn")
  20. title_en := c.PostForm("title_en")
  21. keywords_cn := c.PostForm("keywords_cn")
  22. keywords_en := c.PostForm("keywords_en")
  23. desc_cn := c.PostForm("desc_cn")
  24. desc_en := c.PostForm("desc_en")
  25. css_js := c.PostForm("css_js")
  26. html_cn := c.PostForm("html_cn")
  27. html_en := c.PostForm("html_en")
  28. if title_cn == "" || title_en == "" || html_cn == "" || html_en == "" {
  29. c.JSON(200, gin.H{
  30. "code": 400,
  31. "msg": "error",
  32. })
  33. return
  34. }
  35. models.UpdateAbout("index", title_cn, title_en, keywords_cn, keywords_en, desc_cn, desc_en, css_js, html_cn, html_en)
  36. c.JSON(200, gin.H{
  37. "code": 200,
  38. "msg": "ok",
  39. "result": "",
  40. })
  41. }