package controllers import ( "cc-officialweb/service" beego "github.com/beego/beego/v2/server/web" "strconv" ) type DetailController struct { beego.Controller } func (d *DetailController) Get() { id := d.Ctx.Input.Param(":id") atoi, err := strconv.Atoi(id) if err != nil { d.Redirect("/", 302) } detail := service.GetProductDetail(atoi) productType := service.GetProductType() if len(productType) == 0 { d.Data["productFirst"] = "暂无产品分类" } else { d.Data["productFirst"] = productType[0].Name } d.Data["productType"] = productType d.Data["detail"] = detail d.Data["showSection"] = true d.TplName = "product-detail.html" }