product-detail.go 445 B

1234567891011121314151617181920212223
  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. id := d.Ctx.Input.Param(":id")
  12. atoi, err := strconv.Atoi(id)
  13. if err != nil {
  14. d.Redirect("/", 302)
  15. }
  16. detail := service.GetProductDetail(atoi)
  17. d.Data["detail"] = detail
  18. d.Data["showSection"] = true
  19. d.TplName = "product-detail.html"
  20. }