chart_classify.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. package range_analysis
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_api/controllers"
  5. "eta_gn/eta_api/models"
  6. "eta_gn/eta_api/models/data_manage"
  7. "eta_gn/eta_api/models/system"
  8. "eta_gn/eta_api/services/data"
  9. "eta_gn/eta_api/services/data/data_manage_permission"
  10. "eta_gn/eta_api/utils"
  11. "fmt"
  12. "sort"
  13. "time"
  14. )
  15. type RangeChartClassifyController struct {
  16. controllers.BaseAuthController
  17. }
  18. // @router /chart_classify/list [get]
  19. func (this *RangeChartClassifyController) ChartClassifyList() {
  20. br := new(models.BaseResponse).Init()
  21. defer func() {
  22. if br.ErrMsg == "" {
  23. br.IsSendEmail = false
  24. }
  25. this.Data["json"] = br
  26. this.ServeJSON()
  27. }()
  28. resp := new(data_manage.ChartClassifyListResp)
  29. isShowMe, _ := this.GetBool("IsShowMe")
  30. parentId, _ := this.GetInt("ParentId")
  31. source, _ := this.GetInt("Source", utils.CHART_SOURCE_RANGE_ANALYSIS)
  32. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  33. rootList, err := data_manage.GetChartClassifyByParentId(parentId, utils.CHART_SOURCE_RANGE_ANALYSIS)
  34. if err != nil && !utils.IsErrNoRow(err) {
  35. br.Msg = "获取失败"
  36. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  37. return
  38. }
  39. if len(rootList) > 0 {
  40. permissionClassifyIdList, e := data_manage_permission.GetUserChartClassifyPermissionList(this.SysUser.AdminId, 0)
  41. if e != nil {
  42. br.Msg = "获取失败"
  43. br.ErrMsg = "获取已授权分类id数据失败,Err:" + e.Error()
  44. return
  45. }
  46. for _, v := range rootList {
  47. v.HaveOperaAuth = data_manage_permission.CheckChartClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ChartClassifyId, permissionClassifyIdList)
  48. button := data.GetChartClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
  49. v.Button = button
  50. v.ParentId = parentId
  51. v.Children = make([]*data_manage.ChartClassifyItems, 0)
  52. nodeAll = append(nodeAll, v)
  53. }
  54. }
  55. if parentId > 0 {
  56. currClassify, e := data_manage.GetChartClassifyById(parentId)
  57. if e != nil {
  58. br.Msg = "获取失败"
  59. br.ErrMsg = "获取当前分类信息失败,Err:" + e.Error()
  60. return
  61. }
  62. permissionEdbIdList, permissionClassifyIdList, e := data_manage_permission.GetUserChartAndClassifyPermissionList(this.SysUser.AdminId, 0, 0)
  63. if e != nil {
  64. br.Msg = "获取失败"
  65. br.ErrMsg = "获取所有有权限的指标和分类失败,Err:" + e.Error()
  66. return
  67. }
  68. var adminId int
  69. if isShowMe {
  70. adminId = this.SysUser.AdminId
  71. }
  72. charts, e := data_manage.GetChartInfoBySourceAndParentId(source, parentId, adminId)
  73. if e != nil {
  74. br.Msg = "获取失败"
  75. br.ErrMsg = fmt.Sprintf("获取图表信息失败, Err: %v", e)
  76. return
  77. }
  78. for _, v := range charts {
  79. v.HaveOperaAuth = data_manage_permission.CheckChartPermissionByPermissionIdList(v.IsJoinPermission, currClassify.IsJoinPermission, v.ChartInfoId, v.ChartClassifyId, permissionEdbIdList, permissionClassifyIdList)
  80. button := data.GetChartOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
  81. button.AddButton = false //不管有没有权限,图表都是没有添加按钮的
  82. v.Button = button
  83. v.ParentId = parentId
  84. v.Children = make([]*data_manage.ChartClassifyItems, 0)
  85. nodeAll = append(nodeAll, v)
  86. }
  87. }
  88. if len(nodeAll) > 0 {
  89. sort.Slice(nodeAll, func(i, j int) bool {
  90. return nodeAll[i].Sort < nodeAll[j].Sort
  91. })
  92. }
  93. resp.AllNodes = nodeAll
  94. br.Ret = 200
  95. br.Success = true
  96. br.Msg = "获取成功"
  97. br.Data = resp
  98. }
  99. // @router /chart_classify/items [get]
  100. func (this *RangeChartClassifyController) ChartClassifyItems() {
  101. br := new(models.BaseResponse).Init()
  102. defer func() {
  103. this.Data["json"] = br
  104. this.ServeJSON()
  105. }()
  106. rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_RANGE_ANALYSIS)
  107. if err != nil {
  108. br.Msg = "获取失败"
  109. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  110. return
  111. }
  112. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  113. for k := range rootList {
  114. rootNode := rootList[k]
  115. nodeAll = append(nodeAll, rootNode)
  116. }
  117. resp := new(data_manage.ChartClassifyListResp)
  118. resp.AllNodes = nodeAll
  119. br.Ret = 200
  120. br.Success = true
  121. br.Msg = "获取成功"
  122. br.Data = resp
  123. }
  124. // @router /chart_classify/add [post]
  125. func (this *RangeChartClassifyController) AddChartClassify() {
  126. br := new(models.BaseResponse).Init()
  127. defer func() {
  128. this.Data["json"] = br
  129. this.ServeJSON()
  130. }()
  131. var req data_manage.AddChartClassifyReq
  132. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  133. if err != nil {
  134. br.Msg = "参数解析异常!"
  135. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  136. return
  137. }
  138. if req.ChartClassifyName == "" {
  139. br.Msg = "请输入分类名称"
  140. br.IsSendEmail = false
  141. return
  142. }
  143. if req.ParentId < 0 {
  144. br.Msg = "参数错误"
  145. br.IsSendEmail = false
  146. return
  147. }
  148. _, err, errMsg, isSendEmail := data.AddChartClassify(req.ChartClassifyName, req.ParentId, req.Level, utils.CHART_SOURCE_RANGE_ANALYSIS, this.Lang, this.SysUser)
  149. if err != nil {
  150. br.Msg = errMsg
  151. br.ErrMsg = "添加分类失败,Err:" + err.Error()
  152. br.IsSendEmail = isSendEmail
  153. return
  154. }
  155. br.Ret = 200
  156. br.Msg = "添加成功"
  157. br.Success = true
  158. }
  159. // @router /chart_classify/edit [post]
  160. func (this *RangeChartClassifyController) EditChartClassify() {
  161. br := new(models.BaseResponse).Init()
  162. defer func() {
  163. this.Data["json"] = br
  164. this.ServeJSON()
  165. }()
  166. var req data_manage.EditChartClassifyReq
  167. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  168. if err != nil {
  169. br.Msg = "参数解析异常!"
  170. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  171. return
  172. }
  173. if req.ChartClassifyName == "" {
  174. br.Msg = "请输入分类名称"
  175. br.IsSendEmail = false
  176. return
  177. }
  178. if req.ChartClassifyId <= 0 {
  179. br.Msg = "参数错误"
  180. br.IsSendEmail = false
  181. return
  182. }
  183. _, err, errMsg, isSendEmail := data.EditChartClassify(req.ChartClassifyId, utils.CHART_SOURCE_RANGE_ANALYSIS, req.ChartClassifyName, this.Lang, this.SysUser)
  184. if err != nil {
  185. br.Msg = errMsg
  186. br.ErrMsg = "保存分类失败,Err:" + err.Error()
  187. br.IsSendEmail = isSendEmail
  188. return
  189. }
  190. br.Ret = 200
  191. br.Msg = "修改成功"
  192. br.Success = true
  193. br.IsAddLog = true
  194. }
  195. // @router /chart_classify/delete/check [post]
  196. func (this *RangeChartClassifyController) DeleteChartClassifyCheck() {
  197. br := new(models.BaseResponse).Init()
  198. defer func() {
  199. this.Data["json"] = br
  200. this.ServeJSON()
  201. }()
  202. var req data_manage.ChartClassifyDeleteCheckReq
  203. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  204. if err != nil {
  205. br.Msg = "参数解析异常!"
  206. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  207. return
  208. }
  209. if req.ChartClassifyId < 0 && req.ChartInfoId <= 0 {
  210. br.Msg = "参数错误"
  211. br.IsSendEmail = false
  212. return
  213. }
  214. var deleteStatus int
  215. var tipsMsg string
  216. childIds := make([]int, 0)
  217. if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
  218. classifyAll, err := data_manage.GetChartClassifyAllBySource(utils.CHART_SOURCE_RANGE_ANALYSIS)
  219. if err != nil {
  220. br.Msg = "删除失败"
  221. br.ErrMsg = "获取分类数据失败,Err:" + err.Error()
  222. return
  223. }
  224. classifyAllMap := make(map[int]*data_manage.ChartClassifyItems)
  225. for _, v := range classifyAll {
  226. classifyAllMap[v.ChartClassifyId] = v
  227. }
  228. data.GetChartClassifyChildIds(req.ChartClassifyId, classifyAllMap, &childIds)
  229. condition := ``
  230. pars := make([]interface{}, 0)
  231. if len(childIds) > 0 {
  232. ids := utils.IntArr2joinString(childIds, ",")
  233. condition = ` AND chart_classify_id IN (` + ids + `) `
  234. } else {
  235. condition = ` AND chart_classify_id = ? `
  236. pars = append(pars, req.ChartClassifyId)
  237. }
  238. count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
  239. if err != nil {
  240. br.Msg = "判断图表名称是否存在失败"
  241. br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
  242. return
  243. }
  244. if count > 0 {
  245. deleteStatus = 1
  246. tipsMsg = "该分类下关联图表不可删除"
  247. }
  248. }
  249. if deleteStatus != 1 && req.ChartInfoId == 0 {
  250. if len(childIds) > 0 {
  251. deleteStatus = 2
  252. tipsMsg = "确认删除当前目录及包含的子目录吗"
  253. }
  254. }
  255. if deleteStatus == 0 {
  256. tipsMsg = "可删除,进行删除操作"
  257. }
  258. resp := new(data_manage.ChartClassifyDeleteCheckResp)
  259. resp.DeleteStatus = deleteStatus
  260. resp.TipsMsg = tipsMsg
  261. br.Ret = 200
  262. br.Msg = "检测成功"
  263. br.Success = true
  264. br.Data = resp
  265. }
  266. // @router /chart_classify/delete [post]
  267. func (this *RangeChartClassifyController) DeleteChartClassify() {
  268. br := new(models.BaseResponse).Init()
  269. defer func() {
  270. this.Data["json"] = br
  271. this.ServeJSON()
  272. }()
  273. sysUser := this.SysUser
  274. if sysUser == nil {
  275. br.Msg = "请登录"
  276. br.ErrMsg = "请登录,SysUser Is Empty"
  277. br.Ret = 408
  278. return
  279. }
  280. var req data_manage.DeleteChartClassifyReq
  281. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  282. if err != nil {
  283. br.Msg = "参数解析异常!"
  284. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  285. return
  286. }
  287. if req.ChartClassifyId < 0 && req.ChartInfoId <= 0 {
  288. br.Msg = "参数错误"
  289. br.IsSendEmail = false
  290. return
  291. }
  292. if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
  293. childIds := make([]int, 0)
  294. classifyAll, err := data_manage.GetChartClassifyAllBySource(utils.CHART_SOURCE_RANGE_ANALYSIS)
  295. if err != nil {
  296. br.Msg = "删除失败"
  297. br.ErrMsg = "获取分类数据失败,Err:" + err.Error()
  298. return
  299. }
  300. classifyAllMap := make(map[int]*data_manage.ChartClassifyItems)
  301. for _, v := range classifyAll {
  302. classifyAllMap[v.ChartClassifyId] = v
  303. }
  304. data.GetChartClassifyChildIds(req.ChartClassifyId, classifyAllMap, &childIds)
  305. condition := ``
  306. pars := make([]interface{}, 0)
  307. if len(childIds) > 0 {
  308. ids := utils.IntArr2joinString(childIds, ",")
  309. condition = ` AND chart_classify_id IN (` + ids + `) `
  310. } else {
  311. condition = ` AND chart_classify_id = ? `
  312. pars = append(pars, req.ChartClassifyId)
  313. }
  314. count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
  315. if err != nil {
  316. br.Msg = "判断图表名称是否存在失败"
  317. br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
  318. return
  319. }
  320. if count > 0 {
  321. br.Msg = "该目录下存在关联指标,不可删除"
  322. br.IsSendEmail = false
  323. return
  324. }
  325. delIds := append(childIds, req.ChartClassifyId)
  326. err = data_manage.DeleteChartClassifyByIds(delIds)
  327. if err != nil {
  328. br.Msg = "删除失败"
  329. br.ErrMsg = "删除失败,Err:" + err.Error()
  330. return
  331. }
  332. }
  333. resp := new(data_manage.AddChartInfoResp)
  334. if req.ChartInfoId > 0 {
  335. chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
  336. if err != nil {
  337. if utils.IsErrNoRow(err) {
  338. br.Msg = "图表已删除,请刷新页面"
  339. br.ErrMsg = "指标不存在,Err:" + err.Error()
  340. return
  341. } else {
  342. br.Msg = "删除失败"
  343. br.ErrMsg = "删除失败,获取指标信息失败,Err:" + err.Error()
  344. return
  345. }
  346. }
  347. if chartInfo == nil {
  348. br.Msg = "图表已删除,请刷新页面"
  349. return
  350. }
  351. ok := data.CheckOpChartPermission(sysUser, chartInfo.SysUserId, true)
  352. if !ok {
  353. br.Msg = "没有该图表的操作权限"
  354. br.ErrMsg = "没有该图表的操作权限"
  355. return
  356. }
  357. var myCond string
  358. var myPars []interface{}
  359. myCond += ` AND a.chart_info_id = ? `
  360. myPars = append(myPars, chartInfo.ChartInfoId)
  361. myCharts, e := data_manage.GetMyChartListGroupByCharyInfoIdAndAdminIdByCondition(myCond, myPars)
  362. if e != nil {
  363. br.Msg = "删除失败"
  364. br.ErrMsg = "获取引用图表的MyChats失败, Err: " + e.Error()
  365. return
  366. }
  367. myIds := make([]int, 0)
  368. for _, m := range myCharts {
  369. myIds = append(myIds, m.MyChartId)
  370. }
  371. source := chartInfo.Source // 区间分析图表(滚动相关性)
  372. err = data_manage.DeleteChartInfoAndData(chartInfo.ChartInfoId)
  373. if err != nil {
  374. br.Msg = "删除失败"
  375. br.ErrMsg = "删除失败,Err:" + err.Error()
  376. return
  377. }
  378. chartSeriesOb := new(data_manage.FactorEdbSeriesChartMapping)
  379. seriesMappingItem, e := chartSeriesOb.GetItemByChartInfoId(chartInfo.ChartInfoId)
  380. if e != nil {
  381. if utils.IsErrNoRow(e) {
  382. } else {
  383. br.Msg = "删除失败"
  384. br.ErrMsg = "获取图表关联失败, Err: " + e.Error()
  385. return
  386. }
  387. } else {
  388. factorSeriesOb := new(data_manage.FactorEdbSeries)
  389. e = factorSeriesOb.RemoveSeriesAndMappingByFactorEdbSeriesId(seriesMappingItem)
  390. if e != nil {
  391. br.Msg = "删除失败"
  392. br.ErrMsg = "获取图表关联失败, Err: " + e.Error()
  393. return
  394. }
  395. }
  396. {
  397. go data.EsDeleteChartInfo(chartInfo.ChartInfoId)
  398. go data.EsDeleteMyChartInfoByMyChartIds(myIds)
  399. }
  400. multiConfig, e := data_manage.GetMultipleGraphConfigChartMappingByChartId(chartInfo.ChartInfoId)
  401. if e != nil && !utils.IsErrNoRow(e) {
  402. br.Msg = "删除失败"
  403. br.ErrMsg = "获取图表关联配置失败, Err: " + e.Error()
  404. return
  405. }
  406. if multiConfig != nil { // 删除配置关联指标数据
  407. e = data_manage.DeleteMultipleGraphConfigByChartInfoId(chartInfo.ChartInfoId, multiConfig.MultipleGraphConfigId, utils.CHART_SOURCE_RANGE_ANALYSIS)
  408. if e != nil {
  409. br.Msg = "删除失败"
  410. br.ErrMsg = "删除图表关联配置失败, Err: " + e.Error()
  411. return
  412. }
  413. }
  414. var condition string
  415. var pars []interface{}
  416. condition += " AND chart_classify_id=? AND source = ? "
  417. pars = append(pars, chartInfo.ChartClassifyId, source)
  418. condition += " AND chart_info_id>? ORDER BY create_time ASC LIMIT 1 "
  419. pars = append(pars, req.ChartInfoId)
  420. nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
  421. if err != nil && !utils.IsErrNoRow(err) {
  422. br.Msg = "删除失败"
  423. br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
  424. return
  425. }
  426. if nextItem != nil {
  427. resp.UniqueCode = nextItem.UniqueCode
  428. resp.ChartInfoId = nextItem.ChartInfoId
  429. } else {
  430. var condition string
  431. var pars []interface{}
  432. condition += " AND level=1 "
  433. condition += " AND chart_classify_id>? ORDER BY chart_classify_id ASC LIMIT 1 "
  434. pars = append(pars, chartInfo.ChartClassifyId)
  435. classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
  436. if err != nil && !utils.IsErrNoRow(err) {
  437. br.Msg = "删除失败"
  438. br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
  439. return
  440. }
  441. if classifyItem != nil {
  442. nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
  443. if err != nil && !utils.IsErrNoRow(err) {
  444. br.Msg = "删除失败"
  445. br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
  446. return
  447. }
  448. if nextItem != nil {
  449. resp.UniqueCode = nextItem.UniqueCode
  450. resp.ChartInfoId = nextItem.ChartInfoId
  451. }
  452. }
  453. }
  454. {
  455. chartLog := new(data_manage.ChartInfoLog)
  456. chartLog.ChartName = chartInfo.ChartName
  457. chartLog.ChartInfoId = req.ChartInfoId
  458. chartLog.ChartClassifyId = chartInfo.ChartClassifyId
  459. chartLog.SysUserId = sysUser.AdminId
  460. chartLog.SysUserRealName = sysUser.RealName
  461. chartLog.UniqueCode = chartInfo.UniqueCode
  462. chartLog.CreateTime = time.Now()
  463. chartLog.Content = string(this.Ctx.Input.RequestBody)
  464. chartLog.Status = "删除图表"
  465. chartLog.Method = this.Ctx.Input.URI()
  466. go data_manage.AddChartInfoLog(chartLog)
  467. }
  468. }
  469. br.Ret = 200
  470. br.Msg = "删除成功"
  471. br.Success = true
  472. br.Data = resp
  473. br.IsAddLog = true
  474. }
  475. // @router /chart_classify/move [post]
  476. func (this *RangeChartClassifyController) ChartClassifyMove() {
  477. br := new(models.BaseResponse).Init()
  478. defer func() {
  479. if br.ErrMsg == "" {
  480. br.IsSendEmail = false
  481. }
  482. this.Data["json"] = br
  483. this.ServeJSON()
  484. }()
  485. sysUser := this.SysUser
  486. if sysUser == nil {
  487. br.Msg = "请登录"
  488. br.ErrMsg = "请登录,SysUser Is Empty"
  489. br.Ret = 408
  490. return
  491. }
  492. var req data_manage.MoveChartClassifyReq
  493. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  494. if err != nil {
  495. br.Msg = "参数解析异常!"
  496. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  497. return
  498. }
  499. if req.ClassifyId <= 0 && req.ChartInfoId <= 0 {
  500. br.Msg = "参数错误"
  501. br.ErrMsg = "请选择拖动目标,分类目录或者指标"
  502. return
  503. }
  504. err, errMsg := data.MoveChartClassify(req, sysUser, utils.CHART_SOURCE_RANGE_ANALYSIS)
  505. if errMsg != `` {
  506. br.Msg = errMsg
  507. br.ErrMsg = errMsg
  508. if err != nil {
  509. br.ErrMsg = err.Error()
  510. } else {
  511. br.IsSendEmail = false
  512. }
  513. return
  514. }
  515. br.Ret = 200
  516. br.Success = true
  517. br.Msg = "移动成功"
  518. }
  519. // @router /chart_classify/tree [get]
  520. func (this *RangeChartClassifyController) ClassifyTree() {
  521. br := new(models.BaseResponse).Init()
  522. defer func() {
  523. if br.ErrMsg == "" {
  524. br.IsSendEmail = false
  525. }
  526. this.Data["json"] = br
  527. this.ServeJSON()
  528. }()
  529. allList, err := data_manage.GetChartClassifyAllBySource(utils.CHART_SOURCE_RANGE_ANALYSIS)
  530. if err != nil {
  531. br.Msg = "获取失败"
  532. br.ErrMsg = "获取所有分类失败, Err:" + err.Error()
  533. return
  534. }
  535. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  536. if len(allList) > 0 {
  537. permissionClassifyIdList, e := data_manage_permission.GetUserChartClassifyPermissionList(this.SysUser.AdminId, 0)
  538. if e != nil {
  539. br.Msg = "获取失败"
  540. br.ErrMsg = "获取已授权分类id数据失败,Err:" + e.Error()
  541. return
  542. }
  543. for k, v := range allList {
  544. v.HaveOperaAuth = data_manage_permission.CheckChartClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ChartClassifyId, permissionClassifyIdList)
  545. button := data.GetChartClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
  546. allList[k].Button = button
  547. }
  548. nodeAll = data.GetChartClassifyTreeRecursive(allList, 0)
  549. sort.Slice(nodeAll, func(i, j int) bool {
  550. return nodeAll[i].Sort < nodeAll[j].Sort
  551. })
  552. }
  553. language := `CN`
  554. {
  555. configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.ChartLanguageVar)
  556. if configDetail != nil {
  557. language = configDetail.ConfigValue
  558. } else {
  559. configDetail, _ = system.GetDefaultConfigDetailByCode(system.ChartLanguageVar)
  560. if configDetail != nil {
  561. language = configDetail.ConfigValue
  562. }
  563. }
  564. }
  565. canOpClassify := true
  566. button := data.GetChartClassifyOpButton(this.SysUser, 0, true)
  567. if !button.AddButton {
  568. canOpClassify = false
  569. }
  570. resp := new(data_manage.ChartClassifyListResp)
  571. resp.AllNodes = nodeAll
  572. resp.Language = language
  573. resp.CanOpClassify = canOpClassify
  574. br.Ret = 200
  575. br.Success = true
  576. br.Msg = "获取成功"
  577. br.Data = resp
  578. }