123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package controllers
- import (
- "Yunlot/lib"
- "Yunlot/models/Product"
- beego "github.com/beego/beego/v2/server/web"
- )
- type ProductTypeController struct {
- beego.Controller
- }
- func (c *ProductTypeController) List() {
- PageIndex, _ := c.GetInt("PageIndex", 0)
- PageSize, _ := c.GetInt("PageSize", 10)
- ProductTyper := Product.ProductType{}
- c.ParseForm(&ProductTyper)
- ProductType_r, Total := ProductTyper.Lists(PageIndex, PageSize)
- c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: lib.C_Page(ProductType_r, PageIndex, PageSize, Total)}
- c.ServeJSON()
- return
- }
- func (c *ProductTypeController) Get() {
- ProductTyper := Product.ProductType{}
- c.ParseForm(&ProductTyper)
- if !ProductTyper.Read() {
- c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "ProductID E!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductTyper}
- c.ServeJSON()
- return
- }
- func (c *ProductTypeController) Add() {
- ProductType_r := Product.ProductType{}
- c.ParseForm(&ProductType_r)
- ProductType_r.T_ProductID = lib.GetRandstring(8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0)
- ProductType_r.T_akey = lib.GetRandstring(32, "", 0)
- ProductType_r.Add()
- c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductType_r}
- c.ServeJSON()
- return
- }
- func (c *ProductTypeController) Update() {
- ProductTyper := Product.ProductType{}
- c.ParseForm(&ProductTyper)
- if !ProductTyper.Update("T_name", "T_img", "T_prot", "T_TabData") {
- 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 *ProductTypeController) Delete() {
- ProductTyper := Product.ProductType{}
- c.ParseForm(&ProductTyper)
- if !ProductTyper.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
- }
|