services.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. //获取产品分类
  35. productType := service.GetProductType()
  36. if len(productType) == 0 {
  37. s.Data["productFirst"] = "暂无产品分类"
  38. } else {
  39. s.Data["productFirst"] = productType[0].Name
  40. }
  41. s.Data["productType"] = productType
  42. s.Data["Serve"] = serve
  43. s.Data["Serves"] = serves
  44. s.Data["Products"] = product
  45. s.Data["example"] = success
  46. s.TplName = "services.html"
  47. }