VerifyTemplate.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. package controllers
  2. import (
  3. "ColdVerify_server/conf"
  4. "ColdVerify_server/lib"
  5. "ColdVerify_server/models/Account"
  6. "ColdVerify_server/models/System"
  7. "ColdVerify_server/models/Task"
  8. "ColdVerify_server/models/VerifyTemplate"
  9. "encoding/json"
  10. beego "github.com/beego/beego/v2/server/web"
  11. "math"
  12. "strconv"
  13. )
  14. type VerifyTemplateController struct {
  15. beego.Controller
  16. }
  17. // 列表 -
  18. func (c *VerifyTemplateController) List() {
  19. // 验证登录 User_is, User_r
  20. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  21. if !User_is {
  22. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  23. c.ServeJSON()
  24. return
  25. }
  26. var r_jsons lib.R_JSONS
  27. page, _ := c.GetInt("page")
  28. if page < 1 {
  29. page = 1
  30. }
  31. page_z, _ := c.GetInt("page_z")
  32. if page_z < 1 {
  33. page_z = conf.Page_size
  34. }
  35. T_class, _ := c.GetInt("T_class")
  36. if T_class <= 0 {
  37. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class Err!"}
  38. c.ServeJSON()
  39. return
  40. }
  41. T_name := c.GetString("T_name")
  42. var cnt int64
  43. List, cnt := VerifyTemplate.Read_VerifyTemplate_List(T_class, T_name, page, page_z)
  44. page_size := math.Ceil(float64(cnt) / float64(page_z))
  45. r_jsons.List = List
  46. r_jsons.Page = page
  47. r_jsons.Page_size = int(page_size)
  48. r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  49. r_jsons.Num = int(cnt)
  50. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  51. c.ServeJSON()
  52. return
  53. }
  54. // 添加-
  55. func (c *VerifyTemplateController) Add() {
  56. // 验证登录 User_is, User_r
  57. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  58. if !User_is {
  59. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  60. c.ServeJSON()
  61. return
  62. }
  63. T_name := c.GetString("T_name")
  64. T_sort, _ := c.GetInt("T_sort")
  65. T_class, _ := c.GetInt("T_class")
  66. var_ := VerifyTemplate.VerifyTemplate{
  67. T_class: T_class,
  68. T_name: T_name,
  69. T_sort: T_sort,
  70. }
  71. Id, is := VerifyTemplate.Add_VerifyTemplate(var_)
  72. if !is {
  73. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  74. c.ServeJSON()
  75. return
  76. }
  77. System.Add_UserLogs_T(User_r.T_uuid, "验证模板", "添加", var_)
  78. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
  79. c.ServeJSON()
  80. return
  81. }
  82. // 修改-
  83. func (c *VerifyTemplateController) Up() {
  84. // 验证登录 User_is, User_r
  85. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  86. if !User_is {
  87. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  88. c.ServeJSON()
  89. return
  90. }
  91. T_name := c.GetString("T_name")
  92. T_sort, T_sort_err := c.GetInt("T_sort")
  93. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  94. T_scheme := c.GetString("T_scheme")
  95. T_reporting := c.GetString("T_reporting")
  96. r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id)
  97. if !is {
  98. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  99. c.ServeJSON()
  100. return
  101. }
  102. // .......
  103. if len(T_name) > 0 {
  104. r.T_name = T_name
  105. }
  106. if len(T_scheme) > 0 {
  107. r.T_scheme = T_scheme
  108. }
  109. if len(T_reporting) > 0 {
  110. r.T_reporting = T_reporting
  111. }
  112. if T_sort_err == nil {
  113. r.T_sort = T_sort
  114. }
  115. // .......
  116. if !VerifyTemplate.Update_VerifyTemplate(r, "T_name", "T_sort", "T_scheme", "T_reporting") {
  117. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  118. c.ServeJSON()
  119. return
  120. }
  121. System.Add_UserLogs_T(User_r.T_uuid, "验证模板", "修改", r)
  122. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  123. c.ServeJSON()
  124. return
  125. }
  126. // 删除-
  127. func (c *VerifyTemplateController) Del() {
  128. // 验证登录 User_is, User_r
  129. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  130. if !User_is {
  131. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  132. c.ServeJSON()
  133. return
  134. }
  135. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  136. r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id)
  137. if !is {
  138. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  139. c.ServeJSON()
  140. return
  141. }
  142. if !VerifyTemplate.Delete_VerifyTemplate(r) {
  143. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  144. c.ServeJSON()
  145. return
  146. }
  147. mapList, _ := VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_id, 0, 0)
  148. for _, v := range mapList {
  149. if vtm, is := VerifyTemplate.Read_VerifyTemplateMap(v.T_id); is {
  150. VerifyTemplate.Delete_VerifyTemplateMap(vtm)
  151. }
  152. }
  153. System.Add_UserLogs_T(User_r.T_uuid, "验证模板", "删除", r)
  154. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  155. c.ServeJSON()
  156. return
  157. }
  158. // 复制-
  159. func (c *VerifyTemplateController) Copy() {
  160. // 验证登录 User_is, User_r
  161. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  162. if !User_is {
  163. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  164. c.ServeJSON()
  165. return
  166. }
  167. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  168. T_name := c.GetString("T_name")
  169. r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id)
  170. if !is {
  171. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  172. c.ServeJSON()
  173. return
  174. }
  175. var_ := VerifyTemplate.VerifyTemplate{
  176. T_class: r.T_class,
  177. T_name: T_name,
  178. T_sort: r.T_sort,
  179. }
  180. new_id, is := VerifyTemplate.Add_VerifyTemplate(var_)
  181. if !is {
  182. c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制失败!"}
  183. c.ServeJSON()
  184. return
  185. }
  186. mapList, _ := VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_id, 0, 0)
  187. tempMap := make(map[string]struct{})
  188. idList := make([]string, len(mapList))
  189. // 生成mapList长度的T_id
  190. for i := 0; i < len(mapList); i++ {
  191. // 生成编号
  192. rand_x := 0
  193. T_id := ""
  194. for true {
  195. T_id = lib.GetRandstring(4, "", int64(rand_x))
  196. _, is = VerifyTemplate.Read_VerifyTemplateMap(T_id)
  197. if !is {
  198. if _, ok := tempMap[T_id]; !ok {
  199. break
  200. }
  201. }
  202. rand_x += 1
  203. }
  204. tempMap[T_id] = struct{}{}
  205. idList[i] = T_id
  206. }
  207. mapInsertList := make([]VerifyTemplate.VerifyTemplateMap, 0)
  208. for i, v := range mapList {
  209. vtm := VerifyTemplate.VerifyTemplateMap{
  210. T_id: idList[i],
  211. T_VerifyTemplate_id: new_id,
  212. T_name: v.T_name,
  213. T_text: v.T_text,
  214. T_label: v.T_label,
  215. T_source: v.T_source,
  216. T_sort: v.T_sort,
  217. T_flow_sort: v.T_flow_sort,
  218. T_max_time: v.T_max_time,
  219. T_min_time: v.T_min_time,
  220. }
  221. mapInsertList = append(mapInsertList, vtm)
  222. }
  223. _, is = VerifyTemplate.Add_VerifyTemplateMapMulti(mapInsertList)
  224. if !is {
  225. c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制失败!"}
  226. c.ServeJSON()
  227. return
  228. }
  229. System.Add_UserLogs_T(User_r.T_uuid, "验证模板", "复制", var_)
  230. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: new_id}
  231. c.ServeJSON()
  232. return
  233. }
  234. /// -----------------------------------------------------------------------------
  235. // 标签列表 -
  236. func (c *VerifyTemplateController) Map_List() {
  237. // 验证登录 User_is, User_r
  238. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  239. if !User_is {
  240. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  241. c.ServeJSON()
  242. return
  243. }
  244. var r_jsons lib.R_JSONS
  245. // page, _ := c.GetInt("page")
  246. //
  247. // if page < 1 {
  248. // page = 1
  249. // }
  250. //
  251. // page_z, _ := c.GetInt("page_z")
  252. //
  253. // if page_z < 1 {
  254. // page_z = conf.Page_size
  255. // }
  256. T_sort, _ := c.GetInt("T_sort") // 排序
  257. T_flow_sort, _ := c.GetInt("T_flow_sort") // 验证流程排序
  258. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  259. var cnt int64
  260. List, cnt := VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_id, T_sort, T_flow_sort)
  261. r_jsons.List = List
  262. r_jsons.Num = int(cnt)
  263. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  264. c.ServeJSON()
  265. return
  266. }
  267. // 标签添加-
  268. func (c *VerifyTemplateController) Map_Add() {
  269. // 验证登录 User_is, User_r
  270. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  271. if !User_is {
  272. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  273. c.ServeJSON()
  274. return
  275. }
  276. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  277. T_name := c.GetString("T_name")
  278. T_text := c.GetString("T_text")
  279. T_label, _ := c.GetInt("T_label")
  280. T_source, _ := c.GetInt("T_source")
  281. T_sort, _ := c.GetInt("T_sort")
  282. T_flow_sort, _ := c.GetInt("T_flow_sort")
  283. T_max_time, _ := c.GetInt("T_max_time")
  284. T_min_time, _ := c.GetInt("T_min_time")
  285. var_ := VerifyTemplate.VerifyTemplateMap{
  286. T_VerifyTemplate_id: T_VerifyTemplate_id,
  287. T_name: T_name,
  288. T_text: T_text,
  289. T_label: T_label,
  290. T_source: T_source,
  291. T_sort: T_sort,
  292. T_flow_sort: T_flow_sort,
  293. T_max_time: T_max_time,
  294. T_min_time: T_min_time,
  295. }
  296. Id, is := VerifyTemplate.Add_VerifyTemplateMap(var_)
  297. if !is {
  298. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  299. c.ServeJSON()
  300. return
  301. }
  302. System.Add_UserLogs_T(User_r.T_uuid, "验证模板标签", "添加", var_)
  303. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
  304. c.ServeJSON()
  305. return
  306. }
  307. // 标签修改-
  308. func (c *VerifyTemplateController) Map_Up() {
  309. // 验证登录 User_is, User_r
  310. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  311. if !User_is {
  312. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  313. c.ServeJSON()
  314. return
  315. }
  316. T_name := c.GetString("T_name")
  317. T_text := c.GetString("T_text")
  318. T_label, T_label_err := c.GetInt("T_label")
  319. T_sort, T_sort_err := c.GetInt("T_sort")
  320. T_source, T_source_err := c.GetInt("T_source")
  321. T_min_time, T_min_time_err := c.GetInt("T_min_time")
  322. T_max_time, T_max_time_err := c.GetInt("T_max_time")
  323. T_flow_sort, T_flow_sort_err := c.GetInt("T_flow_sort")
  324. T_id := c.GetString("T_id")
  325. r, is := VerifyTemplate.Read_VerifyTemplateMap(T_id)
  326. if !is {
  327. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  328. c.ServeJSON()
  329. return
  330. }
  331. // .......
  332. if len(T_name) > 0 {
  333. r.T_name = T_name
  334. }
  335. if len(T_text) > 0 {
  336. r.T_text = T_text
  337. }
  338. if T_label_err == nil {
  339. r.T_label = T_label
  340. }
  341. if T_sort_err == nil {
  342. r.T_sort = T_sort
  343. }
  344. if T_source_err == nil {
  345. r.T_source = T_source
  346. }
  347. if T_min_time_err == nil {
  348. r.T_min_time = T_min_time
  349. }
  350. if T_max_time_err == nil {
  351. r.T_max_time = T_max_time
  352. }
  353. if T_flow_sort_err == nil {
  354. r.T_flow_sort = T_flow_sort
  355. }
  356. if !VerifyTemplate.Update_VerifyTemplateMap(r, "T_name", "T_label", "T_text", "T_sort", "T_source", "T_min_time", "T_max_time", "T_flow_sort") {
  357. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  358. c.ServeJSON()
  359. return
  360. }
  361. System.Add_UserLogs_T(User_r.T_uuid, "验证模板标签", "修改", r)
  362. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  363. c.ServeJSON()
  364. return
  365. }
  366. // 标签删除-
  367. func (c *VerifyTemplateController) Map_Del() {
  368. // 验证登录 User_is, User_r
  369. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  370. if !User_is {
  371. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  372. c.ServeJSON()
  373. return
  374. }
  375. T_id := c.GetString("T_id")
  376. if r, is := VerifyTemplate.Read_VerifyTemplateMap(T_id); is {
  377. if !VerifyTemplate.Delete_VerifyTemplateMap(r) {
  378. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  379. c.ServeJSON()
  380. return
  381. }
  382. System.Add_UserLogs_T(User_r.T_uuid, "验证模板标签", "删除", r)
  383. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  384. c.ServeJSON()
  385. return
  386. }
  387. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  388. c.ServeJSON()
  389. return
  390. }
  391. /// -----------------------------------------------------------------------------
  392. // 标签数据列表 -
  393. func (c *VerifyTemplateController) Map_Data_List() {
  394. // 验证登录 User_is, User_r
  395. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  396. if !User_is {
  397. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  398. c.ServeJSON()
  399. return
  400. }
  401. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  402. T_source, _ := c.GetInt("T_source")
  403. T_flow, _ := c.GetInt("T_flow") // app 时间流程
  404. if T_flow == 0 && T_source == 0 {
  405. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_source Err!"}
  406. c.ServeJSON()
  407. return
  408. }
  409. T_task_id := c.GetString("T_task_id")
  410. _, is := Task.Read_Task(T_task_id)
  411. if !is {
  412. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
  413. c.ServeJSON()
  414. return
  415. }
  416. Map_List := VerifyTemplate.Read_VerifyTemplateMap_List_For_Data(T_VerifyTemplate_id, T_source, T_flow)
  417. Data := VerifyTemplate.Read_VerifyTemplateMapData_List(T_source, T_task_id, T_VerifyTemplate_id, Map_List)
  418. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Data}
  419. c.ServeJSON()
  420. return
  421. }
  422. // 添加标签数据
  423. func (c *VerifyTemplateController) Map_Data_Pu() {
  424. //验证登录 User_is, User_r
  425. //token := c.Ctx.Request.Header.Get("user_tokey")
  426. //User_r, User_is := Account.Verification_Admin(token, "")
  427. //if !User_is {
  428. // c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  429. // c.ServeJSON()
  430. // return
  431. //}
  432. type RequestBody struct {
  433. User_tokey string
  434. T_source int
  435. T_task_id string
  436. T_VerifyTemplate_id string
  437. VerifyTemplateMapData []VerifyTemplate.VerifyTemplateMapData_R
  438. }
  439. var body RequestBody
  440. data := c.Ctx.Input.RequestBody
  441. err := json.Unmarshal(data, &body)
  442. if err != nil {
  443. c.Data["json"] = lib.JSONS{Code: 202, Msg: "json.Unmarshal is err:" + err.Error()}
  444. c.ServeJSON()
  445. }
  446. User_r, User_is := Account.Verification_Admin(body.User_tokey, "")
  447. if !User_is {
  448. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  449. c.ServeJSON()
  450. return
  451. }
  452. _, is := Task.Read_Task(body.T_task_id)
  453. if !is {
  454. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
  455. c.ServeJSON()
  456. return
  457. }
  458. MapDataList := make([]VerifyTemplate.VerifyTemplateMapData, 0)
  459. for _, v := range body.VerifyTemplateMapData {
  460. val := VerifyTemplate.VerifyTemplateMapData{
  461. T_source: v.T_source,
  462. T_task_id: body.T_task_id,
  463. T_VerifyTemplate_id: body.T_VerifyTemplate_id,
  464. T_VerifyTemplateMap_id: v.T_VerifyTemplateMap_id,
  465. T_flow_sort: v.T_flow_sort,
  466. T_max_time: v.T_max_time,
  467. T_min_time: v.T_min_time,
  468. T_value: v.T_value,
  469. }
  470. MapDataList = append(MapDataList, val)
  471. }
  472. ids, is := VerifyTemplate.AddOrUpdate_VerifyTemplateMapData(MapDataList)
  473. if !is {
  474. c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
  475. c.ServeJSON()
  476. return
  477. }
  478. System.Add_UserLogs_T(User_r.T_uuid, "验证模版标签数据", "保存", body)
  479. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: ids}
  480. c.ServeJSON()
  481. return
  482. }
  483. func (c *VerifyTemplateController) Map_Data_Copy() {
  484. // 验证登录 User_is, User_r
  485. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  486. if !User_is {
  487. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  488. c.ServeJSON()
  489. return
  490. }
  491. T_source, _ := c.GetInt("T_source")
  492. T_flow, _ := c.GetInt("T_flow")
  493. if T_flow == 0 && T_source == 0 {
  494. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_source Err!"}
  495. c.ServeJSON()
  496. return
  497. }
  498. T_copy_task_id := c.GetString("T_copy_task_id")
  499. copy_task, is := Task.Read_Task(T_copy_task_id)
  500. if !is {
  501. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_copy_task_id 错误!"}
  502. c.ServeJSON()
  503. return
  504. }
  505. T_paste_task_id := c.GetString("T_paste_task_id")
  506. paste_task, is := Task.Read_Task(T_paste_task_id)
  507. if !is {
  508. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_paste_task_id 错误!"}
  509. c.ServeJSON()
  510. return
  511. }
  512. if copy_task.T_VerifyTemplate_id != paste_task.T_VerifyTemplate_id {
  513. c.Data["json"] = lib.JSONS{Code: 202, Msg: "仅支持相同模板间复制!"}
  514. c.ServeJSON()
  515. return
  516. }
  517. list := VerifyTemplate.Read_MapData_List(T_source, T_copy_task_id, copy_task.T_VerifyTemplate_id)
  518. MapDataList := make([]VerifyTemplate.VerifyTemplateMapData, 0)
  519. for _, v := range list {
  520. val := VerifyTemplate.VerifyTemplateMapData{
  521. T_source: T_source,
  522. T_task_id: paste_task.T_task_id,
  523. T_VerifyTemplate_id: paste_task.T_VerifyTemplate_id,
  524. T_VerifyTemplateMap_id: v.T_VerifyTemplateMap_id,
  525. T_flow_sort: v.T_flow_sort,
  526. T_max_time: v.T_max_time,
  527. T_min_time: v.T_min_time,
  528. T_value: v.T_value,
  529. }
  530. MapDataList = append(MapDataList, val)
  531. }
  532. var ids []int64
  533. ids, is = VerifyTemplate.AddOrUpdate_VerifyTemplateMapData(MapDataList)
  534. if !is {
  535. c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
  536. c.ServeJSON()
  537. return
  538. }
  539. System.Add_UserLogs_T(User_r.T_uuid, "验证模版标签数据", "复制", MapDataList)
  540. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: ids}
  541. c.ServeJSON()
  542. return
  543. }
  544. func (c *VerifyTemplateController) Class_List() {
  545. // 验证登录 User_is, User_r
  546. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  547. if !User_is {
  548. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  549. c.ServeJSON()
  550. return
  551. }
  552. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: VerifyTemplate.Read_VerifyTemplateClass_List()}
  553. c.ServeJSON()
  554. return
  555. }
  556. func (c *VerifyTemplateController) Class_Add() {
  557. // 验证登录 User_is, User_r
  558. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  559. if !User_is {
  560. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  561. c.ServeJSON()
  562. return
  563. }
  564. T_name := c.GetString("T_name")
  565. T_fid, _ := c.GetInt("T_fid")
  566. var_ := VerifyTemplate.VerifyTemplateClass{
  567. T_name: T_name,
  568. T_fid: T_fid,
  569. T_State: 1,
  570. }
  571. Id, err := VerifyTemplate.Add_VerifyTemplateClass(var_)
  572. if err != nil {
  573. c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
  574. c.ServeJSON()
  575. return
  576. }
  577. System.Add_UserLogs_T(User_r.T_uuid, "模板分类", "添加", var_)
  578. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
  579. c.ServeJSON()
  580. return
  581. }
  582. func (c *VerifyTemplateController) Class_Up() {
  583. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  584. if !User_is {
  585. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  586. c.ServeJSON()
  587. return
  588. }
  589. T_id, _ := c.GetInt("T_id")
  590. T_name := c.GetString("T_name")
  591. R_VerifyTemplateToolClass, err := VerifyTemplate.Read_VerifyTemplateClass_ById(T_id)
  592. if err != nil {
  593. c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
  594. c.ServeJSON()
  595. return
  596. }
  597. if len(T_name) > 0 {
  598. R_VerifyTemplateToolClass.T_name = T_name
  599. }
  600. if is := VerifyTemplate.Update_VerifyTemplateClass(R_VerifyTemplateToolClass, "T_name"); !is {
  601. c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
  602. c.ServeJSON()
  603. return
  604. }
  605. System.Add_UserLogs_T(User_r.T_uuid, "模板分类", "修改", R_VerifyTemplateToolClass)
  606. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  607. c.ServeJSON()
  608. return
  609. }
  610. func (c *VerifyTemplateController) Class_Del() {
  611. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  612. if !User_is {
  613. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  614. c.ServeJSON()
  615. return
  616. }
  617. T_id, _ := c.GetInt("T_id")
  618. R_VerifyTemplateToolClass, err := VerifyTemplate.Read_VerifyTemplateClass_ById(T_id)
  619. if err != nil {
  620. c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
  621. c.ServeJSON()
  622. return
  623. }
  624. ids := VerifyTemplate.ReadVerifyTemplateClassIds_T_path(R_VerifyTemplateToolClass.T_path)
  625. if is := VerifyTemplate.Delete_VerifyTemplateClass_ByIds(ids); !is {
  626. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  627. c.ServeJSON()
  628. return
  629. }
  630. System.Add_UserLogs(User_r.T_uuid, "模板分类", "删除", strconv.Itoa(T_id))
  631. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  632. c.ServeJSON()
  633. return
  634. }