public_chart.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. package data_manage
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_api/cache"
  5. "eta_gn/eta_api/controllers"
  6. "eta_gn/eta_api/models"
  7. "eta_gn/eta_api/models/data_manage"
  8. "eta_gn/eta_api/models/data_manage/data_approve"
  9. "eta_gn/eta_api/models/data_manage/request"
  10. "eta_gn/eta_api/models/system"
  11. "eta_gn/eta_api/services/data"
  12. dataApproveSerice "eta_gn/eta_api/services/data/data_approve"
  13. "eta_gn/eta_api/services/elastic"
  14. "eta_gn/eta_api/utils"
  15. "fmt"
  16. "github.com/rdlucklib/rdluck_tools/paging"
  17. "strconv"
  18. "strings"
  19. )
  20. // ChartPublicController 公共图表
  21. type ChartPublicController struct {
  22. controllers.BaseAuthController
  23. }
  24. // Save
  25. // @Title 单个图表设置公开
  26. // @Description 单个图表设置公开
  27. // @Param request body request.SetChartInfoShareReq true "type json string"
  28. // @Success 200 {object} data_manage.ChartInfo
  29. // @router /chart_info/public/save [post]
  30. func (c *ChartPublicController) Save() {
  31. br := new(models.BaseResponse).Init()
  32. defer func() {
  33. c.Data["json"] = br
  34. c.ServeJSON()
  35. }()
  36. sysUser := c.SysUser
  37. if sysUser == nil {
  38. br.Msg = "请登录"
  39. br.ErrMsg = "请登录,SysUser Is Empty"
  40. br.Ret = 408
  41. return
  42. }
  43. var req request.SetChartPublicReq
  44. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  45. if err != nil {
  46. br.Msg = "参数解析异常!"
  47. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  48. return
  49. }
  50. if len(req.ChartInfoList) <= 0 {
  51. br.Msg = `请选择图表`
  52. br.IsSendEmail = false
  53. return
  54. }
  55. // 待处理的资产
  56. dataPublicItemList := make([]dataApproveSerice.SetDataPublicItem, 0)
  57. // 校验是否重复存在已公开、已提交的图表
  58. {
  59. chartInfoIdList := make([]int, 0)
  60. for _, item := range req.ChartInfoList {
  61. chartInfoIdList = append(chartInfoIdList, item.ChartInfoId)
  62. dataPublicItemList = append(dataPublicItemList, dataApproveSerice.SetDataPublicItem{
  63. DataId: item.ChartInfoId,
  64. ClassifyId: item.ClassifyId,
  65. })
  66. }
  67. list, err := data_manage.GetChartInfoByIdList(chartInfoIdList)
  68. if err != nil {
  69. br.Msg = "保存失败!"
  70. br.ErrMsg = "获取图表数据失败,Err:" + err.Error()
  71. return
  72. }
  73. for _, v := range list {
  74. if v.PublicStatus != utils.DataPublicDefault {
  75. br.Msg = `选择图表中存在已经公开/提交审批的图表,请仅选择未公开图表!`
  76. br.IsSendEmail = false
  77. return
  78. }
  79. }
  80. }
  81. // 校验是否开启了审批流
  82. opening, e := dataApproveSerice.CheckOpenApprove(utils.DataApproveTypeChart)
  83. if e != nil {
  84. br.Msg = "操作失败"
  85. br.ErrMsg = "校验图表公开是否开启审批流失败, Err: " + e.Error()
  86. return
  87. }
  88. // 是否忽略审批
  89. var isIgnoreApprove bool
  90. {
  91. businessConf, e := models.GetBusinessConfByKey(models.IgnoreChartApproveUserId)
  92. if e != nil {
  93. br.Msg = "获取失败"
  94. br.ErrMsg = "获取商家配置失败, Err: " + e.Error()
  95. return
  96. }
  97. ignoreChartApproveUserIdList := strings.Split(businessConf.ConfVal, `,`)
  98. if utils.InArrayByStr(ignoreChartApproveUserIdList, strconv.Itoa(c.SysUser.AdminId)) {
  99. isIgnoreApprove = true
  100. }
  101. }
  102. chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoList[0].ChartInfoId)
  103. if err != nil {
  104. br.Msg = "获取图表失败"
  105. br.ErrMsg = "获取图表失败:" + err.Error()
  106. return
  107. }
  108. title := chartInfo.ChartName
  109. if len(req.ChartInfoList) > 1 {
  110. title += `等图表`
  111. }
  112. title += `公开审批`
  113. // 没开启审批流、或者无需审批
  114. if !opening || isIgnoreApprove {
  115. err = dataApproveSerice.UpdatePublicByDataList(utils.DataApproveTypeChart, dataApproveSerice.DataApproveStatePass, dataPublicItemList)
  116. } else {
  117. _, err = dataApproveSerice.SubmitDataApprove(utils.DataApproveTypeChart, dataPublicItemList, title, strings.TrimSpace(req.Description), c.SysUser.AdminId, c.SysUser.RealName)
  118. if err != nil {
  119. br.Msg = "提交审批失败"
  120. br.ErrMsg = "提交审批失败, Err: " + err.Error()
  121. return
  122. }
  123. // 更新ES
  124. for _, dataPublicItem := range dataPublicItemList {
  125. data.AddOrEditChartInfoToEs(dataPublicItem.DataId)
  126. }
  127. }
  128. if err != nil {
  129. br.Msg = "编辑失败"
  130. br.ErrMsg = "编辑失败,Err:" + err.Error()
  131. return
  132. }
  133. br.Ret = 200
  134. br.Success = true
  135. br.Msg = "保存成功"
  136. }
  137. // Cancel
  138. // @Title 撤销图表公开
  139. // @Description 撤销图表公开
  140. // @Param ChartInfoId query int true "图表id"
  141. // @Success 200 {object} data_manage.ChartInfo
  142. // @router /chart_info/public/cancel [post]
  143. func (c *ChartPublicController) Cancel() {
  144. br := new(models.BaseResponse).Init()
  145. defer func() {
  146. c.Data["json"] = br
  147. c.ServeJSON()
  148. }()
  149. sysUser := c.SysUser
  150. if sysUser == nil {
  151. br.Msg = "请登录"
  152. br.ErrMsg = "请登录,SysUser Is Empty"
  153. br.Ret = 408
  154. return
  155. }
  156. var req request.CancelChartPublicReq
  157. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  158. if err != nil {
  159. br.Msg = "参数解析异常!"
  160. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  161. return
  162. }
  163. chartInfoId := req.ChartInfoId
  164. if chartInfoId <= 0 {
  165. br.Msg = "参数错误"
  166. br.ErrMsg = "参数错误"
  167. return
  168. }
  169. chartInfo, err := data_manage.GetChartInfoById(chartInfoId)
  170. if err != nil {
  171. br.Msg = "保存失败!"
  172. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  173. return
  174. }
  175. // 判断图表公共状态
  176. if !utils.InArrayByInt([]int{utils.DataPublicSuccess, utils.DataPublicReject, utils.DataPublicCommit}, chartInfo.PublicStatus) {
  177. br.Msg = "保存失败,图表公开状态异常!"
  178. br.ErrMsg = "保存失败,图表公开状态异常,public_status:" + fmt.Sprint(chartInfo.PublicStatus)
  179. return
  180. }
  181. // 如果公开状态是:已驳回、已提交,那么直接去撤销审批单
  182. if utils.InArrayByInt([]int{utils.DataPublicReject, utils.DataPublicCommit}, chartInfo.PublicStatus) {
  183. obj := data_approve.DataApproveRelation{}
  184. dataApproveId, err := obj.GetDataApproveIdByDataId(chartInfoId, utils.DataApproveTypeChart)
  185. if err != nil {
  186. br.Msg = "保存失败!"
  187. br.ErrMsg = "获取审批单失败,Err:" + err.Error()
  188. return
  189. }
  190. // 撤销审批
  191. msg, e := dataApproveSerice.DataApproveCancel(dataApproveId, sysUser.AdminId, sysUser.RealName)
  192. if e != nil {
  193. if msg != "" {
  194. br.Msg = msg
  195. } else {
  196. br.Msg = "操作失败"
  197. }
  198. br.ErrMsg = "撤销审批失败, Err: " + e.Error()
  199. return
  200. }
  201. }
  202. checkUserIdList := []int{sysUser.AdminId}
  203. // 已经分享的用户
  204. {
  205. obj := data_manage.ChartInfoShare{}
  206. userIdList, err := obj.GetAllUserIdListByChartInfoId(chartInfo.ChartInfoId)
  207. if err != nil {
  208. br.Msg = "设置失败!"
  209. br.ErrMsg = "设置失败,Err:" + err.Error()
  210. return
  211. }
  212. if len(userIdList) > 0 {
  213. checkUserIdList = append(checkUserIdList, userIdList...)
  214. }
  215. }
  216. noReferenced, otherUserIdList, err, tips := data.CheckChartReferencedByOthers([]int{chartInfo.ChartInfoId}, []string{chartInfo.UniqueCode}, checkUserIdList)
  217. if err != nil {
  218. br.Msg = "保存失败"
  219. if tips != "" {
  220. br.Msg = tips
  221. }
  222. br.ErrMsg = "撤销图表公开失败,查找图表的关联用户失败,Err:" + err.Error()
  223. return
  224. }
  225. if !noReferenced {
  226. userNameStr := ``
  227. if len(otherUserIdList) > 0 {
  228. userNameList := make([]string, 0)
  229. userList, err := system.GetAdminListByIdList(otherUserIdList)
  230. if err != nil {
  231. br.Msg = "保存失败"
  232. if tips != "" {
  233. br.Msg = tips
  234. }
  235. br.ErrMsg = "撤销图表公开失败,查找用户信息失败,Err:" + err.Error()
  236. return
  237. }
  238. for _, userInfo := range userList {
  239. userNameList = append(userNameList, userInfo.RealName)
  240. }
  241. userNameStr = strings.Join(userNameList, ",")
  242. }
  243. msg := `图表被其他用户使用,无法撤销公开`
  244. if userNameStr != "" {
  245. msg = fmt.Sprintf(`图表被用户%s使用,无法撤销公开`, userNameStr)
  246. }
  247. if tips != "" {
  248. msg = fmt.Sprintf(`%s,用户为:%s,无法撤销公开`, tips, userNameStr)
  249. }
  250. br.Msg = msg
  251. br.ErrMsg = "图表被其他用户共享,无法撤销公开,ChartInfoId:" + strconv.Itoa(chartInfo.ChartInfoId)
  252. br.IsSendEmail = false
  253. return
  254. }
  255. chartInfo.PublicStatus = utils.DataPublicDefault
  256. chartInfo.ChartPublicClassifyId = 0
  257. err = chartInfo.Update([]string{"PublicStatus", "ChartPublicClassifyId"})
  258. if err != nil {
  259. br.Msg = "保存失败"
  260. br.ErrMsg = "取消图表公共失败,Err:" + err.Error()
  261. return
  262. }
  263. // 修改ES数据
  264. data.AddOrEditChartInfoToEs(chartInfo.ChartInfoId)
  265. // 图表收藏操作处理
  266. go cache.AddDataCollectHandler(chartInfo.ChartInfoId, utils.DataCollectTypeChart)
  267. br.Ret = 200
  268. br.Success = true
  269. br.Msg = "保存成功"
  270. }
  271. // ListByEs
  272. // @Title 图表筛选接口
  273. // @Description 图表筛选接口
  274. // @Success 200 {object} data_manage.ChartInfoList
  275. // @Param request body request.SearchPublicChartReq true "type json string"
  276. // @Success 200 {object} data_manage.ChartInfoFilterDataResp
  277. // @router /chart_info/public/list/es [post]
  278. func (c *ChartPublicController) ListByEs() {
  279. br := new(models.BaseResponse).Init()
  280. defer func() {
  281. c.Data["json"] = br
  282. c.ServeJSON()
  283. }()
  284. var req request.SearchPublicChartReq
  285. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  286. if err != nil {
  287. br.Msg = "参数解析异常!"
  288. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  289. return
  290. }
  291. pageSize := req.PageSize
  292. currentIndex := req.CurrentIndex
  293. var total int64
  294. var startSize int
  295. if pageSize <= 0 {
  296. pageSize = utils.PageSize20
  297. }
  298. if currentIndex <= 0 {
  299. currentIndex = 1
  300. }
  301. startSize = paging.StartIndex(currentIndex, pageSize)
  302. // 获取查询参数
  303. keyword, searchChartPublicList, sourceList, chartTypeList, chartClassifyIdList, publicClassifyIdList, chartAuth, sortMap := data.GetChartSearchPar(req)
  304. total, chartInfoList, err := elastic.SearchChartInfoDataByPublic(keyword, startSize, pageSize, searchChartPublicList, sourceList, chartTypeList, chartClassifyIdList, publicClassifyIdList, chartAuth, c.SysUser.AdminId, sortMap)
  305. if err != nil {
  306. chartInfoList = make([]*data_manage.ChartInfoView, 0)
  307. }
  308. page := paging.GetPaging(currentIndex, pageSize, int(total))
  309. // 因为是ES查找的,所以需要重新查一下图表的信息,主要是为了把是否授权字段找出来
  310. if len(chartInfoList) > 0 {
  311. // 图表map信息
  312. chartInfoMap := make(map[int]*data_manage.ChartInfo)
  313. classifyMap := make(map[int]*data_manage.ChartClassify)
  314. publicClassifyMap := make(map[int]*data_manage.ChartPublicClassify)
  315. // 图表id,分类id,公共分类id
  316. chartInfoIdList := make([]int, 0)
  317. tmpClassifyIdList := make([]int, 0)
  318. tmpPublicClassifyIdList := make([]int, 0)
  319. for _, v := range chartInfoList {
  320. v.ConvertToResp()
  321. v.HaveOperaAuth = true
  322. chartInfoIdList = append(chartInfoIdList, v.ChartInfoId)
  323. tmpClassifyIdList = append(tmpClassifyIdList, v.ChartClassifyId)
  324. tmpPublicClassifyIdList = append(tmpPublicClassifyIdList, v.ChartPublicClassifyId)
  325. }
  326. // 获取所有有权限的图表
  327. {
  328. tmpChartList, err := data_manage.GetChartInfoByIdList(chartInfoIdList)
  329. if err != nil {
  330. br.Msg = "获取失败"
  331. br.ErrMsg = "获取所有有权限的图表失败,Err:" + err.Error()
  332. return
  333. }
  334. for _, v := range tmpChartList {
  335. chartInfoMap[v.ChartInfoId] = v
  336. }
  337. }
  338. // 图表分类
  339. {
  340. tmpList, err := data_manage.GetChartClassifyByIdList(tmpClassifyIdList)
  341. if err != nil {
  342. br.Msg = "获取失败"
  343. br.ErrMsg = "获取所有有权限的图表分类失败,Err:" + err.Error()
  344. return
  345. }
  346. for _, v := range tmpList {
  347. classifyMap[v.ChartClassifyId] = v
  348. }
  349. }
  350. // 公共分类
  351. {
  352. obj := data_manage.ChartPublicClassify{}
  353. tmpList, err := obj.GetChartClassifyByIdList(tmpPublicClassifyIdList)
  354. if err != nil {
  355. br.Msg = "获取失败"
  356. br.ErrMsg = "获取所有有权限的公共分类失败,Err:" + err.Error()
  357. return
  358. }
  359. for _, v := range tmpList {
  360. publicClassifyMap[v.ChartPublicClassifyId] = v
  361. }
  362. }
  363. // 数据重新赋值
  364. for _, v := range chartInfoList {
  365. if tmpChartInfo, ok := chartInfoMap[v.ChartInfoId]; ok {
  366. v.IsJoinPermission = tmpChartInfo.IsJoinPermission
  367. }
  368. // 普通分类
  369. if classifyItem, ok := classifyMap[v.ChartClassifyId]; ok {
  370. v.ClassifyNamePath = classifyItem.ChartClassifyNamePath
  371. }
  372. // 公共分类
  373. if classifyItem, ok := publicClassifyMap[v.ChartPublicClassifyId]; ok {
  374. v.PublicClassifyNamePath = classifyItem.ChartPublicClassifyNamePath
  375. }
  376. }
  377. }
  378. resp := data_manage.ChartInfoFilterDataResp{
  379. Paging: page,
  380. List: chartInfoList,
  381. }
  382. br.Ret = 200
  383. br.Success = true
  384. br.Msg = "获取成功"
  385. br.Data = resp
  386. }
  387. // AllListByEs
  388. // @Title 图表筛选接口
  389. // @Description 图表筛选接口
  390. // @Success 200 {object} data_manage.ChartInfoList
  391. // @Param request body request.SearchChartInfoShareReq true "type json string"
  392. // @Success 200 {object} data_manage.ChartInfoFilterDataResp
  393. // @router /chart_info/public/list/es/all [post]
  394. func (c *ChartPublicController) AllListByEs() {
  395. br := new(models.BaseResponse).Init()
  396. defer func() {
  397. c.Data["json"] = br
  398. c.ServeJSON()
  399. }()
  400. var req request.AllSearchPublicChartReq
  401. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  402. if err != nil {
  403. br.Msg = "参数解析异常!"
  404. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  405. return
  406. }
  407. // 选择所有图表,所以需要通过es获取数据
  408. // 选中的图表id列表
  409. chartInfoList := make([]*data_manage.ChartInfoView, 0)
  410. // 选择所有图表,所以需要通过es获取数据
  411. if req.IsSelectAll {
  412. tmpChartInfoList, err := data.GetAllChartInfoListBySearchPublicChartReq(req.SearchPublicChartReq, c.SysUser.AdminId)
  413. if err != nil {
  414. br.Msg = "获取图表列表失败!"
  415. br.ErrMsg = "获取图表列表失败,Err:" + err.Error()
  416. return
  417. }
  418. // 如果有过滤图表,那么就过滤吧
  419. if len(req.NoChartIdList) > 0 {
  420. noChartIdMap := make(map[int]bool)
  421. for _, v := range req.NoChartIdList {
  422. noChartIdMap[v] = true
  423. }
  424. for _, v := range tmpChartInfoList {
  425. if _, ok := noChartIdMap[v.ChartInfoId]; !ok {
  426. // 如果不在未选中的图表id列表中,那么就加入到选中的图表id列表
  427. chartInfoList = append(chartInfoList, v)
  428. }
  429. }
  430. } else {
  431. chartInfoList = tmpChartInfoList
  432. }
  433. // 因为是ES查找的,所以需要重新查一下图表的信息,主要是为了把是否授权字段找出来
  434. if len(chartInfoList) > 0 {
  435. chartInfoIdList := make([]int, 0)
  436. for _, v := range chartInfoList {
  437. v.ConvertToResp()
  438. v.HaveOperaAuth = true
  439. chartInfoIdList = append(chartInfoIdList, v.ChartInfoId)
  440. }
  441. tmpChartList, err := data_manage.GetChartInfoByIdList(chartInfoIdList)
  442. if err != nil {
  443. br.Msg = "获取失败"
  444. br.ErrMsg = "获取所有有权限的图表失败,Err:" + err.Error()
  445. return
  446. }
  447. chartInfoMap := make(map[int]*data_manage.ChartInfo)
  448. for _, v := range tmpChartList {
  449. chartInfoMap[v.ChartInfoId] = v
  450. }
  451. for _, v := range chartInfoList {
  452. tmpChartInfo, ok := chartInfoMap[v.ChartInfoId]
  453. if !ok {
  454. continue
  455. }
  456. v.IsJoinPermission = tmpChartInfo.IsJoinPermission
  457. }
  458. }
  459. } else {
  460. // 因为是ES查找的,所以需要重新查一下图表的信息,主要是为了把是否授权字段找出来
  461. if len(req.ChartIdList) > 0 {
  462. chartInfoList, err = data_manage.GetChartInfoViewByIdList(req.ChartIdList)
  463. if err != nil {
  464. br.Msg = "获取失败"
  465. br.ErrMsg = "获取所有有权限的图表失败,Err:" + err.Error()
  466. return
  467. }
  468. }
  469. }
  470. resp := data_manage.ChartInfoFilterDataResp{
  471. List: chartInfoList,
  472. }
  473. br.Ret = 200
  474. br.Success = true
  475. br.Msg = "获取成功"
  476. br.Data = resp
  477. }
  478. // BatchMove
  479. // @Title 图表批量移动接口
  480. // @Description 图表批量移动接口
  481. // @Param request body request.MoveChartClassifyReq true "type json string"
  482. // @Success Ret=200 移动成功
  483. // @router /chart_info/public/batch_move [post]
  484. func (c *ChartPublicController) BatchMove() {
  485. br := new(models.BaseResponse).Init()
  486. defer func() {
  487. c.Data["json"] = br
  488. c.ServeJSON()
  489. }()
  490. var req request.MoveChartClassifyReq
  491. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  492. if err != nil {
  493. br.Msg = "参数解析异常!"
  494. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  495. return
  496. }
  497. if req.NewClassifyId <= 0 {
  498. br.Msg = `请选择要转移的新分类`
  499. br.IsSendEmail = false
  500. return
  501. }
  502. // 校验分类
  503. obj := data_manage.ChartPublicClassify{}
  504. publicClassifyItem, err := obj.GetChartClassifyById(req.NewClassifyId)
  505. if err != nil {
  506. br.Msg = "获取公共分类失败!"
  507. br.ErrMsg = "获取公共分类失败!" + err.Error()
  508. return
  509. }
  510. if publicClassifyItem.ChartPublicClassifyId <= 0 {
  511. br.Msg = "公共分类不存在!"
  512. br.ErrMsg = "公共分类不存在!"
  513. return
  514. }
  515. // 只是取公开
  516. req.SearchPublicChartReq.ChartPublicList = []int{3}
  517. chartInfoIdList := make([]int, 0)
  518. if req.IsSelectAll {
  519. // 获取图表
  520. chartInfoList, err := data.GetAllChartInfoListBySearchPublicChartReq(req.SearchPublicChartReq, c.SysUser.AdminId)
  521. if err != nil {
  522. br.Msg = "获取图表列表失败!"
  523. br.ErrMsg = "获取图表列表失败,Err:" + err.Error()
  524. return
  525. }
  526. // 如果有过滤图表,那么就过滤吧
  527. if len(req.NoChartIdList) > 0 {
  528. noChartIdMap := make(map[int]bool)
  529. for _, v := range req.NoChartIdList {
  530. noChartIdMap[v] = true
  531. }
  532. for _, chartInfo := range chartInfoList {
  533. if _, ok := noChartIdMap[chartInfo.ChartInfoId]; !ok {
  534. if chartInfo.PublicStatus != utils.DataPublicSuccess {
  535. br.Msg = `存在未公开的图表:` + chartInfo.ChartName
  536. br.IsSendEmail = false
  537. return
  538. }
  539. // 如果不在未选中的图表id列表中,那么就加入到选中的图表id列表
  540. chartInfoIdList = append(chartInfoIdList, chartInfo.ChartInfoId)
  541. }
  542. }
  543. } else {
  544. for _, chartInfo := range chartInfoList {
  545. if chartInfo.PublicStatus != utils.DataPublicSuccess {
  546. br.Msg = `存在未公开的图表:` + chartInfo.ChartName
  547. br.IsSendEmail = false
  548. return
  549. }
  550. chartInfoIdList = append(chartInfoIdList, chartInfo.ChartInfoId)
  551. }
  552. }
  553. } else {
  554. chartInfoList, err := data_manage.GetChartInfoViewByIdList(req.ChartIdList)
  555. if err != nil {
  556. br.Msg = "获取失败"
  557. br.ErrMsg = "获取所有有权限的图表失败,Err:" + err.Error()
  558. return
  559. }
  560. for _, v := range chartInfoList {
  561. if v.PublicStatus != utils.DataPublicSuccess {
  562. br.Msg = `存在未公开的图表:` + v.ChartName
  563. br.IsSendEmail = false
  564. return
  565. }
  566. }
  567. chartInfoIdList = req.ChartIdList
  568. }
  569. num := len(chartInfoIdList)
  570. if num <= 0 {
  571. br.Msg = `请选择要移动的图表!`
  572. br.IsSendEmail = false
  573. return
  574. }
  575. if num > 100 {
  576. br.Msg = `最多只能选择100条图表!`
  577. br.IsSendEmail = false
  578. return
  579. }
  580. // 开始批量修改图表分类
  581. if len(chartInfoIdList) > 0 {
  582. err = data_manage.UpdatePublicClassifyIdByChartInfoIdList(chartInfoIdList, req.NewClassifyId)
  583. if err != nil {
  584. br.Msg = `图表移动失败!`
  585. br.ErrMsg = `图表移动失败,ERR:` + err.Error()
  586. return
  587. }
  588. }
  589. br.Ret = 200
  590. br.Success = true
  591. br.Msg = "获取成功"
  592. }