123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- package data_manage_permission
- import (
- "eta/eta_api/models/data_manage/data_manage_permission"
- "eta/eta_api/utils"
- )
- // SetEdbChartPermission
- // @Description: 单独给资产(指标、图表、ETA表格)设置权限
- // @author: Roc
- // @datetime 2024-03-27 10:52:32
- // @param source int
- // @param subSource int
- // @param userId int
- // @param userList []int
- // @param isSelectAll bool
- // @param dataId []string
- // @param noDataId []string
- // @param keyword string
- // @param classify string
- // @return err error
- // @return errMsg string
- func SetEdbChartPermission(source, subSource, userId int, userList []int, isSelectAll bool, dataIdList, noDataIdList []string, keyword, classify string) (err error, errMsg string) {
- // TODO 消息通知
- // 如果勾选全部数据,那么
- if isSelectAll {
- // 找出不要的指标ID列表
- noDataIdMap := make(map[string]string, 0)
- for _, v := range noDataIdList {
- noDataIdMap[v] = v
- }
- // 需要转义的指标/图表ID列表
- dataIdList = make([]string, 0)
- // 获取所有指标/图表
- list, _, tmpErr := GetMoveEdbChartList(source, subSource, userId, keyword, classify, 0, 100000)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- for _, v := range list {
- if _, ok := noDataIdMap[v.DataId]; !ok {
- dataIdList = append(dataIdList, v.DataId)
- }
- }
- }
- if len(userList) <= 0 {
- // 说明是取消权限管控
- }
- switch source {
- case 3, 4: //ETA指标库、ETA预测指标
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- // 重新设置权限
- edbInfoType := 0
- if source == 4 {
- edbInfoType = 1
- }
- err = data_manage_permission.SetPermissionByEdbIdList(dataIdList, userList, edbInfoType)
- case 5: //图库
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- // 重新设置权限
- chartSource := utils.CHART_SOURCE_DEFAULT
- err = data_manage_permission.SetPermissionByChartIdList(dataIdList, userList, chartSource)
- case 6: // ETA表格
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- // 重新设置权限
- err = data_manage_permission.SetPermissionByExcelIdList(dataIdList, userList, subSource)
- default:
- return
- }
- return
- }
- // SetDataIsPermission
- // @Description: 设置资产(指标、图表、ETA表格)分类是否涉密
- // @author: Roc
- // @datetime 2024-03-27 10:52:32
- // @param source int
- // @param subSource int
- // @param dataId []string
- // @return err error
- // @return errMsg string
- func SetDataIsPermission(source, subSource int, classifyIdList []int) (err error, errMsg string) {
- // TODO 消息通知
- switch source {
- case 3, 4: //ETA指标库、ETA预测指标
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- // 重新设置权限
- classifyType := 0
- if source == 4 {
- classifyType = 1
- }
- err = data_manage_permission.SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList, classifyType)
- case 5: //图库
- // 重新设置权限
- chartClassifySource := utils.CHART_SOURCE_DEFAULT
- err = data_manage_permission.SetIsPermissionByChartClassifyIdList(classifyIdList, chartClassifySource)
- case 6:
- // ETA表格
- // 重新设置权限
- err = data_manage_permission.SetIsPermissionByExcelClassifyIdList(classifyIdList, subSource)
- default:
- return
- }
- return
- }
- // SetEdbChartClassifyPermission
- // @Description: 给用户设置涉密分类的权限
- // @author: Roc
- // @datetime 2024-03-28 14:22:30
- // @param source int
- // @param subSource int
- // @param userList []int
- // @param classifyIdList []int
- // @return err error
- // @return errMsg string
- func SetEdbChartClassifyPermission(source, subSource int, userList []int, classifyIdList []int) (err error, errMsg string) {
- // TODO 消息通知
- if len(classifyIdList) <= 0 {
- // 说明是取消权限管控
- }
- switch source {
- case 3, 4: //ETA指标库、ETA预测指标
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- // 重新设置权限
- classifyType := 0
- if source == 4 {
- classifyType = 1
- }
- err = data_manage_permission.SetPermissionByEdbClassifyIdList(classifyIdList, userList, classifyType)
- case 5: //图库
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- // 重新设置权限
- chartClassifySource := utils.CHART_SOURCE_DEFAULT
- err = data_manage_permission.SetPermissionByChartClassifyIdList(classifyIdList, userList, chartClassifySource)
- case 6:
- // ETA表格
- err = data_manage_permission.SetPermissionByExcelClassifyIdList(classifyIdList, userList, subSource)
- default:
- return
- }
- return
- }
- // GetEdbChartClassifyIdListPermissionByUserId
- // @Description: 根据用户id获取已经配置的分类id列表
- // @author: Roc
- // @datetime 2024-03-29 16:26:10
- // @param source int
- // @param subSource int
- // @param userId int
- // @return idList []int
- // @return err error
- func GetEdbChartClassifyIdListPermissionByUserId(source, subSource, userId int) (idList []int, err error) {
- switch source {
- case 3, 4: //ETA指标库、ETA预测指标
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- // 重新设置权限
- classifyType := 0
- if source == 4 {
- classifyType = 1
- }
- idList, err = data_manage_permission.GetPermissionEdbClassifyIdListByUserId(userId, classifyType)
- case 5:
- //图库
- chartClassifySource := utils.CHART_SOURCE_DEFAULT
- idList, err = data_manage_permission.GetPermissionChartClassifyIdListByUserId(userId, chartClassifySource)
- case 6:
- // ETA表格
- idList, err = data_manage_permission.GetPermissionExcelClassifyIdListByUserId(userId, subSource)
- default:
- return
- }
- return
- }
- // GetEdbChartIdListPermissionByDataId
- // @Description: 根据用户id获取已经配置的资产(指标、图表、表格)id列表
- // @author: Roc
- // @datetime 2024-03-29 16:26:10
- // @param source int
- // @param subSource int
- // @param dataId int
- // @return idList []int
- // @return err error
- func GetEdbChartIdListPermissionByDataId(source, subSource, dataId int) (idList []int, err error) {
- switch source {
- case 3, 4: //ETA指标库、ETA预测指标
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
- //if tmpErr != nil {
- // err = tmpErr
- // return
- //}
- //if len(tmpList) > 0 {
- //}
- edbInfoType := 0
- if source == 4 {
- edbInfoType = 1
- }
- idList, err = data_manage_permission.GetPermissionEdbIdListByDataId(dataId, edbInfoType)
- case 5:
- //图库
- chartClassifySource := utils.CHART_SOURCE_DEFAULT
- idList, err = data_manage_permission.GetPermissionChartIdListByDataId(dataId, chartClassifySource)
- case 6:
- // ETA表格
- idList, err = data_manage_permission.GetPermissionExcelIdListByDataId(dataId, subSource)
- default:
- return
- }
- return
- }
|