VerifyTemplate.go 20 KB

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