package controllers import ( "Yunlot/lib" "Yunlot/models/Product" beego "github.com/beego/beego/v2/server/web" ) type ProductTabController struct { beego.Controller } func (c *ProductTabController) List() { PageIndex, _ := c.GetInt("PageIndex", 0) PageSize, _ := c.GetInt("PageSize", 10) ProductTabr := Product.ProductTab{} c.ParseForm(&ProductTabr) ProductTab_r, Total := ProductTabr.Lists(PageIndex, PageSize) c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: lib.C_Page(ProductTab_r, PageIndex, PageSize, Total)} c.ServeJSON() return } func (c *ProductTabController) Add() { ProductTab_r := Product.ProductTab{} c.ParseForm(&ProductTab_r) ProductTab_r.Id = 0 ProductTab_r.Add() c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductTab_r} c.ServeJSON() return } func (c *ProductTabController) Update() { ProductTabr := Product.ProductTab{} c.ParseForm(&ProductTabr) if !ProductTabr.Update("T_name", "T_tab", "T_type", "T_attr", "T_text") { c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "E!"} c.ServeJSON() return } c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!"} c.ServeJSON() return } func (c *ProductTabController) Delete() { ProductTabr := Product.ProductTab{} c.ParseForm(&ProductTabr) if !ProductTabr.Delete() { c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "E!"} c.ServeJSON() return } c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!"} c.ServeJSON() return }