product-detail.go 472 B

123456789101112131415161718192021222324
  1. package controllers
  2. import (
  3. "cc-officialweb/service"
  4. beego "github.com/beego/beego/v2/server/web"
  5. "strconv"
  6. )
  7. type DetailController struct {
  8. beego.Controller
  9. }
  10. func (d *DetailController) Get() {
  11. d.Data["IsDetail"] = true
  12. id := d.Ctx.Input.Param(":id")
  13. atoi, err := strconv.Atoi(id)
  14. if err != nil {
  15. d.Redirect("/", 302)
  16. }
  17. detail := service.GetProductDetail(atoi)
  18. d.Data["detail"] = detail
  19. d.Data["showSection"] = true
  20. d.TplName = "product-detail.html"
  21. }