edb_permission.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. package data_manage_permission
  2. import (
  3. "eta/eta_mobile/models/data_manage"
  4. "eta/eta_mobile/models/data_manage/data_manage_permission"
  5. "eta/eta_mobile/models/data_manage/excel"
  6. "eta/eta_mobile/models/system"
  7. "eta/eta_mobile/utils"
  8. "fmt"
  9. "github.com/rdlucklib/rdluck_tools/uuid"
  10. "strings"
  11. )
  12. // SetEdbChartPermission
  13. // @Description: 单独给资产(指标、图表、ETA表格)设置权限
  14. // @author: Roc
  15. // @datetime 2024-03-27 10:52:32
  16. // @param source int
  17. // @param subSource int
  18. // @param userId int
  19. // @param authUserList []int
  20. // @param isSelectAll bool
  21. // @param dataId []string
  22. // @param noDataId []string
  23. // @param keyword string
  24. // @param classify string
  25. // @param opUserId int 操作人
  26. // @return err error
  27. // @return errMsg string
  28. func SetEdbChartPermission(source, subSource, userId int, authUserList []int, isSelectAll bool, dataIdList, noDataIdList []string, keyword, classify string, opUserId int) (err error, errMsg string) {
  29. // 如果勾选全部数据,那么
  30. if isSelectAll {
  31. // 找出不要的指标ID列表
  32. noDataIdMap := make(map[string]string, 0)
  33. for _, v := range noDataIdList {
  34. noDataIdMap[v] = v
  35. }
  36. // 需要转义的指标/图表ID列表
  37. dataIdList = make([]string, 0)
  38. // 获取所有指标/图表
  39. list, _, tmpErr := GetMoveEdbChartList(source, subSource, userId, keyword, classify, 0, 100000)
  40. if tmpErr != nil {
  41. err = tmpErr
  42. return
  43. }
  44. for _, v := range list {
  45. if _, ok := noDataIdMap[v.DataId]; !ok {
  46. dataIdList = append(dataIdList, v.DataId)
  47. }
  48. }
  49. }
  50. if len(authUserList) <= 0 {
  51. // 说明是取消权限管控
  52. }
  53. uniqueCode := uuid.NewUUID().Hex32()
  54. title := `数据权限变更`
  55. content := `数据权限`
  56. dataList := make([]data_manage_permission.DataItem, 0)
  57. switch source {
  58. case 3, 4:
  59. //ETA指标库、ETA预测指标
  60. if source == 3 {
  61. content += `(ETA指标库)`
  62. } else {
  63. content += `(ETA预测指标)`
  64. }
  65. tmpList, tmpErr := data_manage.GetEdbInfoListByEdbInfoId(dataIdList)
  66. if tmpErr != nil {
  67. err = tmpErr
  68. return
  69. }
  70. dataIdList = make([]string, 0)
  71. if len(tmpList) > 0 {
  72. for _, v := range tmpList {
  73. dataList = append(dataList, data_manage_permission.DataItem{
  74. DataId: v.EdbInfoId,
  75. DataCode: v.EdbCode,
  76. DataName: v.EdbName,
  77. })
  78. dataIdList = append(dataIdList, fmt.Sprint(v.EdbInfoId))
  79. }
  80. // 重新设置权限
  81. edbInfoType := 0
  82. if source == 4 {
  83. edbInfoType = 1
  84. }
  85. err = data_manage_permission.SetPermissionByEdbIdList(dataIdList, authUserList, edbInfoType)
  86. }
  87. case 5:
  88. //图库
  89. content += `(ETA图库)`
  90. tmpList, tmpErr := data_manage.GetChartInfoListByChartIdList(dataIdList)
  91. if tmpErr != nil {
  92. err = tmpErr
  93. return
  94. }
  95. if len(tmpList) > 0 {
  96. dataIdList = make([]string, 0)
  97. for _, v := range tmpList {
  98. dataList = append(dataList, data_manage_permission.DataItem{
  99. DataId: v.ChartInfoId,
  100. DataCode: fmt.Sprint(v.ChartInfoId),
  101. DataName: v.ChartName,
  102. })
  103. dataIdList = append(dataIdList, fmt.Sprint(v.ChartInfoId))
  104. }
  105. // 重新设置权限
  106. chartSource := utils.CHART_SOURCE_DEFAULT
  107. err = data_manage_permission.SetPermissionByChartIdList(dataIdList, authUserList, chartSource)
  108. }
  109. case 6:
  110. // ETA表格
  111. content += `(ETA表格)`
  112. tmpList, tmpErr := excel.GetNoContentExcelListByExcelInfoIdList(dataIdList)
  113. if tmpErr != nil {
  114. err = tmpErr
  115. return
  116. }
  117. if len(tmpList) > 0 {
  118. dataIdList = make([]string, 0)
  119. for _, v := range tmpList {
  120. dataList = append(dataList, data_manage_permission.DataItem{
  121. DataId: v.ExcelInfoId,
  122. DataCode: fmt.Sprint(v.ExcelInfoId),
  123. DataName: v.ExcelName,
  124. })
  125. dataIdList = append(dataIdList, fmt.Sprint(v.ExcelInfoId))
  126. }
  127. // 重新设置权限
  128. err = data_manage_permission.SetPermissionByExcelIdList(dataIdList, authUserList, subSource)
  129. }
  130. default:
  131. return
  132. }
  133. if err != nil {
  134. return
  135. }
  136. var authRecordErr error
  137. defer func() {
  138. if authRecordErr != nil {
  139. utils.FileLog.Error(fmt.Sprintf("记录未设置记录资产权限的记录失败:%s;source:%d;sub_source:%d;数据ID列表:%s;授权人列表:%v", authRecordErr.Error(), source, subSource, strings.Join(dataIdList, ","), authUserList))
  140. }
  141. }()
  142. // 获取所有在用的用户
  143. cond := ` AND enabled = 1`
  144. pars := make([]interface{}, 0)
  145. adminList, authRecordErr := system.GetSysAdminList(cond, pars, []string{}, "")
  146. if authRecordErr != nil {
  147. return
  148. }
  149. // 如果没有授权人,那么就删除未授权记录
  150. if len(authUserList) < 0 {
  151. authRecordErr = data_manage_permission.DeleteRecordBySourceAndDataIdList(source, subSource, dataIdList)
  152. return
  153. }
  154. userIdMap := make(map[int]int)
  155. for _, tmpUserId := range authUserList {
  156. userIdMap[tmpUserId] = tmpUserId
  157. }
  158. noAuthUserIdList := make([]int, 0)
  159. for _, v := range adminList {
  160. if _, ok := userIdMap[v.AdminId]; !ok {
  161. noAuthUserIdList = append(noAuthUserIdList, v.AdminId)
  162. }
  163. }
  164. content += "已关闭"
  165. // 添加未授权记录
  166. authRecordErr = data_manage_permission.AddRecordBySourceAndDataIdList(source, subSource, dataList, noAuthUserIdList, authUserList, uniqueCode, title, content, opUserId)
  167. return
  168. }
  169. // SetDataClassifyIsPermission
  170. // @Description: 设置资产(指标、图表、ETA表格)分类是否涉密
  171. // @author: Roc
  172. // @datetime 2024-03-27 10:52:32
  173. // @param source int
  174. // @param subSource int
  175. // @param dataId []string
  176. // @param opUserId int 操作人id
  177. // @return err error
  178. // @return errMsg string
  179. func SetDataClassifyIsPermission(source, subSource int, classifyIdList []int, opUserId int) (err error, errMsg string) {
  180. uniqueCode := uuid.NewUUID().Hex32()
  181. title := `数据权限变更`
  182. content := `分类权限`
  183. classifyDataList := make([]data_manage_permission.ClassifyDataItem, 0)
  184. switch source {
  185. case 3, 4:
  186. //ETA指标库、ETA预测指标
  187. if source == 3 {
  188. content += `(ETA指标库)`
  189. } else {
  190. content += `(ETA预测指标)`
  191. }
  192. {
  193. // 分类信息
  194. classifyInfoList, tmpErr := data_manage.GetEdbClassifyByIdList(classifyIdList)
  195. if tmpErr != nil {
  196. err = tmpErr
  197. return
  198. }
  199. for _, v := range classifyInfoList {
  200. classifyDataList = append(classifyDataList, data_manage_permission.ClassifyDataItem{
  201. ClassifyId: v.ClassifyId,
  202. ClassifyName: v.ClassifyName,
  203. })
  204. }
  205. }
  206. // 重新设置权限
  207. classifyType := 0
  208. if source == 4 {
  209. classifyType = 1
  210. }
  211. err = data_manage_permission.SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList, classifyType)
  212. case 5:
  213. //图库
  214. content += `(ETA图库)`
  215. {
  216. // 分类信息
  217. classifyInfoList, tmpErr := data_manage.GetChartClassifyByIdList(classifyIdList)
  218. if tmpErr != nil {
  219. err = tmpErr
  220. return
  221. }
  222. for _, v := range classifyInfoList {
  223. classifyDataList = append(classifyDataList, data_manage_permission.ClassifyDataItem{
  224. ClassifyId: v.ChartClassifyId,
  225. ClassifyName: v.ChartClassifyName,
  226. })
  227. }
  228. }
  229. // 重新设置权限
  230. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  231. err = data_manage_permission.SetIsPermissionByChartClassifyIdList(classifyIdList, chartClassifySource)
  232. case 6:
  233. // ETA表格
  234. content += `(ETA表格)`
  235. {
  236. // 分类信息
  237. classifyInfoList, tmpErr := excel.GetExcelClassifyByIdList(classifyIdList)
  238. if tmpErr != nil {
  239. err = tmpErr
  240. return
  241. }
  242. for _, v := range classifyInfoList {
  243. classifyDataList = append(classifyDataList, data_manage_permission.ClassifyDataItem{
  244. ClassifyId: v.ExcelClassifyId,
  245. ClassifyName: v.ExcelClassifyName,
  246. })
  247. }
  248. }
  249. // 重新设置权限
  250. err = data_manage_permission.SetIsPermissionByExcelClassifyIdList(classifyIdList, subSource)
  251. default:
  252. return
  253. }
  254. if err != nil {
  255. return
  256. }
  257. var authRecordErr error
  258. defer func() {
  259. if authRecordErr != nil {
  260. utils.FileLog.Error(fmt.Sprintf("记录未设置记录资产权限的记录失败:%s;source:%d;sub_source:%d;分类ID列表:%v", authRecordErr.Error(), source, subSource, classifyIdList))
  261. }
  262. }()
  263. // 如果没有涉密的分类,那么就移除所有删除未授权记录
  264. if len(classifyIdList) <= 0 {
  265. authRecordErr = data_manage_permission.DeleteClassifyNoAuthRecordBySourceAndClassifyIdList(source, subSource)
  266. return
  267. }
  268. // 获取所有在用的用户
  269. cond := ` AND enabled = 1`
  270. pars := make([]interface{}, 0)
  271. adminList, authRecordErr := system.GetSysAdminList(cond, pars, []string{}, "")
  272. if authRecordErr != nil {
  273. return
  274. }
  275. noAuthUserIdList := make([]int, 0)
  276. for _, v := range adminList {
  277. noAuthUserIdList = append(noAuthUserIdList, v.AdminId)
  278. }
  279. content += "已关闭"
  280. // 添加未授权记录
  281. authRecordErr = data_manage_permission.AddClassifyNoAuthRecordBySourceAndClassifyIdList(source, subSource, classifyDataList, noAuthUserIdList, uniqueCode, title, content, opUserId)
  282. return
  283. }
  284. // SetEdbChartClassifyPermission
  285. // @Description: 给用户设置涉密分类的权限
  286. // @author: Roc
  287. // @datetime 2024-03-28 14:22:30
  288. // @param source int
  289. // @param subSource int
  290. // @param authUserList []int
  291. // @param classifyIdList []int
  292. // @param opUserId int 操作人id
  293. // @return err error
  294. // @return errMsg string
  295. func SetEdbChartClassifyPermission(source, subSource int, authUserList []int, classifyIdList []int, opUserId int) (err error, errMsg string) {
  296. uniqueCode := uuid.NewUUID().Hex32()
  297. title := `数据权限变更`
  298. content := `分类权限`
  299. secretClassifyInfoList := make([]data_manage_permission.ClassifyDataItem, 0)
  300. if len(classifyIdList) <= 0 {
  301. // 说明是取消权限管控
  302. }
  303. // 先获取所有的涉密分类,然后根据用户去判断那些分类给权限了
  304. switch source {
  305. case 3, 4: //ETA指标库、ETA预测指标
  306. //ETA指标库、ETA预测指标
  307. if source == 3 {
  308. content += `(ETA指标库)`
  309. } else {
  310. content += `(ETA预测指标)`
  311. }
  312. classifyType := 0
  313. if source == 4 {
  314. classifyType = 1
  315. }
  316. {
  317. // 获取已经设置加密的分类信息
  318. classifyInfoList, tmpErr := data_manage.GetEdbClassifyByClassifyTypeAndIsJoinPermission(classifyType, 1)
  319. if tmpErr != nil {
  320. err = tmpErr
  321. return
  322. }
  323. for _, v := range classifyInfoList {
  324. secretClassifyInfoList = append(secretClassifyInfoList, data_manage_permission.ClassifyDataItem{
  325. ClassifyId: v.ClassifyId,
  326. ClassifyName: v.ClassifyName,
  327. })
  328. }
  329. }
  330. // 重新设置权限
  331. err = data_manage_permission.SetPermissionByEdbClassifyIdList(classifyIdList, authUserList, classifyType)
  332. case 5:
  333. subSource = utils.CHART_SOURCE_DEFAULT
  334. //图库
  335. content += `(ETA图库)`
  336. {
  337. // 分类信息
  338. classifyInfoList, tmpErr := data_manage.GetChartClassifyBySourceAndIsJoinPermission(subSource, 1)
  339. if tmpErr != nil {
  340. err = tmpErr
  341. return
  342. }
  343. for _, v := range classifyInfoList {
  344. secretClassifyInfoList = append(secretClassifyInfoList, data_manage_permission.ClassifyDataItem{
  345. ClassifyId: v.ChartClassifyId,
  346. ClassifyName: v.ChartClassifyName,
  347. })
  348. }
  349. }
  350. // 重新设置权限
  351. err = data_manage_permission.SetPermissionByChartClassifyIdList(classifyIdList, authUserList, subSource)
  352. case 6:
  353. // ETA表格
  354. content += `(ETA表格)`
  355. {
  356. // 分类信息
  357. classifyInfoList, tmpErr := excel.GetExcelClassifyBySourceAndIsJoinPermission(subSource, 1)
  358. if tmpErr != nil {
  359. err = tmpErr
  360. return
  361. }
  362. for _, v := range classifyInfoList {
  363. secretClassifyInfoList = append(secretClassifyInfoList, data_manage_permission.ClassifyDataItem{
  364. ClassifyId: v.ExcelClassifyId,
  365. ClassifyName: v.ExcelClassifyName,
  366. })
  367. }
  368. }
  369. err = data_manage_permission.SetPermissionByExcelClassifyIdList(classifyIdList, authUserList, subSource)
  370. default:
  371. return
  372. }
  373. if err != nil {
  374. return
  375. }
  376. var authRecordErr error
  377. defer func() {
  378. if authRecordErr != nil {
  379. utils.FileLog.Error(fmt.Sprintf("记录未设置记录资产权限的记录失败:%s;source:%d;sub_source:%d;分类ID列表:%v", authRecordErr.Error(), source, subSource, classifyIdList))
  380. }
  381. }()
  382. content += "已关闭"
  383. authClassifyIdMap := make(map[int]int)
  384. for _, v := range classifyIdList {
  385. authClassifyIdMap[v] = v
  386. }
  387. noAuthClassifyMap := make(map[int]data_manage_permission.ClassifyDataItem)
  388. for _, classifyInfo := range secretClassifyInfoList {
  389. if _, ok := authClassifyIdMap[classifyInfo.ClassifyId]; !ok {
  390. noAuthClassifyMap[classifyInfo.ClassifyId] = classifyInfo
  391. }
  392. }
  393. // 添加未授权记录
  394. authRecordErr = data_manage_permission.AddClassifyNoAuthRecordBySourceAndUserIdList(source, subSource, noAuthClassifyMap, authUserList, uniqueCode, title, content, opUserId)
  395. return
  396. }
  397. // GetEdbChartClassifyIdListPermissionByUserId
  398. // @Description: 根据用户id获取已经配置的分类id列表
  399. // @author: Roc
  400. // @datetime 2024-03-29 16:26:10
  401. // @param source int
  402. // @param subSource int
  403. // @param userId int
  404. // @return idList []int
  405. // @return err error
  406. func GetEdbChartClassifyIdListPermissionByUserId(source, subSource, userId int) (idList []int, err error) {
  407. switch source {
  408. case 3, 4: //ETA指标库、ETA预测指标
  409. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  410. //if tmpErr != nil {
  411. // err = tmpErr
  412. // return
  413. //}
  414. //if len(tmpList) > 0 {
  415. //}
  416. // 重新设置权限
  417. classifyType := 0
  418. if source == 4 {
  419. classifyType = 1
  420. }
  421. idList, err = data_manage_permission.GetPermissionEdbClassifyIdListByUserId(userId, classifyType)
  422. case 5:
  423. //图库
  424. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  425. idList, err = data_manage_permission.GetPermissionChartClassifyIdListByUserId(userId, chartClassifySource)
  426. case 6:
  427. // ETA表格
  428. idList, err = data_manage_permission.GetPermissionExcelClassifyIdListByUserId(userId, subSource)
  429. default:
  430. return
  431. }
  432. return
  433. }
  434. // GetUserIdListPermissionByDataId
  435. // @Description: 根据资产(指标、图表、表格)id获取已经配置的用户id
  436. // @author: Roc
  437. // @datetime 2024-03-29 16:26:10
  438. // @param source int
  439. // @param subSource int
  440. // @param dataId int
  441. // @return idList []int
  442. // @return err error
  443. func GetUserIdListPermissionByDataId(source, subSource, dataId int) (idList []int, err error) {
  444. switch source {
  445. case 3, 4:
  446. // ETA指标库、ETA预测指标
  447. edbInfoType := 0
  448. if source == 4 {
  449. edbInfoType = 1
  450. }
  451. idList, err = data_manage_permission.GetPermissionUserIdListByEdbId(dataId, edbInfoType)
  452. case 5:
  453. // 图库
  454. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  455. idList, err = data_manage_permission.GetPermissionUserIdListByChartId(dataId, chartClassifySource)
  456. case 6:
  457. // ETA表格
  458. idList, err = data_manage_permission.GetPermissionUserIdListByExcelId(dataId, subSource)
  459. default:
  460. return
  461. }
  462. return
  463. }
  464. // GetUserIdListNoPermissionByDataId
  465. // @Description: 根据资产(指标、图表、表格)id获取没有该资产分类权限的用户id
  466. // @author: Roc
  467. // @datetime 2024-03-29 16:26:10
  468. // @param source int
  469. // @param subSource int
  470. // @param dataId int
  471. // @return idList []int
  472. // @return err error
  473. func GetUserIdListNoPermissionByDataId(source, subSource, dataId int) (idList []int, err error) {
  474. // 已经授权的用户map
  475. authIdList := make([]int, 0)
  476. switch source {
  477. case 3, 4:
  478. // ETA指标库、ETA预测指标
  479. edbInfoType := 0
  480. if source == 4 {
  481. edbInfoType = 1
  482. }
  483. // 获取指标
  484. edbInfoItem, tmpErr := data_manage.GetEdbInfoById(dataId)
  485. if tmpErr != nil {
  486. err = tmpErr
  487. return
  488. }
  489. // 获取分类
  490. classifyItem, tmpErr := data_manage.GetEdbClassifyById(edbInfoItem.ClassifyId)
  491. if tmpErr != nil {
  492. err = tmpErr
  493. return
  494. }
  495. // 判断分类是否涉密,不涉密就直接返回
  496. if classifyItem.IsJoinPermission == 0 {
  497. return
  498. }
  499. // 获取已经配置分类权限的用户ID列表
  500. authIdList, err = data_manage_permission.GetPermissionUserIdListByEdbClassifyId(dataId, edbInfoType)
  501. case 5:
  502. // 图库
  503. // 获取图表
  504. chartInfoItem, tmpErr := data_manage.GetChartInfoById(dataId)
  505. if tmpErr != nil {
  506. err = tmpErr
  507. return
  508. }
  509. // 获取分类
  510. classifyItem, tmpErr := data_manage.GetChartClassifyById(chartInfoItem.ChartClassifyId)
  511. if tmpErr != nil {
  512. err = tmpErr
  513. return
  514. }
  515. // 判断分类是否涉密,不涉密就直接返回
  516. if classifyItem.IsJoinPermission == 0 {
  517. return
  518. }
  519. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  520. authIdList, err = data_manage_permission.GetPermissionUserIdListByChartClassifyId(dataId, chartClassifySource)
  521. case 6:
  522. // ETA表格
  523. // 获取图表
  524. excelInfoItem, tmpErr := excel.GetNoContentExcelInfoByExcelId(dataId)
  525. if tmpErr != nil {
  526. err = tmpErr
  527. return
  528. }
  529. // 获取分类
  530. classifyItem, tmpErr := excel.GetExcelClassifyById(excelInfoItem.ExcelClassifyId)
  531. if tmpErr != nil {
  532. err = tmpErr
  533. return
  534. }
  535. // 判断分类是否涉密,不涉密就直接返回
  536. if classifyItem.IsJoinPermission == 0 {
  537. return
  538. }
  539. authIdList, err = data_manage_permission.GetPermissionUserIdListByExcelClassifyId(dataId, subSource)
  540. default:
  541. return
  542. }
  543. // 已经授权的用户map
  544. authUserIdMap := make(map[int]int)
  545. for _, v := range authIdList {
  546. authUserIdMap[v] = v
  547. }
  548. // 获取所有在用的用户
  549. cond := ` AND enabled = 1`
  550. pars := make([]interface{}, 0)
  551. adminList, authRecordErr := system.GetSysAdminList(cond, pars, []string{}, "")
  552. if authRecordErr != nil {
  553. return
  554. }
  555. for _, v := range adminList {
  556. if _, ok := authUserIdMap[v.AdminId]; !ok {
  557. idList = append(idList, v.AdminId)
  558. }
  559. }
  560. return
  561. }
  562. // InheritParentClassify
  563. // @Description: 继承父级分类的涉密权限
  564. // @author: Roc
  565. // @datetime 2024-04-07 21:09:16
  566. // @param source int
  567. // @param subSource int
  568. // @param classifyId int
  569. // @param parentClassifyId int
  570. // @param classifyName string
  571. func InheritParentClassify(source, subSource, classifyId, parentClassifyId int, classifyName string) {
  572. var err error
  573. defer func() {
  574. if err != nil {
  575. fmt.Println(fmt.Sprintf("继承父级分类失败:%s;source:%d;sub_source:%d;分类ID列表:%v", err.Error(), source, subSource, classifyId))
  576. utils.FileLog.Error(fmt.Sprintf("继承父级分类失败:%s;source:%d;sub_source:%d;分类ID列表:%v", err.Error(), source, subSource, classifyId))
  577. }
  578. }()
  579. // 一级分类不用继承
  580. if parentClassifyId <= 0 {
  581. return
  582. }
  583. uniqueCode := uuid.NewUUID().Hex32()
  584. switch source {
  585. case 3, 4:
  586. //ETA指标库、ETA预测指标
  587. // 分类信息
  588. parentClassifyInfo, tmpErr := data_manage.GetEdbClassifyById(parentClassifyId)
  589. if tmpErr != nil {
  590. err = tmpErr
  591. return
  592. }
  593. // 没有标记涉密那么就忽略
  594. if parentClassifyInfo.IsJoinPermission == 0 {
  595. return
  596. }
  597. // 重新设置权限
  598. classifyType := 0
  599. if source == 4 {
  600. classifyType = 1
  601. }
  602. err = data_manage_permission.InheritParentClassifyByEdbClassifyId(source, classifyType, classifyId, parentClassifyId, classifyName, uniqueCode)
  603. case 5:
  604. //图库
  605. // 分类信息
  606. parentClassifyInfo, tmpErr := data_manage.GetChartClassifyById(parentClassifyId)
  607. if tmpErr != nil {
  608. err = tmpErr
  609. return
  610. }
  611. // 没有标记涉密那么就忽略
  612. if parentClassifyInfo.IsJoinPermission == 0 {
  613. return
  614. }
  615. // 重新设置权限
  616. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  617. err = data_manage_permission.InheritParentClassifyByChartClassifyId(source, chartClassifySource, classifyId, parentClassifyId, classifyName, uniqueCode)
  618. case 6:
  619. // ETA表格
  620. // 分类信息
  621. parentClassifyInfo, tmpErr := excel.GetExcelClassifyById(parentClassifyId)
  622. if tmpErr != nil {
  623. err = tmpErr
  624. return
  625. }
  626. // 没有标记涉密那么就忽略
  627. if parentClassifyInfo.IsJoinPermission == 0 {
  628. return
  629. }
  630. // 重新设置权限
  631. err = data_manage_permission.InheritParentClassifyByExcelClassifyId(source, subSource, classifyId, parentClassifyId, classifyName, uniqueCode)
  632. default:
  633. return
  634. }
  635. }