package controllers import ( "Yunlot/lib" "Yunlot/models/Product" beego "github.com/beego/beego/v2/server/web" ) type ProductRelayController struct { beego.Controller } func (c *ProductRelayController) List() { PageIndex, _ := c.GetInt("PageIndex", 0) PageSize, _ := c.GetInt("PageSize", 10) ProductRelayr := Product.ProductRelay{} c.ParseForm(&ProductRelayr) ProductRelay_r, Total := ProductRelayr.Lists(PageIndex, PageSize) c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: lib.C_Page(ProductRelay_r, PageIndex, PageSize, Total)} c.ServeJSON() return } func (c *ProductRelayController) Add() { ProductRelay_r := Product.ProductRelay{} c.ParseForm(&ProductRelay_r) ProductRelay_r.Id = 0 ProductRelay_r.Add() c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductRelay_r} c.ServeJSON() return } func (c *ProductRelayController) Update() { ProductRelayr := Product.ProductRelay{} c.ParseForm(&ProductRelayr) if !ProductRelayr.Update("T_name", "T_rtab", "T_mode", "T_pub") { 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 *ProductRelayController) Delete() { ProductRelayr := Product.ProductRelay{} c.ParseForm(&ProductRelayr) if !ProductRelayr.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 }