GoodsOrder.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package controllers
  2. import (
  3. "Cold_Api/conf"
  4. "Cold_Api/controllers/lib"
  5. "Cold_Api/models/Function"
  6. "Cold_Api/models/Template"
  7. beego "github.com/beego/beego/v2/server/web"
  8. )
  9. //Handle
  10. type GoodsOrderController struct {
  11. beego.Controller
  12. }
  13. func (c *GoodsOrderController) GoodsOrder_html() {
  14. // 验证登录
  15. b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  16. if !b_ {
  17. c.Ctx.Redirect(302, "Login")
  18. return
  19. }
  20. //c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
  21. Name := c.GetString("Name")
  22. page, _ := c.GetInt("page")
  23. println(page)
  24. if page < 1 {
  25. page = 1
  26. }
  27. page_z, _ := c.GetInt("Page_size")
  28. if page_z == 0 {
  29. page_z = conf.Page_size
  30. }
  31. List, cnt := Function.Read_GoodsOrder_List(page, page_z, Name)
  32. c.Data["Name"] = Name
  33. c.Data["List"] = List
  34. c.Data["Page"] = page
  35. c.Data["Page_size"] = page_z
  36. c.Data["Pages"] = lib.Func_page(int64(page), int64(page_z))
  37. c.Data["cnt"] = cnt
  38. c.TplName = "GoodsOrder/GoodsOrder.html"
  39. }
  40. func (c *GoodsOrderController) GoodsOrder__html() {
  41. // 验证登录
  42. b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  43. if !b_ {
  44. c.Ctx.Redirect(302, "Login")
  45. return
  46. }
  47. //c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
  48. c.TplName = "GoodsOrder/GoodsOrder-.html"
  49. }
  50. //
  51. //func (c *GoodsOrderController) GoodsOrder_List() {
  52. // // 验证登录
  53. // b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  54. // if !b_ {
  55. // c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  56. // c.ServeJSON()
  57. // return
  58. // }
  59. //
  60. // type R_JSONS struct {
  61. // //必须的大写开头
  62. // DeviceSensor_lite []Device.DeviceSensor_R
  63. // Num int
  64. // Page int
  65. // Page_size int
  66. // Pages []lib.Page_T
  67. // }
  68. // var r_jsons R_JSONS
  69. // page, _ := c.GetInt("page")
  70. //
  71. // println(page)
  72. // if page < 1 {
  73. // page = 1
  74. // }
  75. //
  76. // page_z, _ := c.GetInt("page_z")
  77. // if page_z == 0 {
  78. // page_z = conf.Page_size
  79. // }
  80. //
  81. // T_sn := c.GetString("Sn")
  82. //
  83. // Device_r, err := Device.Read_Device_ByT_sn(T_sn)
  84. // if err != nil {
  85. // c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_sn Err!"}
  86. // c.ServeJSON()
  87. // return
  88. // }
  89. // if admin_r.Admin_master > 1 {
  90. // if !strings.Contains(Device_r.T_Bind, "U"+strconv.Itoa(admin_r.Id)+"|") && admin_r.Admin_master != 0 {
  91. // c.Data["json"] = lib.JSONS{Code: 202, Msg: "! U" + strconv.Itoa(admin_r.Id)}
  92. // c.ServeJSON()
  93. // return
  94. // }
  95. // }
  96. //
  97. // //c.Data["Class_List"] = Device.Read_Class_All_1()
  98. //
  99. // var cnt int64
  100. // r_jsons.DeviceSensor_lite, cnt = Device.Read_DeviceSensor_ALL_T_sn(T_sn, page, page_z)
  101. //
  102. // page_size := math.Ceil(float64(cnt) / float64(page_z))
  103. // r_jsons.Page = int(page)
  104. // r_jsons.Page_size = int(page_size)
  105. // r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  106. // r_jsons.Num = int(cnt)
  107. //
  108. // c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  109. // c.ServeJSON()
  110. // return
  111. //
  112. //}
  113. //
  114. func (c *GoodsOrderController) List_Post() {
  115. var id int64
  116. var err error
  117. id, _ = c.GetInt64("id")
  118. T_name := c.GetString("T_name")
  119. T_class, _ := c.GetInt("T_class")
  120. T_img := c.GetString("T_img")
  121. T_int, _ := c.GetInt("T_int")
  122. T_text := c.GetString("T_text")
  123. var_ := Template.Template{
  124. T_name: T_name,
  125. T_class: T_class,
  126. T_img: T_img,
  127. T_int: T_int,
  128. T_text: T_text,
  129. T_State: 1,
  130. }
  131. if id > 0 {
  132. var_.Id = int(id)
  133. err = Template.Update_List_ById(var_)
  134. if err != nil {
  135. c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
  136. c.ServeJSON()
  137. return
  138. }
  139. } else {
  140. id, err = Template.Add_List(var_)
  141. if err != nil {
  142. c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
  143. c.ServeJSON()
  144. return
  145. }
  146. }
  147. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  148. c.ServeJSON()
  149. return
  150. }
  151. func (c *GoodsOrderController) List_Del() {
  152. Id, _ := c.GetInt("Id")
  153. if Id > 0 {
  154. Template.Delete_List_ById(Id)
  155. } else {
  156. c.Data["json"] = lib.JSONS{Code: 201, Msg: "e!"}
  157. c.ServeJSON()
  158. return
  159. }
  160. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  161. c.ServeJSON()
  162. return
  163. }