chart_classify.go 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. package data_manage
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/controllers"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/data_manage"
  7. "eta/eta_api/models/system"
  8. "eta/eta_api/services/data"
  9. "eta/eta_api/services/data/data_manage_permission"
  10. "eta/eta_api/utils"
  11. "fmt"
  12. "time"
  13. )
  14. // 数据管理-分类模块
  15. type ChartClassifyController struct {
  16. controllers.BaseAuthController
  17. }
  18. //
  19. //// @Title 图表分类列表
  20. //// @Description 图表分类列表接口
  21. //// @Success 200 {object} data_manage.ChartClassifyListResp
  22. //// @router /chart_classify/list [get]
  23. //func (this *ChartClassifyController) ChartClassifyList() {
  24. // br := new(models.BaseResponse).Init()
  25. // defer func() {
  26. // this.Data["json"] = br
  27. // this.ServeJSON()
  28. // }()
  29. // rootList, err := data_manage.GetChartClassifyByParentId(0)
  30. // if err != nil {
  31. // br.Msg = "获取失败"
  32. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  33. // return
  34. // }
  35. //
  36. // classifyAll, err := data_manage.GetChartClassifyAll()
  37. // if err != nil {
  38. // br.Msg = "获取失败"
  39. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  40. // return
  41. // }
  42. //
  43. // nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  44. // for k := range rootList {
  45. // rootNode := rootList[k]
  46. // data.ChartClassifyListMakeTree(classifyAll, rootNode)
  47. // nodeAll = append(nodeAll, rootNode)
  48. // }
  49. // resp := new(data_manage.ChartClassifyListResp)
  50. // resp.AllNodes = nodeAll
  51. // br.Ret = 200
  52. // br.Success = true
  53. // br.Msg = "获取成功"
  54. // br.Data = resp
  55. //}
  56. // ChartClassifyListV2
  57. // @Title 图表分类列表
  58. // @Description 图表分类列表接口
  59. // @Param IsShowMe query bool true "是否只看我的,true、false"
  60. // @Success 200 {object} data_manage.ChartClassifyListResp
  61. // @router /chart_classify/list [get]
  62. func (this *ChartClassifyController) ChartClassifyListV2() {
  63. br := new(models.BaseResponse).Init()
  64. defer func() {
  65. this.Data["json"] = br
  66. this.ServeJSON()
  67. }()
  68. resp := new(data_manage.ChartClassifyListResp)
  69. // 获取当前账号的不可见指标
  70. noPermissionChartIdMap := make(map[int]bool)
  71. {
  72. obj := data_manage.EdbInfoNoPermissionAdmin{}
  73. confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
  74. if err != nil && err.Error() != utils.ErrNoRow() {
  75. br.Msg = "获取失败"
  76. br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
  77. return
  78. }
  79. for _, v := range confList {
  80. noPermissionChartIdMap[v.ChartInfoId] = true
  81. }
  82. }
  83. isShowMe, _ := this.GetBool("IsShowMe")
  84. if isShowMe {
  85. errMsg, err := getChartClassifyListForMe(*this.SysUser, resp)
  86. if err != nil {
  87. br.Msg = errMsg
  88. br.ErrMsg = err.Error()
  89. return
  90. }
  91. // 移除没有权限的图表
  92. allNodes := data.HandleNoPermissionChart(resp.AllNodes, noPermissionChartIdMap, this.SysUser.AdminId)
  93. resp.AllNodes = allNodes
  94. br.Ret = 200
  95. br.Success = true
  96. br.Msg = "获取成功"
  97. br.Data = resp
  98. fmt.Println("source my classify")
  99. return
  100. }
  101. //判断是否存在缓存,如果存在缓存,那么直接从缓存中获取
  102. key := utils.CACHE_CHART_CLASSIFY
  103. if utils.Re == nil {
  104. if utils.Re == nil && utils.Rc.IsExist(key) {
  105. if redisData, err1 := utils.Rc.RedisBytes(key); err1 == nil {
  106. err := json.Unmarshal(redisData, &resp)
  107. if err == nil && resp != nil {
  108. // 移除没有权限的图表
  109. allNodes := data.HandleNoPermissionChart(resp.AllNodes, noPermissionChartIdMap, this.SysUser.AdminId)
  110. resp.AllNodes = allNodes
  111. br.Ret = 200
  112. br.Success = true
  113. br.Msg = "获取成功"
  114. br.Data = resp
  115. fmt.Println("source redis")
  116. return
  117. }
  118. }
  119. }
  120. }
  121. rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_DEFAULT)
  122. if err != nil && err.Error() != utils.ErrNoRow() {
  123. br.Msg = "获取失败"
  124. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  125. return
  126. }
  127. classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_DEFAULT)
  128. if err != nil && err.Error() != utils.ErrNoRow() {
  129. br.Msg = "获取失败"
  130. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  131. return
  132. }
  133. allChartInfo, err := data_manage.GetChartInfoAll([]int{utils.CHART_SOURCE_DEFAULT})
  134. if err != nil && err.Error() != utils.ErrNoRow() {
  135. br.Msg = "获取失败"
  136. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  137. return
  138. }
  139. chartInfoMap := make(map[int][]*data_manage.ChartClassifyItems)
  140. for _, v := range allChartInfo {
  141. chartInfoMap[v.ChartClassifyId] = append(chartInfoMap[v.ChartClassifyId], v)
  142. }
  143. rootChildMap := make(map[int][]*data_manage.ChartClassifyItems)
  144. for _, v := range classifyAll {
  145. rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
  146. if existItems, ok := chartInfoMap[v.ChartClassifyId]; ok {
  147. v.Children = existItems
  148. } else {
  149. items := make([]*data_manage.ChartClassifyItems, 0)
  150. v.Children = items
  151. }
  152. }
  153. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  154. for _, v := range rootList {
  155. if existItems, ok := rootChildMap[v.ChartClassifyId]; ok {
  156. v.Children = existItems
  157. } else {
  158. items := make([]*data_manage.ChartClassifyItems, 0)
  159. v.Children = items
  160. }
  161. nodeAll = append(nodeAll, v)
  162. }
  163. //
  164. //
  165. //nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  166. //for k := range rootList {
  167. // rootNode := rootList[k]
  168. // data.ChartClassifyListMakeTree(classifyAll, rootNode)
  169. // nodeAll = append(nodeAll, rootNode)
  170. //}
  171. resp.AllNodes = nodeAll
  172. // 将数据加入缓存
  173. if utils.Re == nil {
  174. redisData, _ := json.Marshal(resp)
  175. utils.Rc.Put(key, redisData, 2*time.Hour)
  176. }
  177. // 移除没有权限的图表
  178. allNodes := data.HandleNoPermissionChart(resp.AllNodes, noPermissionChartIdMap, this.SysUser.AdminId)
  179. resp.AllNodes = allNodes
  180. br.Ret = 200
  181. br.Success = true
  182. br.Msg = "获取成功"
  183. br.Data = resp
  184. }
  185. // getChartClassifyListForMe 获取我创建的图表
  186. func getChartClassifyListForMe(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
  187. rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_DEFAULT)
  188. if err != nil && err.Error() != utils.ErrNoRow() {
  189. errMsg = "获取失败"
  190. return
  191. }
  192. classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_DEFAULT)
  193. if err != nil && err.Error() != utils.ErrNoRow() {
  194. errMsg = "获取失败"
  195. return
  196. }
  197. allChartInfo, err := data_manage.GetChartInfoByAdminId([]int{utils.CHART_SOURCE_DEFAULT}, adminInfo.AdminId)
  198. if err != nil && err.Error() != utils.ErrNoRow() {
  199. errMsg = "获取失败"
  200. return
  201. }
  202. chartInfoMap := make(map[int][]*data_manage.ChartClassifyItems)
  203. for _, v := range allChartInfo {
  204. chartInfoMap[v.ChartClassifyId] = append(chartInfoMap[v.ChartClassifyId], v)
  205. }
  206. rootChildMap := make(map[int][]*data_manage.ChartClassifyItems)
  207. for _, v := range classifyAll {
  208. rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
  209. if existItems, ok := chartInfoMap[v.ChartClassifyId]; ok {
  210. v.Children = existItems
  211. } else {
  212. items := make([]*data_manage.ChartClassifyItems, 0)
  213. v.Children = items
  214. }
  215. }
  216. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  217. for _, v := range rootList {
  218. if existItems, ok := rootChildMap[v.ChartClassifyId]; ok {
  219. v.Children = existItems
  220. } else {
  221. items := make([]*data_manage.ChartClassifyItems, 0)
  222. v.Children = items
  223. }
  224. nodeAll = append(nodeAll, v)
  225. }
  226. resp.AllNodes = nodeAll
  227. return
  228. }
  229. // ChartClassifyItems
  230. // @Title 获取所有图表分类接口-不包含图表
  231. // @Description 获取所有图表分类接口-不包含图表
  232. // @Param IsShowMe query bool true "是否只看我的,true、false"
  233. // @Success 200 {object} data_manage.ChartClassifyListResp
  234. // @router /chart_classify/items [get]
  235. func (this *ChartClassifyController) ChartClassifyItems() {
  236. br := new(models.BaseResponse).Init()
  237. defer func() {
  238. this.Data["json"] = br
  239. this.ServeJSON()
  240. }()
  241. isShowMe, _ := this.GetBool("IsShowMe")
  242. level, _ := this.GetInt(`Level`)
  243. rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_DEFAULT)
  244. if err != nil {
  245. br.Msg = "获取失败"
  246. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  247. return
  248. }
  249. classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_DEFAULT)
  250. if err != nil {
  251. br.Msg = "获取失败"
  252. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  253. return
  254. }
  255. // 已授权分类id
  256. permissionClassifyIdList, err := data_manage_permission.GetUserChartClassifyPermissionList(this.SysUser.AdminId, 0)
  257. if err != nil {
  258. br.Msg = "获取失败"
  259. br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
  260. return
  261. }
  262. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  263. for k := range rootList {
  264. rootNode := rootList[k]
  265. data.ChartClassifyItemsMakeTree(this.SysUser, classifyAll, rootNode, permissionClassifyIdList, level)
  266. nodeAll = append(nodeAll, rootNode)
  267. }
  268. if isShowMe {
  269. // 自己拥有的分类id列表
  270. chartClassifyIdList, err := data_manage.GetChartClassifyIdListByAdminId(this.SysUser.AdminId, utils.CHART_SOURCE_DEFAULT)
  271. if err != nil {
  272. br.Msg = "获取失败"
  273. br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
  274. return
  275. }
  276. tmpNodeAll := nodeAll
  277. nodeAll = make([]*data_manage.ChartClassifyItems, 0)
  278. for _, node := range tmpNodeAll {
  279. if node.Children == nil || len(node.Children) <= 0 {
  280. continue
  281. }
  282. isSelf := data.RemoveNotChartClassifyItemsMakeTree(node, chartClassifyIdList)
  283. if isSelf {
  284. nodeAll = append(nodeAll, node)
  285. }
  286. }
  287. }
  288. language := `CN`
  289. // 指标显示的语言
  290. {
  291. configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.ChartLanguageVar)
  292. if configDetail != nil {
  293. language = configDetail.ConfigValue
  294. } else {
  295. configDetail, _ = system.GetDefaultConfigDetailByCode(system.ChartLanguageVar)
  296. if configDetail != nil {
  297. language = configDetail.ConfigValue
  298. }
  299. }
  300. }
  301. // 是否允许添加分类
  302. canOpClassify := true
  303. // 如果不是 超管 或者 ficc管理员 或者 ficc研究员,那么就没有权限
  304. //if !utils.InArrayByStr([]string{utils.ROLE_TYPE_CODE_ADMIN, utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_RESEARCHR, utils.ROLE_TYPE_CODE_FICC_RESEARCHR}, this.SysUser.RoleTypeCode) {
  305. // canOpClassify = false
  306. //}
  307. resp := data_manage.ChartClassifyListResp{
  308. AllNodes: nodeAll,
  309. Language: language,
  310. CanOpClassify: canOpClassify,
  311. }
  312. br.Ret = 200
  313. br.Success = true
  314. br.Msg = "获取成功"
  315. br.Data = resp
  316. }
  317. // @Title 新增图表分类
  318. // @Description 新增图表分类接口
  319. // @Param request body data_manage.AddChartClassifyReq true "type json string"
  320. // @Success 200 Ret=200 保存成功
  321. // @router /chart_classify/add [post]
  322. func (this *ChartClassifyController) AddChartClassify() {
  323. br := new(models.BaseResponse).Init()
  324. defer func() {
  325. this.Data["json"] = br
  326. this.ServeJSON()
  327. }()
  328. var req data_manage.AddChartClassifyReq
  329. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  330. if err != nil {
  331. br.Msg = "参数解析异常!"
  332. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  333. return
  334. }
  335. if req.ChartClassifyName == "" {
  336. br.Msg = "请输入分类名称"
  337. br.IsSendEmail = false
  338. return
  339. }
  340. if req.ParentId < 0 {
  341. br.Msg = "参数错误"
  342. br.IsSendEmail = false
  343. return
  344. }
  345. // 新增图表分类
  346. _, err, errMsg, isSendEmail := data.AddChartClassify(req.ChartClassifyName, req.ParentId, req.Level, utils.CHART_SOURCE_DEFAULT, this.Lang, this.SysUser)
  347. if err != nil {
  348. br.Msg = errMsg
  349. br.ErrMsg = "添加分类失败,Err:" + err.Error()
  350. br.IsSendEmail = isSendEmail
  351. return
  352. }
  353. br.Ret = 200
  354. br.Msg = "保存成功"
  355. br.Success = true
  356. }
  357. // EditChartClassify
  358. // @Title 修改图表分类
  359. // @Description 修改图表分类接口
  360. // @Param request body data_manage.EditChartClassifyReq true "type json string"
  361. // @Success 200 Ret=200 修改成功
  362. // @router /chart_classify/edit [post]
  363. func (this *ChartClassifyController) EditChartClassify() {
  364. br := new(models.BaseResponse).Init()
  365. defer func() {
  366. this.Data["json"] = br
  367. this.ServeJSON()
  368. }()
  369. var req data_manage.EditChartClassifyReq
  370. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  371. if err != nil {
  372. br.Msg = "参数解析异常!"
  373. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  374. return
  375. }
  376. if req.ChartClassifyName == "" {
  377. br.Msg = "请输入分类名称"
  378. br.IsSendEmail = false
  379. return
  380. }
  381. if req.ChartClassifyId <= 0 {
  382. br.Msg = "参数错误"
  383. br.IsSendEmail = false
  384. return
  385. }
  386. // 编辑图表分类
  387. _, err, errMsg, isSendEmail := data.EditChartClassifyV2(req.ChartClassifyId, req.ParentId, utils.CHART_SOURCE_DEFAULT, req.ChartClassifyName, this.Lang)
  388. if err != nil {
  389. br.Msg = errMsg
  390. br.ErrMsg = "保存分类失败,Err:" + err.Error()
  391. br.IsSendEmail = isSendEmail
  392. return
  393. }
  394. br.Ret = 200
  395. br.Msg = "保存成功"
  396. br.Success = true
  397. br.IsAddLog = true
  398. }
  399. // @Title 删除图表检测接口
  400. // @Description 删除图表检测接口
  401. // @Param request body data_manage.ChartClassifyDeleteCheckResp true "type json string"
  402. // @Success 200 Ret=200 检测成功
  403. // @router /chart_classify/delete/check [post]
  404. func (this *ChartClassifyController) DeleteChartClassifyCheck() {
  405. br := new(models.BaseResponse).Init()
  406. defer func() {
  407. this.Data["json"] = br
  408. this.ServeJSON()
  409. }()
  410. var req data_manage.ChartClassifyDeleteCheckReq
  411. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  412. if err != nil {
  413. br.Msg = "参数解析异常!"
  414. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  415. return
  416. }
  417. if req.ChartClassifyId < 0 && req.ChartInfoId <= 0 {
  418. br.Msg = "参数错误"
  419. br.IsSendEmail = false
  420. return
  421. }
  422. var deleteStatus int
  423. var tipsMsg string
  424. //删除分类
  425. if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
  426. // 查找分类
  427. item, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
  428. if err != nil {
  429. br.Msg = "保存失败"
  430. br.Msg = "获取分类信息失败,Err:" + err.Error()
  431. return
  432. }
  433. // 已授权分类id
  434. permissionClassifyIdList, err := data_manage_permission.GetUserChartClassifyPermissionList(this.SysUser.AdminId, item.ChartClassifyId)
  435. if err != nil {
  436. br.Msg = "获取失败"
  437. br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
  438. return
  439. }
  440. // 权限校验
  441. {
  442. haveOperaAuth := data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(item.IsJoinPermission, item.ChartClassifyId, permissionClassifyIdList)
  443. button := data.GetChartClassifyOpButton(this.SysUser, item.SysUserId, haveOperaAuth)
  444. if !button.OpButton {
  445. br.Msg = "无操作权限"
  446. br.IsSendEmail = false
  447. return
  448. }
  449. }
  450. //判断图表分类下,是否含有图表
  451. count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
  452. if err != nil {
  453. br.Msg = "删除失败"
  454. br.ErrMsg = "分类下是否含有指标失败,Err:" + err.Error()
  455. return
  456. }
  457. if count > 0 {
  458. deleteStatus = 1
  459. tipsMsg = "该分类下关联图表不可删除"
  460. }
  461. }
  462. if deleteStatus != 1 && req.ChartInfoId == 0 {
  463. classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
  464. if err != nil && err.Error() != utils.ErrNoRow() {
  465. br.Msg = "删除失败"
  466. br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
  467. return
  468. }
  469. if classifyCount > 0 {
  470. deleteStatus = 2
  471. tipsMsg = "确认删除当前目录及包含的子目录吗"
  472. }
  473. }
  474. if deleteStatus == 0 {
  475. tipsMsg = "可删除,进行删除操作"
  476. }
  477. resp := new(data_manage.ChartClassifyDeleteCheckResp)
  478. resp.DeleteStatus = deleteStatus
  479. resp.TipsMsg = tipsMsg
  480. br.Ret = 200
  481. br.Msg = "检测成功"
  482. br.Success = true
  483. br.Data = resp
  484. }
  485. // @Title 删除图表分类/图表
  486. // @Description 删除图表分类/图表接口
  487. // @Param request body data_manage.DeleteChartClassifyReq true "type json string"
  488. // @Success 200 Ret=200 删除成功
  489. // @router /chart_classify/delete [post]
  490. func (this *ChartClassifyController) DeleteChartClassify() {
  491. br := new(models.BaseResponse).Init()
  492. defer func() {
  493. this.Data["json"] = br
  494. this.ServeJSON()
  495. }()
  496. sysUser := this.SysUser
  497. if sysUser == nil {
  498. br.Msg = "请登录"
  499. br.ErrMsg = "请登录,SysUser Is Empty"
  500. br.Ret = 408
  501. return
  502. }
  503. var req data_manage.DeleteChartClassifyReq
  504. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  505. if err != nil {
  506. br.Msg = "参数解析异常!"
  507. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  508. return
  509. }
  510. if req.ChartClassifyId < 0 && req.ChartInfoId <= 0 {
  511. br.Msg = "参数错误"
  512. br.IsSendEmail = false
  513. return
  514. }
  515. //删除分类
  516. if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
  517. // 查找分类
  518. item, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
  519. if err != nil {
  520. br.Msg = "保存失败"
  521. br.Msg = "获取分类信息失败,Err:" + err.Error()
  522. return
  523. }
  524. // 已授权分类id
  525. permissionClassifyIdList, err := data_manage_permission.GetUserChartClassifyPermissionList(this.SysUser.AdminId, item.ChartClassifyId)
  526. if err != nil {
  527. br.Msg = "获取失败"
  528. br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
  529. return
  530. }
  531. // 权限校验
  532. {
  533. haveOperaAuth := data_manage_permission.CheckChartClassifyPermissionByPermissionIdList(item.IsJoinPermission, item.ChartClassifyId, permissionClassifyIdList)
  534. button := data.GetChartClassifyOpButton(this.SysUser, item.SysUserId, haveOperaAuth)
  535. if !button.OpButton {
  536. br.Msg = "无操作权限"
  537. br.IsSendEmail = false
  538. return
  539. }
  540. }
  541. //判断是否含有指标
  542. count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
  543. if err != nil && err.Error() != utils.ErrNoRow() {
  544. br.Msg = "删除失败"
  545. br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
  546. return
  547. }
  548. if count > 0 {
  549. br.Msg = "该目录下存在关联指标,不可删除"
  550. br.IsSendEmail = false
  551. return
  552. }
  553. err = data_manage.DeleteChartClassify(req.ChartClassifyId)
  554. if err != nil {
  555. br.Msg = "删除失败"
  556. br.ErrMsg = "删除失败,Err:" + err.Error()
  557. return
  558. }
  559. }
  560. resp := new(data_manage.AddChartInfoResp)
  561. //删除图表
  562. if req.ChartInfoId > 0 {
  563. chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
  564. if err != nil {
  565. if err.Error() == utils.ErrNoRow() {
  566. br.Msg = "图表已删除,请刷新页面"
  567. br.ErrMsg = "指标不存在,Err:" + err.Error()
  568. return
  569. } else {
  570. br.Msg = "删除失败"
  571. br.ErrMsg = "删除失败,获取指标信息失败,Err:" + err.Error()
  572. return
  573. }
  574. }
  575. if chartInfo == nil {
  576. br.Msg = "图表已删除,请刷新页面"
  577. return
  578. }
  579. chartClassifyItem, err := data_manage.GetChartClassifyById(chartInfo.ChartClassifyId)
  580. if err != nil {
  581. br.Msg = "获取失败"
  582. br.ErrMsg = "获取图表分类详情数据失败,Err:" + err.Error()
  583. return
  584. }
  585. // 已授权图表、分类id
  586. permissionChartIdList, permissionClassifyIdList, err := data_manage_permission.GetUserChartAndClassifyPermissionList(this.SysUser.AdminId, chartInfo.ChartInfoId, chartInfo.ChartClassifyId)
  587. if err != nil {
  588. br.Msg = "获取失败"
  589. br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
  590. return
  591. }
  592. // 权限校验
  593. {
  594. haveOperaAuth := data_manage_permission.CheckChartPermissionByPermissionIdList(chartInfo.IsJoinPermission, chartClassifyItem.IsJoinPermission, chartInfo.ChartInfoId, chartInfo.ChartClassifyId, permissionChartIdList, permissionClassifyIdList)
  595. //图表操作权限
  596. ok := data.CheckOpChartPermission(sysUser, chartInfo.SysUserId, haveOperaAuth)
  597. if !ok {
  598. br.Msg = "没有该图表的操作权限"
  599. br.ErrMsg = "没有该图表的操作权限"
  600. return
  601. }
  602. }
  603. // 获取引用该图表的MyCharts, 用于ES删除
  604. var myCond string
  605. var myPars []interface{}
  606. myCond += ` AND a.chart_info_id = ? `
  607. myPars = append(myPars, req.ChartInfoId)
  608. myCharts, e := data_manage.GetMyChartListGroupByCharyInfoIdAndAdminIdByCondition(myCond, myPars)
  609. if e != nil {
  610. br.Msg = "删除失败"
  611. br.ErrMsg = "获取引用图表的MyChats失败, Err: " + e.Error()
  612. return
  613. }
  614. myIds := make([]int, 0)
  615. for _, m := range myCharts {
  616. myIds = append(myIds, m.MyChartId)
  617. }
  618. //删除图表及关联指标
  619. err = data_manage.DeleteChartInfoAndData(req.ChartInfoId)
  620. if err != nil {
  621. br.Msg = "删除失败"
  622. br.ErrMsg = "删除失败,Err:" + err.Error()
  623. return
  624. }
  625. if chartInfo.ChartType == utils.CHART_TYPE_SECTION_COMBINE {
  626. err = data_manage.DeleteChartSeriesAndEdbMapping(req.ChartInfoId)
  627. if err != nil {
  628. br.Msg = "删除失败"
  629. br.ErrMsg = "删除失败,Err:" + err.Error()
  630. return
  631. }
  632. }
  633. //删除ES
  634. {
  635. go data.EsDeleteChartInfo(req.ChartInfoId)
  636. // 删除MY ETA 图表 es数据
  637. //go data.EsDeleteMyChartInfoByChartInfoId(req.ChartInfoId)
  638. go data.EsDeleteMyChartInfoByMyChartIds(myIds)
  639. }
  640. var condition string
  641. var pars []interface{}
  642. condition += " AND chart_classify_id=? AND source = ? "
  643. pars = append(pars, chartInfo.ChartClassifyId, utils.CHART_SOURCE_DEFAULT)
  644. condition += " AND chart_info_id>? ORDER BY create_time ASC LIMIT 1 "
  645. pars = append(pars, req.ChartInfoId)
  646. nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
  647. if err != nil && err.Error() != utils.ErrNoRow() {
  648. br.Msg = "删除失败"
  649. br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
  650. return
  651. }
  652. if nextItem != nil {
  653. resp.UniqueCode = nextItem.UniqueCode
  654. resp.ChartInfoId = nextItem.ChartInfoId
  655. } else {
  656. var condition string
  657. var pars []interface{}
  658. condition += " AND level=3 "
  659. //pars = append(pars, chartInfo.ChartClassifyId)
  660. condition += " AND chart_classify_id>? ORDER BY chart_classify_id ASC LIMIT 1 "
  661. pars = append(pars, chartInfo.ChartClassifyId)
  662. classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
  663. if err != nil && err.Error() != utils.ErrNoRow() {
  664. br.Msg = "删除失败"
  665. br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
  666. return
  667. }
  668. if classifyItem != nil {
  669. nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
  670. if err != nil && err.Error() != utils.ErrNoRow() {
  671. br.Msg = "删除失败"
  672. br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
  673. return
  674. }
  675. if nextItem != nil {
  676. resp.UniqueCode = nextItem.UniqueCode
  677. resp.ChartInfoId = nextItem.ChartInfoId
  678. }
  679. }
  680. }
  681. // 删除图表中的指标引用
  682. _ = data_manage.DeleteEdbRelationByObjectId(req.ChartInfoId, utils.EDB_RELATION_CHART)
  683. //新增操作日志
  684. {
  685. chartLog := new(data_manage.ChartInfoLog)
  686. chartLog.ChartName = chartInfo.ChartName
  687. chartLog.ChartInfoId = req.ChartInfoId
  688. chartLog.ChartClassifyId = chartInfo.ChartClassifyId
  689. chartLog.SysUserId = sysUser.AdminId
  690. chartLog.SysUserRealName = sysUser.RealName
  691. chartLog.UniqueCode = chartInfo.UniqueCode
  692. chartLog.CreateTime = time.Now()
  693. chartLog.Content = string(this.Ctx.Input.RequestBody)
  694. chartLog.Status = "删除图表"
  695. chartLog.Method = this.Ctx.Input.URI()
  696. go data_manage.AddChartInfoLog(chartLog)
  697. }
  698. }
  699. br.Ret = 200
  700. br.Msg = "删除成功"
  701. br.Success = true
  702. br.Data = resp
  703. br.IsAddLog = true
  704. }
  705. // ChartClassifyMove
  706. // @Title 图表分类移动接口
  707. // @Description 图表分类移动接口
  708. // @Success 200 {object} data_manage.MoveChartClassifyReq
  709. // @router /chart_classify/move [post]
  710. func (this *ChartClassifyController) ChartClassifyMove() {
  711. br := new(models.BaseResponse).Init()
  712. defer func() {
  713. if br.ErrMsg == "" {
  714. br.IsSendEmail = false
  715. }
  716. this.Data["json"] = br
  717. this.ServeJSON()
  718. }()
  719. sysUser := this.SysUser
  720. if sysUser == nil {
  721. br.Msg = "请登录"
  722. br.ErrMsg = "请登录,SysUser Is Empty"
  723. br.Ret = 408
  724. return
  725. }
  726. var req data_manage.MoveChartClassifyReq
  727. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  728. if err != nil {
  729. br.Msg = "参数解析异常!"
  730. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  731. return
  732. }
  733. if req.ClassifyId <= 0 {
  734. br.Msg = "参数错误"
  735. br.ErrMsg = "分类id小于等于0"
  736. return
  737. }
  738. //判断分类是否存在
  739. chartClassifyInfo, err := data_manage.GetChartClassifyById(req.ClassifyId)
  740. if err != nil {
  741. if err.Error() == utils.ErrNoRow() {
  742. br.Msg = "分类不存在,请刷新页面"
  743. return
  744. }
  745. br.Msg = "移动失败"
  746. br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
  747. return
  748. }
  749. // 校验移动的父级目录下是否有重名分类
  750. exists, e := data_manage.GetChartClassifyByParentIdAndName(req.ParentClassifyId, chartClassifyInfo.ChartClassifyName, req.ClassifyId)
  751. if e != nil && e.Error() != utils.ErrNoRow() {
  752. br.Msg = "移动失败"
  753. br.ErrMsg = "获取父级目录下的同名分类失败, Err: " + e.Error()
  754. return
  755. }
  756. if exists != nil {
  757. br.Msg = "移动失败,分类名称已存在"
  758. return
  759. }
  760. // 已授权分类id
  761. permissionClassifyIdList, err := data_manage_permission.GetUserChartClassifyPermissionList(this.SysUser.AdminId, chartClassifyInfo.ChartClassifyId)
  762. if err != nil {
  763. br.Msg = "获取失败"
  764. br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
  765. return
  766. }
  767. // 权限校验
  768. {
  769. haveOperaAuth := data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(chartClassifyInfo.IsJoinPermission, chartClassifyInfo.ChartClassifyId, permissionClassifyIdList)
  770. button := data.GetChartClassifyOpButton(this.SysUser, chartClassifyInfo.SysUserId, haveOperaAuth)
  771. if !button.OpButton {
  772. br.Msg = "无操作权限"
  773. br.IsSendEmail = false
  774. return
  775. }
  776. }
  777. if chartClassifyInfo.Source != utils.CHART_SOURCE_DEFAULT {
  778. br.Msg = "分类异常"
  779. br.ErrMsg = "分类异常,不是ETA图库的分类"
  780. return
  781. }
  782. updateCol := make([]string, 0)
  783. //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
  784. if chartClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId != 0 {
  785. parentChartClassifyInfo, err := data_manage.GetChartClassifyById(req.ParentClassifyId)
  786. if err != nil {
  787. br.Msg = "移动失败"
  788. br.ErrMsg = "获取上级分类信息失败,Err:" + err.Error()
  789. return
  790. }
  791. chartClassifyInfo.ParentId = parentChartClassifyInfo.ChartClassifyId
  792. chartClassifyInfo.Level = parentChartClassifyInfo.Level + 1
  793. chartClassifyInfo.ModifyTime = time.Now()
  794. updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
  795. }
  796. //如果有传入 上一个兄弟节点分类id
  797. if req.PrevClassifyId > 0 {
  798. //上一个兄弟节点
  799. prevClassify, err := data_manage.GetChartClassifyById(req.PrevClassifyId)
  800. if err != nil {
  801. br.Msg = "移动失败"
  802. br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
  803. return
  804. }
  805. //如果是移动在两个兄弟节点之间
  806. if req.NextClassifyId > 0 {
  807. //下一个兄弟节点
  808. nextClassify, err := data_manage.GetChartClassifyById(req.NextClassifyId)
  809. if err != nil {
  810. br.Msg = "移动失败"
  811. br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
  812. return
  813. }
  814. //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
  815. if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == chartClassifyInfo.Sort {
  816. //变更兄弟节点的排序
  817. updateSortStr := `sort + 2`
  818. _ = data_manage.UpdateChartClassifySortByParentId(prevClassify.ParentId, prevClassify.ChartClassifyId, prevClassify.Sort, updateSortStr)
  819. } else {
  820. //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
  821. if nextClassify.Sort-prevClassify.Sort == 1 {
  822. //变更兄弟节点的排序
  823. updateSortStr := `sort + 1`
  824. _ = data_manage.UpdateChartClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr)
  825. }
  826. }
  827. }
  828. chartClassifyInfo.Sort = prevClassify.Sort + 1
  829. chartClassifyInfo.ModifyTime = time.Now()
  830. updateCol = append(updateCol, "Sort", "ModifyTime")
  831. } else {
  832. firstClassify, err := data_manage.GetFirstChartClassifyByParentId(chartClassifyInfo.ParentId)
  833. if err != nil && err.Error() != utils.ErrNoRow() {
  834. br.Msg = "移动失败"
  835. br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
  836. return
  837. }
  838. //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  839. if firstClassify != nil && firstClassify.Sort == 0 {
  840. updateSortStr := ` sort + 1 `
  841. _ = data_manage.UpdateChartClassifySortByParentId(firstClassify.ParentId, firstClassify.ChartClassifyId-1, 0, updateSortStr)
  842. }
  843. chartClassifyInfo.Sort = 0 //那就是排在第一位
  844. chartClassifyInfo.ModifyTime = time.Now()
  845. updateCol = append(updateCol, "Sort", "ModifyTime")
  846. }
  847. //更新
  848. if len(updateCol) > 0 {
  849. err = chartClassifyInfo.Update(updateCol)
  850. if err != nil {
  851. br.Msg = "移动失败"
  852. br.ErrMsg = "修改失败,Err:" + err.Error()
  853. return
  854. }
  855. }
  856. br.Ret = 200
  857. br.Success = true
  858. br.Msg = "移动成功"
  859. }
  860. // getChartClassifyListForMe 获取我创建的图表分类
  861. func getChartClassifyListForMeV2(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
  862. rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_DEFAULT)
  863. if err != nil && err.Error() != utils.ErrNoRow() {
  864. errMsg = "获取失败"
  865. return
  866. }
  867. classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_DEFAULT)
  868. if err != nil && err.Error() != utils.ErrNoRow() {
  869. errMsg = "获取失败"
  870. return
  871. }
  872. rootChildMap := make(map[int][]*data_manage.ChartClassifyItems)
  873. for _, v := range classifyAll {
  874. rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
  875. }
  876. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  877. for _, v := range rootList {
  878. if existItems, ok := rootChildMap[v.ChartClassifyId]; ok {
  879. v.Children = existItems
  880. } else {
  881. items := make([]*data_manage.ChartClassifyItems, 0)
  882. v.Children = items
  883. }
  884. nodeAll = append(nodeAll, v)
  885. }
  886. resp.AllNodes = nodeAll
  887. return
  888. }
  889. // ChartClassifyChartListV2
  890. // @Title 根据图表分类获取图表列表
  891. // @Description 根据图表分类获取图表列表接口
  892. // @Param IsShowMe query bool true "是否只看我的,true、false"
  893. // @Param ChartClassifyId query bool true "图片分类id"
  894. // @Success 200 {object} data_manage.ChartClassifyListResp
  895. // @router /chart_classify/chart/list [get]
  896. func (this *ChartClassifyController) ChartClassifyChartListV2() {
  897. br := new(models.BaseResponse).Init()
  898. defer func() {
  899. this.Data["json"] = br
  900. this.ServeJSON()
  901. }()
  902. sysUser := this.SysUser
  903. if sysUser == nil {
  904. br.Msg = "请登录"
  905. br.ErrMsg = "请登录,SysUser Is Empty"
  906. br.Ret = 408
  907. return
  908. }
  909. resp := new(data_manage.ChartClassifyListResp)
  910. chartClassifyId, _ := this.GetInt("ChartClassifyId")
  911. if chartClassifyId <= 0 {
  912. br.Msg = "参数错误"
  913. return
  914. }
  915. // 获取当前账号的不可见指标
  916. noPermissionChartIdMap := make(map[int]bool)
  917. {
  918. obj := data_manage.EdbInfoNoPermissionAdmin{}
  919. confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
  920. if err != nil && err.Error() != utils.ErrNoRow() {
  921. br.Msg = "获取失败"
  922. br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
  923. return
  924. }
  925. for _, v := range confList {
  926. noPermissionChartIdMap[v.ChartInfoId] = true
  927. }
  928. }
  929. isShowMe, _ := this.GetBool("IsShowMe")
  930. if isShowMe {
  931. allChartInfo, err := data_manage.GetChartInfoByAdminIdAndClassify([]int{utils.CHART_SOURCE_DEFAULT}, sysUser.AdminId, chartClassifyId)
  932. if err != nil && err.Error() != utils.ErrNoRow() {
  933. br.Msg = "获取失败"
  934. br.ErrMsg = "获取全部数据失败,Err:" + err.Error()
  935. return
  936. }
  937. // 移除没有权限的图表
  938. allNodes := data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
  939. resp.AllNodes = allNodes
  940. br.Ret = 200
  941. br.Success = true
  942. br.Msg = "获取成功"
  943. br.Data = resp
  944. fmt.Println("source my classify")
  945. return
  946. }
  947. allChartInfo, err := data_manage.GetChartInfoAllByClassifyId(utils.CHART_SOURCE_DEFAULT, chartClassifyId)
  948. if err != nil && err.Error() != utils.ErrNoRow() {
  949. br.Msg = "获取失败"
  950. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  951. return
  952. }
  953. // 移除没有权限的图表
  954. allNodes := data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
  955. for k, item := range allNodes {
  956. item.Button = data.GetChartOpButton(this.SysUser, item.SysUserId, item.HaveOperaAuth)
  957. item.Button.AddButton = false
  958. item.Button.OpButton = false
  959. item.Button.DeleteButton = false
  960. allNodes[k] = item
  961. }
  962. resp.AllNodes = allNodes
  963. br.Ret = 200
  964. br.Success = true
  965. br.Msg = "获取成功"
  966. br.Data = resp
  967. }
  968. // ChartClassifyChartListV3
  969. // @Title 根据图表分类获取图表列表-包含分类和图表
  970. // @Description 根据图表分类获取图表列表接口-包含分类和图表
  971. // @Param IsShowMe query bool true "是否只看我的,true、false"
  972. // @Param ChartClassifyId query bool true "图片分类id"
  973. // @Success 200 {object} data_manage.ChartClassifyListResp
  974. // @router /chart_classify/chart/listV2 [get]
  975. func (this *ChartClassifyController) ChartClassifyChartListV3() {
  976. br := new(models.BaseResponse).Init()
  977. defer func() {
  978. this.Data["json"] = br
  979. this.ServeJSON()
  980. }()
  981. sysUser := this.SysUser
  982. if sysUser == nil {
  983. br.Msg = "请登录"
  984. br.ErrMsg = "请登录,SysUser Is Empty"
  985. br.Ret = 408
  986. return
  987. }
  988. resp := new(data_manage.ChartClassifyListResp)
  989. chartClassifyId, _ := this.GetInt("ChartClassifyId")
  990. if chartClassifyId < 0 {
  991. br.Msg = "参数错误"
  992. return
  993. }
  994. // 获取当前账号的不可见指标
  995. noPermissionChartIdMap := make(map[int]bool)
  996. {
  997. obj := data_manage.EdbInfoNoPermissionAdmin{}
  998. confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
  999. if err != nil && err.Error() != utils.ErrNoRow() {
  1000. br.Msg = "获取失败"
  1001. br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
  1002. return
  1003. }
  1004. for _, v := range confList {
  1005. noPermissionChartIdMap[v.ChartInfoId] = true
  1006. }
  1007. }
  1008. isShowMe, _ := this.GetBool("IsShowMe")
  1009. if isShowMe {
  1010. allChartInfo, err := data_manage.GetChartClassifyAndInfoByParentIdForMe(chartClassifyId, sysUser.AdminId)
  1011. if err != nil && err.Error() != utils.ErrNoRow() {
  1012. br.Msg = "获取失败"
  1013. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1014. return
  1015. }
  1016. // 移除没有权限的图表
  1017. allNodes := data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
  1018. allNodes, err = data.GetChartClassifyByIsMe(sysUser.AdminId, chartClassifyId, utils.CHART_SOURCE_DEFAULT, allNodes)
  1019. if err != nil {
  1020. br.Msg = "获取失败"
  1021. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1022. return
  1023. }
  1024. resp.AllNodes = allNodes
  1025. br.Ret = 200
  1026. br.Success = true
  1027. br.Msg = "获取成功"
  1028. br.Data = resp
  1029. fmt.Println("source my classify")
  1030. return
  1031. }
  1032. allChartInfo, err := data_manage.GetChartClassifyAndInfoByParentId(chartClassifyId)
  1033. if err != nil && err.Error() != utils.ErrNoRow() {
  1034. br.Msg = "获取失败"
  1035. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1036. return
  1037. }
  1038. //allChartInfo, err := data_manage.GetChartInfoAllByClassifyId(utils.CHART_SOURCE_DEFAULT, chartClassifyId)
  1039. //if err != nil && err.Error() != utils.ErrNoRow() {
  1040. // br.Msg = "获取失败"
  1041. // br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  1042. // return
  1043. //}
  1044. // 移除没有权限的图表
  1045. allNodes := data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
  1046. for k, item := range allNodes {
  1047. item.Button = data.GetChartOpButton(this.SysUser, item.SysUserId, item.HaveOperaAuth)
  1048. if item.ChartInfoId > 0 {
  1049. item.Button.AddButton = false
  1050. item.Button.OpButton = false
  1051. item.Button.DeleteButton = false
  1052. item.Button.MoveButton = true
  1053. } else if item.Level == 6 {
  1054. item.Button.AddButton = false
  1055. }
  1056. allNodes[k] = item
  1057. }
  1058. resp.AllNodes = allNodes
  1059. br.Ret = 200
  1060. br.Success = true
  1061. br.Msg = "获取成功"
  1062. br.Data = resp
  1063. }