services.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package controllers
  2. import (
  3. "cc-officialweb/models"
  4. "cc-officialweb/service"
  5. beego "github.com/beego/beego/v2/server/web"
  6. "strconv"
  7. )
  8. type ServicesController struct {
  9. beego.Controller
  10. }
  11. func (s *ServicesController) Get() {
  12. var success []string
  13. ptype := s.GetString("ptype")
  14. id := s.GetString(":id")
  15. atoi, _ := strconv.Atoi(id)
  16. product := service.GetProduct(ptype)
  17. //获取成功案例轮播图
  18. exams := service.GetResource("example")
  19. for _, v := range exams {
  20. success = append(success, v.Url)
  21. }
  22. var serve models.Products
  23. var getService []models.Server
  24. if atoi == 0 {
  25. serve = service.GetServices()
  26. getService = service.GetService(int(serve.ID))
  27. } else {
  28. serve = service.GetServicesByID(atoi)
  29. getService = service.GetService(atoi)
  30. }
  31. serves := service.GetIndexProductServe("serve")
  32. //getService = service.GetService(atoi)
  33. s.Data["GetService"] = getService
  34. s.Data["Serve"] = serve
  35. s.Data["Serves"] = serves
  36. s.Data["Products"] = product
  37. s.Data["example"] = success
  38. s.TplName = "services.html"
  39. }