package controllers import ( "Yunlot/lib" "Yunlot/models/Product" beego "github.com/beego/beego/v2/server/web" ) type ProductProtController struct { beego.Controller } func (c *ProductProtController) ProductModeLists() { ProductProt_r, Total := Product.ProductModeLists() c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: lib.C_Page(ProductProt_r, 0, 0, Total)} c.ServeJSON() return } func (c *ProductProtController) Get() { ProductProt := Product.ProductProt{} c.ParseForm(&ProductProt) if !ProductProt.Read() { c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "ID E!"} c.ServeJSON() return } c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductProt} c.ServeJSON() return } func (c *ProductProtController) List() { PageIndex, _ := c.GetInt("PageIndex", 0) PageSize, _ := c.GetInt("PageSize", 10) ProductProtr := Product.ProductProt{} c.ParseForm(&ProductProtr) ProductProt_r, Total := ProductProtr.Lists(PageIndex, PageSize) c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: lib.C_Page(ProductProt_r, PageIndex, PageSize, Total)} c.ServeJSON() return } func (c *ProductProtController) Add() { ProductProt_r := Product.ProductProt{} c.ParseForm(&ProductProt_r) ProductProt_r.Id = 0 ProductProt_r.Add() c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductProt_r} c.ServeJSON() return } func (c *ProductProtController) Update() { ProductProtr := Product.ProductProt{} c.ParseForm(&ProductProtr) if !ProductProtr.Update("T_name", "T_mode", "T_lang", "T_analysis", "T_text", "T_describe") { 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 *ProductProtController) Delete() { ProductProtr := Product.ProductProt{} c.ParseForm(&ProductProtr) if !ProductProtr.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 }