ProductRelay.go 1.5 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 ProductRelayController struct {
  8. beego.Controller
  9. }
  10. func (c *ProductRelayController) List() {
  11. PageIndex, _ := c.GetInt("PageIndex", 0)
  12. PageSize, _ := c.GetInt("PageSize", 10)
  13. ProductRelayr := Product.ProductRelay{}
  14. c.ParseForm(&ProductRelayr)
  15. ProductRelay_r, Total := ProductRelayr.Lists(PageIndex, PageSize)
  16. c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: lib.C_Page(ProductRelay_r, PageIndex, PageSize, Total)}
  17. c.ServeJSON()
  18. return
  19. }
  20. func (c *ProductRelayController) Add() {
  21. ProductRelay_r := Product.ProductRelay{}
  22. c.ParseForm(&ProductRelay_r)
  23. ProductRelay_r.Id = 0
  24. ProductRelay_r.Add()
  25. c.Data["json"] = lib.JSONR{Code: lib.Success, Msg: "ok!", Data: ProductRelay_r}
  26. c.ServeJSON()
  27. return
  28. }
  29. func (c *ProductRelayController) Update() {
  30. ProductRelayr := Product.ProductRelay{}
  31. c.ParseForm(&ProductRelayr)
  32. if !ProductRelayr.Update("T_name", "T_rtab", "T_mode", "T_pub") {
  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 *ProductRelayController) Delete() {
  42. ProductRelayr := Product.ProductRelay{}
  43. c.ParseForm(&ProductRelayr)
  44. if !ProductRelayr.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. }