VerifyTemplate.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. package controllers
  2. import (
  3. "bzd_server/lib"
  4. "bzd_server/models/VerifyTemplate"
  5. beego "github.com/beego/beego/v2/server/web"
  6. )
  7. type VerifyTemplateController struct {
  8. beego.Controller
  9. }
  10. // 列表 -
  11. func (c *VerifyTemplateController) List() {
  12. // 验证登录 User_is, User_r
  13. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  14. //if !User_is {
  15. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  16. // c.ServeJSON()
  17. // return
  18. //}
  19. T_name := c.GetString("T_name")
  20. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: VerifyTemplate.Read_VerifyTemplate_List(T_name)}
  21. c.ServeJSON()
  22. return
  23. }
  24. // 添加-
  25. func (c *VerifyTemplateController) Add() {
  26. // 验证登录 User_is, User_r
  27. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  28. //if !User_is {
  29. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  30. // c.ServeJSON()
  31. // return
  32. //}
  33. T_name := c.GetString("T_name")
  34. T_sort, _ := c.GetInt("T_sort")
  35. var_ := VerifyTemplate.VerifyTemplate{
  36. T_name: T_name,
  37. T_sort: T_sort,
  38. }
  39. Id, is := VerifyTemplate.Add_VerifyTemplate(var_)
  40. if !is {
  41. c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
  42. c.ServeJSON()
  43. return
  44. }
  45. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: Id}
  46. c.ServeJSON()
  47. return
  48. }
  49. // 修改-
  50. func (c *VerifyTemplateController) Up() {
  51. // 验证登录 User_is, User_r
  52. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  53. //if !User_is {
  54. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  55. // c.ServeJSON()
  56. // return
  57. //}
  58. T_name := c.GetString("T_name")
  59. T_sort, T_sort_err := c.GetInt("T_sort")
  60. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  61. r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id);
  62. if !is {
  63. c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id 错误!"}
  64. c.ServeJSON()
  65. return
  66. }
  67. // .......
  68. if len(T_name) > 0{
  69. r.T_name = T_name
  70. }
  71. if T_sort_err == nil {
  72. r.T_sort = T_sort
  73. }
  74. // .......
  75. if !VerifyTemplate.Update_VerifyTemplate(r,"T_name","T_sort") {
  76. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  77. c.ServeJSON()
  78. return
  79. }
  80. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  81. c.ServeJSON()
  82. return
  83. }
  84. // 删除-
  85. func (c *VerifyTemplateController) Del() {
  86. // 验证登录 User_is, User_r
  87. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  88. //if !User_is {
  89. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  90. // c.ServeJSON()
  91. // return
  92. //}
  93. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  94. if r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id); is {
  95. if !VerifyTemplate.Delete_VerifyTemplate(r) {
  96. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  97. c.ServeJSON()
  98. return
  99. }
  100. }
  101. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  102. c.ServeJSON()
  103. return
  104. }
  105. /// -----------------------------------------------------------------------------
  106. // 列表 -
  107. func (c *VerifyTemplateController) Map_List() {
  108. // 验证登录 User_is, User_r
  109. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  110. //if !User_is {
  111. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  112. // c.ServeJSON()
  113. // return
  114. //}
  115. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  116. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_id)}
  117. c.ServeJSON()
  118. return
  119. }
  120. // 添加-
  121. func (c *VerifyTemplateController) Map_Add() {
  122. // 验证登录 User_is, User_r
  123. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  124. //if !User_is {
  125. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  126. // c.ServeJSON()
  127. // return
  128. //}
  129. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  130. T_name := c.GetString("T_name")
  131. T_field := c.GetString("T_field")
  132. T_text := c.GetString("T_text")
  133. T_label, _ := c.GetInt("T_label")
  134. var_ := VerifyTemplate.VerifyTemplateMap{
  135. T_VerifyTemplate_id: T_VerifyTemplate_id,
  136. T_name: T_name,
  137. T_field: T_field,
  138. T_text: T_text,
  139. T_label: T_label,
  140. }
  141. Id, is := VerifyTemplate.Add_VerifyTemplateMap(var_)
  142. if !is {
  143. c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
  144. c.ServeJSON()
  145. return
  146. }
  147. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: Id}
  148. c.ServeJSON()
  149. return
  150. }
  151. // 修改-
  152. func (c *VerifyTemplateController) Map_Up() {
  153. // 验证登录 User_is, User_r
  154. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  155. //if !User_is {
  156. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  157. // c.ServeJSON()
  158. // return
  159. //}
  160. T_name := c.GetString("T_name")
  161. T_field := c.GetString("T_field")
  162. T_text := c.GetString("T_text")
  163. T_label, T_label_err := c.GetInt("T_label")
  164. T_id := c.GetString("T_id")
  165. r, is := VerifyTemplate.Read_VerifyTemplateMap(T_id);
  166. if !is {
  167. c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id 错误!"}
  168. c.ServeJSON()
  169. return
  170. }
  171. // .......
  172. if len(T_name) > 0{
  173. r.T_name = T_name
  174. }
  175. if len(T_field) > 0{
  176. r.T_field = T_field
  177. }
  178. if len(T_text) > 0{
  179. r.T_text = T_text
  180. }
  181. if T_label_err == nil {
  182. r.T_label = T_label
  183. }
  184. // .......
  185. if !VerifyTemplate.Update_VerifyTemplateMap(r,"T_name","T_label","T_text","T_field") {
  186. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  187. c.ServeJSON()
  188. return
  189. }
  190. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  191. c.ServeJSON()
  192. return
  193. }
  194. // 删除-
  195. func (c *VerifyTemplateController) Map_Del() {
  196. // 验证登录 User_is, User_r
  197. //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  198. //if !User_is {
  199. // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
  200. // c.ServeJSON()
  201. // return
  202. //}
  203. T_id := c.GetString("T_id")
  204. if r, is := VerifyTemplate.Read_VerifyTemplateMap(T_id); is {
  205. if !VerifyTemplate.Delete_VerifyTemplateMap(r) {
  206. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  207. c.ServeJSON()
  208. return
  209. }
  210. }
  211. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  212. c.ServeJSON()
  213. return
  214. }