about.go 781 B

123456789101112131415161718192021222324252627282930313233343536
  1. package controllers
  2. import (
  3. "cc-officialweb/service"
  4. beego "github.com/beego/beego/v2/server/web"
  5. )
  6. type AboutController struct {
  7. beego.Controller
  8. }
  9. func (a *AboutController) Get() {
  10. about, err := service.GetRecruit("about")
  11. if err != nil {
  12. a.Data["content"] = "暂无内容"
  13. } else {
  14. a.Data["content"] = about
  15. }
  16. var success []string
  17. //获取成功案例轮播图
  18. exams := service.GetResource("example")
  19. for _, v := range exams {
  20. success = append(success, v.Url)
  21. }
  22. //获取产品分类
  23. productType := service.GetProductType()
  24. if len(productType) == 0 {
  25. a.Data["productFirst"] = "暂无产品分类"
  26. } else {
  27. a.Data["productFirst"] = productType[0].Name
  28. }
  29. a.Data["productType"] = productType
  30. a.Data["example"] = success
  31. a.TplName = "about.html"
  32. }