ProductTab.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package controllers
  2. import (
  3. "Yunlot/lib"
  4. "Yunlot/models/Product"
  5. beego "github.com/beego/beego/v2/server/web"
  6. )
  7. type ProductTabController struct {
  8. beego.Controller
  9. }
  10. func (c *ProductTabController) List() {
  11. PageIndex, _ := c.GetInt("PageIndex", 0)
  12. PageSize, _ := c.GetInt("PageSize", 10)
  13. ProductTabr := Product.ProductTab{}
  14. c.ParseForm(&ProductTabr)
  15. ProductTab_r, Total := ProductTabr.Lists(PageIndex, PageSize)
  16. c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: lib.C_Page(ProductTab_r, PageIndex, PageSize, Total)}
  17. c.ServeJSON()
  18. return
  19. }
  20. func (c *ProductTabController) Add() {
  21. ProductTab_r := Product.ProductTab{}
  22. c.ParseForm(&ProductTab_r)
  23. ProductTab_r.Id = 0
  24. ProductTab_r.Add()
  25. c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductTab_r}
  26. c.ServeJSON()
  27. return
  28. }
  29. func (c *ProductTabController) Update() {
  30. ProductTabr := Product.ProductTab{}
  31. c.ParseForm(&ProductTabr)
  32. if !ProductTabr.Update("T_name", "T_tab", "T_type", "T_attr", "T_text") {
  33. c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "E!"}
  34. c.ServeJSON()
  35. return
  36. }
  37. c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!"}
  38. c.ServeJSON()
  39. return
  40. }
  41. func (c *ProductTabController) Delete() {
  42. ProductTabr := Product.ProductTab{}
  43. c.ParseForm(&ProductTabr)
  44. if !ProductTabr.Delete() {
  45. c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "E!"}
  46. c.ServeJSON()
  47. return
  48. }
  49. c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!"}
  50. c.ServeJSON()
  51. return
  52. }