edb_permission.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. package data_manage_permission
  2. import (
  3. "eta/eta_api/models/data_manage/data_manage_permission"
  4. "eta/eta_api/utils"
  5. )
  6. // SetEdbChartPermission
  7. // @Description: 单独给资产(指标、图表、ETA表格)设置权限
  8. // @author: Roc
  9. // @datetime 2024-03-27 10:52:32
  10. // @param source int
  11. // @param subSource int
  12. // @param userId int
  13. // @param userList []int
  14. // @param isSelectAll bool
  15. // @param dataId []string
  16. // @param noDataId []string
  17. // @param keyword string
  18. // @param classify string
  19. // @return err error
  20. // @return errMsg string
  21. func SetEdbChartPermission(source, subSource, userId int, userList []int, isSelectAll bool, dataIdList, noDataIdList []string, keyword, classify string) (err error, errMsg string) {
  22. // TODO 消息通知
  23. // 如果勾选全部数据,那么
  24. if isSelectAll {
  25. // 找出不要的指标ID列表
  26. noDataIdMap := make(map[string]string, 0)
  27. for _, v := range noDataIdList {
  28. noDataIdMap[v] = v
  29. }
  30. // 需要转义的指标/图表ID列表
  31. dataIdList = make([]string, 0)
  32. // 获取所有指标/图表
  33. list, _, tmpErr := GetMoveEdbChartList(source, subSource, userId, keyword, classify, 0, 100000)
  34. if tmpErr != nil {
  35. err = tmpErr
  36. return
  37. }
  38. for _, v := range list {
  39. if _, ok := noDataIdMap[v.DataId]; !ok {
  40. dataIdList = append(dataIdList, v.DataId)
  41. }
  42. }
  43. }
  44. if len(userList) <= 0 {
  45. // 说明是取消权限管控
  46. }
  47. switch source {
  48. case 3, 4: //ETA指标库、ETA预测指标
  49. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  50. //if tmpErr != nil {
  51. // err = tmpErr
  52. // return
  53. //}
  54. //if len(tmpList) > 0 {
  55. //}
  56. // 重新设置权限
  57. edbInfoType := 0
  58. if source == 4 {
  59. edbInfoType = 1
  60. }
  61. err = data_manage_permission.SetPermissionByEdbIdList(dataIdList, userList, edbInfoType)
  62. case 5: //图库
  63. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  64. //if tmpErr != nil {
  65. // err = tmpErr
  66. // return
  67. //}
  68. //if len(tmpList) > 0 {
  69. //}
  70. // 重新设置权限
  71. chartSource := utils.CHART_SOURCE_DEFAULT
  72. err = data_manage_permission.SetPermissionByChartIdList(dataIdList, userList, chartSource)
  73. case 6: // ETA表格
  74. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  75. //if tmpErr != nil {
  76. // err = tmpErr
  77. // return
  78. //}
  79. //if len(tmpList) > 0 {
  80. //}
  81. // 重新设置权限
  82. err = data_manage_permission.SetPermissionByExcelIdList(dataIdList, userList, subSource)
  83. default:
  84. return
  85. }
  86. return
  87. }
  88. // SetDataIsPermission
  89. // @Description: 设置资产(指标、图表、ETA表格)分类是否涉密
  90. // @author: Roc
  91. // @datetime 2024-03-27 10:52:32
  92. // @param source int
  93. // @param subSource int
  94. // @param dataId []string
  95. // @return err error
  96. // @return errMsg string
  97. func SetDataIsPermission(source, subSource int, classifyIdList []int) (err error, errMsg string) {
  98. // TODO 消息通知
  99. switch source {
  100. case 3, 4: //ETA指标库、ETA预测指标
  101. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  102. //if tmpErr != nil {
  103. // err = tmpErr
  104. // return
  105. //}
  106. //if len(tmpList) > 0 {
  107. //}
  108. // 重新设置权限
  109. classifyType := 0
  110. if source == 4 {
  111. classifyType = 1
  112. }
  113. err = data_manage_permission.SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList, classifyType)
  114. case 5: //图库
  115. // 重新设置权限
  116. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  117. err = data_manage_permission.SetIsPermissionByChartClassifyIdList(classifyIdList, chartClassifySource)
  118. case 6:
  119. // ETA表格
  120. // 重新设置权限
  121. err = data_manage_permission.SetIsPermissionByExcelClassifyIdList(classifyIdList, subSource)
  122. default:
  123. return
  124. }
  125. return
  126. }
  127. // SetEdbChartClassifyPermission
  128. // @Description: 给用户设置涉密分类的权限
  129. // @author: Roc
  130. // @datetime 2024-03-28 14:22:30
  131. // @param source int
  132. // @param subSource int
  133. // @param userList []int
  134. // @param classifyIdList []int
  135. // @return err error
  136. // @return errMsg string
  137. func SetEdbChartClassifyPermission(source, subSource int, userList []int, classifyIdList []int) (err error, errMsg string) {
  138. // TODO 消息通知
  139. if len(classifyIdList) <= 0 {
  140. // 说明是取消权限管控
  141. }
  142. switch source {
  143. case 3, 4: //ETA指标库、ETA预测指标
  144. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  145. //if tmpErr != nil {
  146. // err = tmpErr
  147. // return
  148. //}
  149. //if len(tmpList) > 0 {
  150. //}
  151. // 重新设置权限
  152. classifyType := 0
  153. if source == 4 {
  154. classifyType = 1
  155. }
  156. err = data_manage_permission.SetPermissionByEdbClassifyIdList(classifyIdList, userList, classifyType)
  157. case 5: //图库
  158. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  159. //if tmpErr != nil {
  160. // err = tmpErr
  161. // return
  162. //}
  163. //if len(tmpList) > 0 {
  164. //}
  165. // 重新设置权限
  166. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  167. err = data_manage_permission.SetPermissionByChartClassifyIdList(classifyIdList, userList, chartClassifySource)
  168. case 6:
  169. // ETA表格
  170. err = data_manage_permission.SetPermissionByExcelClassifyIdList(classifyIdList, userList, subSource)
  171. default:
  172. return
  173. }
  174. return
  175. }
  176. // GetEdbChartClassifyIdListPermissionByUserId
  177. // @Description: 根据用户id获取已经配置的分类id列表
  178. // @author: Roc
  179. // @datetime 2024-03-29 16:26:10
  180. // @param source int
  181. // @param subSource int
  182. // @param userId int
  183. // @return idList []int
  184. // @return err error
  185. func GetEdbChartClassifyIdListPermissionByUserId(source, subSource, userId int) (idList []int, err error) {
  186. switch source {
  187. case 3, 4: //ETA指标库、ETA预测指标
  188. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  189. //if tmpErr != nil {
  190. // err = tmpErr
  191. // return
  192. //}
  193. //if len(tmpList) > 0 {
  194. //}
  195. // 重新设置权限
  196. classifyType := 0
  197. if source == 4 {
  198. classifyType = 1
  199. }
  200. idList, err = data_manage_permission.GetPermissionEdbClassifyIdListByUserId(userId, classifyType)
  201. case 5:
  202. //图库
  203. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  204. idList, err = data_manage_permission.GetPermissionChartClassifyIdListByUserId(userId, chartClassifySource)
  205. case 6:
  206. // ETA表格
  207. idList, err = data_manage_permission.GetPermissionExcelClassifyIdListByUserId(userId, subSource)
  208. default:
  209. return
  210. }
  211. return
  212. }
  213. // GetEdbChartIdListPermissionByDataId
  214. // @Description: 根据用户id获取已经配置的资产(指标、图表、表格)id列表
  215. // @author: Roc
  216. // @datetime 2024-03-29 16:26:10
  217. // @param source int
  218. // @param subSource int
  219. // @param dataId int
  220. // @return idList []int
  221. // @return err error
  222. func GetEdbChartIdListPermissionByDataId(source, subSource, dataId int) (idList []int, err error) {
  223. switch source {
  224. case 3, 4: //ETA指标库、ETA预测指标
  225. //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
  226. //if tmpErr != nil {
  227. // err = tmpErr
  228. // return
  229. //}
  230. //if len(tmpList) > 0 {
  231. //}
  232. edbInfoType := 0
  233. if source == 4 {
  234. edbInfoType = 1
  235. }
  236. idList, err = data_manage_permission.GetPermissionEdbIdListByDataId(dataId, edbInfoType)
  237. case 5:
  238. //图库
  239. chartClassifySource := utils.CHART_SOURCE_DEFAULT
  240. idList, err = data_manage_permission.GetPermissionChartIdListByDataId(dataId, chartClassifySource)
  241. case 6:
  242. // ETA表格
  243. idList, err = data_manage_permission.GetPermissionExcelIdListByDataId(dataId, subSource)
  244. default:
  245. return
  246. }
  247. return
  248. }