InfoTemplate.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. package controllers
  2. import (
  3. "ColdVerify_server/conf"
  4. "ColdVerify_server/lib"
  5. "ColdVerify_server/models/Account"
  6. "ColdVerify_server/models/InfoCollection"
  7. "ColdVerify_server/models/System"
  8. "encoding/json"
  9. beego "github.com/beego/beego/v2/server/web"
  10. "math"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type InfoTemplateController struct {
  16. beego.Controller
  17. User_r Account.Admin // 登陆的用户
  18. }
  19. func (c *InfoTemplateController) Prepare() {
  20. GetCookie := c.Ctx.GetCookie("User_tokey")
  21. GetString := c.GetString("User_tokey")
  22. // 此接口单独从body获取token验证,此处不做验证
  23. if strings.Contains(c.Ctx.Request.URL.Path, "/InfoTemplateMapData/Pu") {
  24. return
  25. }
  26. // 验证登录 User_is, User_r
  27. User_r, User_is := Account.Verification_Admin(GetCookie, GetString)
  28. if !User_is {
  29. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  30. c.ServeJSON()
  31. return
  32. }
  33. // 经销商只能访问列表接口,不能操作
  34. if len(User_r.T_Distributor_id) > 0 {
  35. checkUrl := []string{"Add", "Up", "Del", "Copy"}
  36. for _, v := range checkUrl {
  37. if strings.Contains(c.Ctx.Request.URL.Path, v) {
  38. c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有操作权限!"}
  39. c.ServeJSON()
  40. return
  41. }
  42. }
  43. }
  44. c.User_r = User_r
  45. }
  46. // 列表 -
  47. func (c *InfoTemplateController) List() {
  48. var r_jsons lib.R_JSONS
  49. page, _ := c.GetInt("page")
  50. if page < 1 {
  51. page = 1
  52. }
  53. page_z, _ := c.GetInt("page_z")
  54. if page_z < 1 {
  55. page_z = conf.Page_size
  56. }
  57. T_class, _ := c.GetInt("T_class")
  58. if T_class <= 0 {
  59. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class Err!"}
  60. c.ServeJSON()
  61. return
  62. }
  63. T_name := c.GetString("T_name")
  64. var cnt int64
  65. List, cnt := InfoCollection.Read_InfoTemplate_List(T_class, T_name, page, page_z)
  66. page_size := math.Ceil(float64(cnt) / float64(page_z))
  67. r_jsons.List = List
  68. r_jsons.Page = page
  69. r_jsons.Page_size = int(page_size)
  70. r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  71. r_jsons.Num = int(cnt)
  72. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  73. c.ServeJSON()
  74. return
  75. }
  76. // 添加-
  77. func (c *InfoTemplateController) Add() {
  78. T_name := c.GetString("T_name")
  79. T_sort, _ := c.GetInt("T_sort")
  80. T_class, _ := c.GetInt("T_class")
  81. var_ := InfoCollection.InfoTemplate{
  82. T_class: T_class,
  83. T_name: T_name,
  84. T_sort: T_sort,
  85. }
  86. Id, is := InfoCollection.Add_InfoTemplate(var_)
  87. if !is {
  88. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  89. c.ServeJSON()
  90. return
  91. }
  92. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集信息采集模版", "添加", var_)
  93. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
  94. c.ServeJSON()
  95. return
  96. }
  97. // 修改-
  98. func (c *InfoTemplateController) Up() {
  99. T_name := c.GetString("T_name")
  100. T_sort, T_sort_err := c.GetInt("T_sort")
  101. T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
  102. r, is := InfoCollection.Read_InfoTemplate(T_InfoTemplate_id)
  103. if !is {
  104. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  105. c.ServeJSON()
  106. return
  107. }
  108. // .......
  109. if len(T_name) > 0 {
  110. r.T_name = T_name
  111. }
  112. if T_sort_err == nil {
  113. r.T_sort = T_sort
  114. }
  115. // .......
  116. if !InfoCollection.Update_InfoTemplate(r, "T_name", "T_sort") {
  117. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  118. c.ServeJSON()
  119. return
  120. }
  121. System.Add_UserLogs_T(c.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 *InfoTemplateController) Del() {
  128. T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
  129. r, is := InfoCollection.Read_InfoTemplate(T_InfoTemplate_id)
  130. if !is {
  131. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  132. c.ServeJSON()
  133. return
  134. }
  135. if !InfoCollection.Delete_InfoTemplate(r) {
  136. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  137. c.ServeJSON()
  138. return
  139. }
  140. mapList, _ := InfoCollection.Read_InfoTemplateMap_List(T_InfoTemplate_id, 0, 0)
  141. for _, v := range mapList {
  142. if vtm, is := InfoCollection.Read_InfoTemplateMap(v.T_id); is {
  143. InfoCollection.Delete_InfoTemplateMap(vtm)
  144. }
  145. }
  146. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集信息采集模版", "删除", r)
  147. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  148. c.ServeJSON()
  149. return
  150. }
  151. // 复制-
  152. func (c *InfoTemplateController) Copy() {
  153. T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
  154. T_name := c.GetString("T_name")
  155. r, is := InfoCollection.Read_InfoTemplate(T_InfoTemplate_id)
  156. if !is {
  157. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  158. c.ServeJSON()
  159. return
  160. }
  161. var_ := InfoCollection.InfoTemplate{
  162. T_class: r.T_class,
  163. T_name: T_name,
  164. T_sort: r.T_sort,
  165. }
  166. new_id, is := InfoCollection.Add_InfoTemplate(var_)
  167. if !is {
  168. c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制失败!"}
  169. c.ServeJSON()
  170. return
  171. }
  172. mapList, _ := InfoCollection.Read_InfoTemplateMap_List(T_InfoTemplate_id, 0, 0)
  173. tempMap := make(map[string]struct{})
  174. idList := make([]string, len(mapList))
  175. // 生成mapList长度的T_id
  176. for i := 0; i < len(mapList); i++ {
  177. // 生成编号
  178. rand_x := 0
  179. T_id := ""
  180. for true {
  181. T_id = lib.GetRandstring(4, "", int64(rand_x))
  182. _, is = InfoCollection.Read_InfoTemplateMap(T_id)
  183. if !is {
  184. if _, ok := tempMap[T_id]; !ok {
  185. break
  186. }
  187. }
  188. rand_x += 1
  189. }
  190. tempMap[T_id] = struct{}{}
  191. idList[i] = T_id
  192. }
  193. mapInsertList := make([]InfoCollection.InfoTemplateMap, 0)
  194. for i, v := range mapList {
  195. vtm := InfoCollection.InfoTemplateMap{
  196. T_id: idList[i],
  197. T_InfoTemplate_id: new_id,
  198. T_name: v.T_name,
  199. T_text: v.T_text,
  200. T_label: v.T_label,
  201. T_sort: v.T_sort,
  202. }
  203. mapInsertList = append(mapInsertList, vtm)
  204. }
  205. _, is = InfoCollection.Add_InfoTemplateMapMulti(mapInsertList)
  206. if !is {
  207. c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制失败!"}
  208. c.ServeJSON()
  209. return
  210. }
  211. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集信息采集模版", "复制", var_)
  212. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: new_id}
  213. c.ServeJSON()
  214. return
  215. }
  216. /// -----------------------------------------------------------------------------
  217. // 标签列表 -
  218. func (c *InfoTemplateController) Map_List() {
  219. // 验证登录 User_is, User_r
  220. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  221. if !User_is {
  222. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  223. c.ServeJSON()
  224. return
  225. }
  226. var r_jsons lib.R_JSONS
  227. T_sort, _ := c.GetInt("T_sort") // 排序
  228. T_flow_sort, _ := c.GetInt("T_flow_sort") // 验证流程排序
  229. T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
  230. var cnt int64
  231. List, cnt := InfoCollection.Read_InfoTemplateMap_List(T_InfoTemplate_id, T_sort, T_flow_sort)
  232. r_jsons.List = List
  233. r_jsons.Num = int(cnt)
  234. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  235. c.ServeJSON()
  236. return
  237. }
  238. // 标签添加-
  239. func (c *InfoTemplateController) Map_Add() {
  240. T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
  241. T_name := c.GetString("T_name")
  242. T_text := c.GetString("T_text")
  243. T_label, _ := c.GetInt("T_label")
  244. T_sort, _ := c.GetInt("T_sort")
  245. var_ := InfoCollection.InfoTemplateMap{
  246. T_InfoTemplate_id: T_InfoTemplate_id,
  247. T_name: T_name,
  248. T_text: T_text,
  249. T_label: T_label,
  250. T_sort: T_sort,
  251. }
  252. Id, is := InfoCollection.Add_InfoTemplateMap(var_)
  253. if !is {
  254. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  255. c.ServeJSON()
  256. return
  257. }
  258. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集信息采集模版标签", "添加", var_)
  259. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
  260. c.ServeJSON()
  261. return
  262. }
  263. // 标签修改-
  264. func (c *InfoTemplateController) Map_Up() {
  265. T_name := c.GetString("T_name")
  266. T_text := c.GetString("T_text")
  267. T_label, T_label_err := c.GetInt("T_label")
  268. T_sort, T_sort_err := c.GetInt("T_sort")
  269. T_id := c.GetString("T_id")
  270. r, is := InfoCollection.Read_InfoTemplateMap(T_id)
  271. if !is {
  272. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  273. c.ServeJSON()
  274. return
  275. }
  276. // .......
  277. if len(T_name) > 0 {
  278. r.T_name = T_name
  279. }
  280. if len(T_text) > 0 {
  281. r.T_text = T_text
  282. }
  283. if T_label_err == nil {
  284. r.T_label = T_label
  285. }
  286. if T_sort_err == nil {
  287. r.T_sort = T_sort
  288. }
  289. if !InfoCollection.Update_InfoTemplateMap(r, "T_name", "T_label", "T_text", "T_sort") {
  290. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  291. c.ServeJSON()
  292. return
  293. }
  294. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集信息采集模版标签", "修改", r)
  295. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  296. c.ServeJSON()
  297. return
  298. }
  299. // 标签删除-
  300. func (c *InfoTemplateController) Map_Del() {
  301. T_id := c.GetString("T_id")
  302. if r, is := InfoCollection.Read_InfoTemplateMap(T_id); is {
  303. if !InfoCollection.Delete_InfoTemplateMap(r) {
  304. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  305. c.ServeJSON()
  306. return
  307. }
  308. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集信息采集模版标签", "删除", r)
  309. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  310. c.ServeJSON()
  311. return
  312. }
  313. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  314. c.ServeJSON()
  315. return
  316. }
  317. /// -----------------------------------------------------------------------------
  318. // 标签数据列表 -
  319. func (c *InfoTemplateController) Map_Data_List() {
  320. T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
  321. T_InfoCollection_id := c.GetString("T_InfoCollection_id")
  322. _, is := InfoCollection.Read_InfoCollection(T_InfoCollection_id)
  323. if !is {
  324. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_InfoCollection_id 错误!"}
  325. c.ServeJSON()
  326. return
  327. }
  328. Map_List := InfoCollection.Read_InfoTemplateMap_List_For_Data(T_InfoTemplate_id)
  329. Data := InfoCollection.Read_InfoTemplateMapData_List(T_InfoCollection_id, T_InfoTemplate_id, Map_List)
  330. type JSONS struct {
  331. //必须的大写开头
  332. Code int16
  333. Msg string
  334. Data interface{} // 泛型
  335. }
  336. c.Data["json"] = JSONS{Code: 200, Msg: "ok!", Data: Data}
  337. c.ServeJSON()
  338. return
  339. }
  340. // 添加标签数据
  341. func (c *InfoTemplateController) Map_Data_Pu() {
  342. //验证登录 User_is, User_r
  343. type RequestBody struct {
  344. User_tokey string
  345. T_InfoCollection_id string
  346. T_InfoTemplate_id string
  347. InfoTemplateMapData []InfoCollection.InfoTemplateMapData_R
  348. }
  349. var body RequestBody
  350. data := c.Ctx.Input.RequestBody
  351. err := json.Unmarshal(data, &body)
  352. if err != nil {
  353. c.Data["json"] = lib.JSONS{Code: 202, Msg: "json返序列化失败:" + err.Error()}
  354. c.ServeJSON()
  355. }
  356. User_r, User_is := Account.Verification_Admin(body.User_tokey, "")
  357. if !User_is {
  358. System.Add_UserLogs_T(User_r.T_uuid, "信息采集模版标签数据", "未登录-保存", body)
  359. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  360. c.ServeJSON()
  361. return
  362. }
  363. infoCollection, is := InfoCollection.Read_InfoCollection(body.T_InfoCollection_id)
  364. if !is {
  365. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_InfoCollection_id 错误!"}
  366. c.ServeJSON()
  367. return
  368. }
  369. // 如果信息采集开始时间为空,则设置为当前时间
  370. if len(infoCollection.T_start_time) == 0 {
  371. infoCollection.T_start_time = time.Now().Format("2006-01-02 15:04:05")
  372. if !InfoCollection.Update_InfoCollection(infoCollection, "T_start_time") {
  373. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改信息采集开始时间失败!"}
  374. c.ServeJSON()
  375. return
  376. }
  377. }
  378. MapDataList := make([]InfoCollection.InfoTemplateMapData, 0)
  379. for _, v := range body.InfoTemplateMapData {
  380. val := InfoCollection.InfoTemplateMapData{
  381. T_InfoCollection_id: body.T_InfoCollection_id,
  382. T_InfoTemplate_id: body.T_InfoTemplate_id,
  383. T_InfoTemplateMap_id: v.T_InfoTemplateMap_id,
  384. T_value: v.T_value,
  385. }
  386. MapDataList = append(MapDataList, val)
  387. }
  388. ids, is := InfoCollection.AddOrUpdate_InfoTemplateMapData(MapDataList)
  389. if !is {
  390. c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
  391. c.ServeJSON()
  392. return
  393. }
  394. System.Add_UserLogs_T(User_r.T_uuid, "信息采集模版标签数据", "保存", body)
  395. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: ids}
  396. c.ServeJSON()
  397. return
  398. }
  399. func (c *InfoTemplateController) Map_Data_Copy() {
  400. T_copy_InfoCollection_id := c.GetString("T_copy_InfoCollection_id")
  401. copy_InfoCollection, is := InfoCollection.Read_InfoCollection(T_copy_InfoCollection_id)
  402. if !is {
  403. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_copy_InfoCollection_id 错误!"}
  404. c.ServeJSON()
  405. return
  406. }
  407. T_paste_InfoCollection_id := c.GetString("T_paste_InfoCollection_id")
  408. paste_InfoCollection, is := InfoCollection.Read_InfoCollection(T_paste_InfoCollection_id)
  409. if !is {
  410. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_paste_InfoCollection_id 错误!"}
  411. c.ServeJSON()
  412. return
  413. }
  414. if copy_InfoCollection.T_InfoTemplate_id != paste_InfoCollection.T_InfoTemplate_id {
  415. c.Data["json"] = lib.JSONS{Code: 202, Msg: "仅支持相同信息采集模版间复制!"}
  416. c.ServeJSON()
  417. return
  418. }
  419. list := InfoCollection.Read_MapData_List(T_copy_InfoCollection_id, copy_InfoCollection.T_InfoTemplate_id)
  420. MapDataList := make([]InfoCollection.InfoTemplateMapData, 0)
  421. for _, v := range list {
  422. val := InfoCollection.InfoTemplateMapData{
  423. T_InfoCollection_id: paste_InfoCollection.T_InfoCollection_id,
  424. T_InfoTemplate_id: paste_InfoCollection.T_InfoTemplate_id,
  425. T_InfoTemplateMap_id: v.T_InfoTemplateMap_id,
  426. T_value: v.T_value,
  427. }
  428. MapDataList = append(MapDataList, val)
  429. }
  430. var ids []int64
  431. ids, is = InfoCollection.AddOrUpdate_InfoTemplateMapData(MapDataList)
  432. if !is {
  433. c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
  434. c.ServeJSON()
  435. return
  436. }
  437. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集模版标签数据", "复制", MapDataList)
  438. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: ids}
  439. c.ServeJSON()
  440. return
  441. }
  442. func (c *InfoTemplateController) Class_List() {
  443. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: InfoCollection.Read_InfoTemplateClass_List()}
  444. c.ServeJSON()
  445. return
  446. }
  447. func (c *InfoTemplateController) Class_Add() {
  448. T_name := c.GetString("T_name")
  449. T_fid, _ := c.GetInt("T_fid")
  450. var_ := InfoCollection.InfoTemplateClass{
  451. T_name: T_name,
  452. T_fid: T_fid,
  453. T_State: 1,
  454. }
  455. Id, err := InfoCollection.Add_InfoTemplateClass(var_)
  456. if err != nil {
  457. c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
  458. c.ServeJSON()
  459. return
  460. }
  461. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集模版分类", "添加", var_)
  462. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
  463. c.ServeJSON()
  464. return
  465. }
  466. func (c *InfoTemplateController) Class_Up() {
  467. T_id, _ := c.GetInt("T_id")
  468. T_name := c.GetString("T_name")
  469. R_InfoTemplateToolClass, err := InfoCollection.Read_InfoTemplateClass_ById(T_id)
  470. if err != nil {
  471. c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
  472. c.ServeJSON()
  473. return
  474. }
  475. if len(T_name) > 0 {
  476. R_InfoTemplateToolClass.T_name = T_name
  477. }
  478. if is := InfoCollection.Update_InfoTemplateClass(R_InfoTemplateToolClass, "T_name"); !is {
  479. c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
  480. c.ServeJSON()
  481. return
  482. }
  483. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集模版分类", "修改", R_InfoTemplateToolClass)
  484. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  485. c.ServeJSON()
  486. return
  487. }
  488. func (c *InfoTemplateController) Class_Del() {
  489. T_id, _ := c.GetInt("T_id")
  490. R_InfoTemplateToolClass, err := InfoCollection.Read_InfoTemplateClass_ById(T_id)
  491. if err != nil {
  492. c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
  493. c.ServeJSON()
  494. return
  495. }
  496. ids := InfoCollection.ReadInfoTemplateClassIds_T_path(R_InfoTemplateToolClass.T_path)
  497. if is := InfoCollection.Delete_InfoTemplateClass_ByIds(ids); !is {
  498. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  499. c.ServeJSON()
  500. return
  501. }
  502. System.Add_UserLogs(c.User_r.T_uuid, "信息采集模版分类", "删除", strconv.Itoa(T_id))
  503. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  504. c.ServeJSON()
  505. return
  506. }
  507. // 复制信息采集-分类-标签
  508. func (c *InfoTemplateController) Class_Copy() {
  509. T_id, _ := c.GetInt("T_id") // 要复制的信息采集分类id
  510. T_name := c.GetString("T_name")
  511. // 查询要复制的信息采集分类id
  512. R_InfoTemplateClass, err := InfoCollection.Read_InfoTemplateClass_ById(T_id)
  513. if err != nil {
  514. c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
  515. c.ServeJSON()
  516. return
  517. }
  518. if len(T_name) > 0 && T_name != R_InfoTemplateClass.T_name {
  519. R_InfoTemplateClass.T_name = T_name
  520. } else {
  521. R_InfoTemplateClass.T_name = R_InfoTemplateClass.T_name + "_副本"
  522. }
  523. _, err = InfoCollection.CopyInfoTemplateClassTree(R_InfoTemplateClass.T_path, R_InfoTemplateClass.T_fid, R_InfoTemplateClass.T_name)
  524. if err != nil {
  525. c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制信息采集模版分类失败"}
  526. c.ServeJSON()
  527. return
  528. }
  529. System.Add_UserLogs_T(c.User_r.T_uuid, "信息采集模版分类", "复制", T_id)
  530. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  531. c.ServeJSON()
  532. return
  533. }