package controllers import ( "cc-officialweb/models" "cc-officialweb/service" beego "github.com/beego/beego/v2/server/web" "strconv" ) type ServicesController struct { beego.Controller } func (s *ServicesController) Get() { var success []string ptype := s.GetString("ptype") id := s.GetString(":id") atoi, _ := strconv.Atoi(id) product := service.GetProduct(ptype) //获取成功案例轮播图 exams := service.GetResource("example") for _, v := range exams { success = append(success, v.Url) } var serve models.Products var getService []models.Server if atoi == 0 { serve = service.GetServices() getService = service.GetService(int(serve.ID)) } else { serve = service.GetServicesByID(atoi) getService = service.GetService(atoi) } serves := service.GetIndexProductServe("serve") //getService = service.GetService(atoi) s.Data["GetService"] = getService s.Data["Serve"] = serve s.Data["Serves"] = serves s.Data["Products"] = product s.Data["example"] = success s.TplName = "services.html" }