123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- package data
- import (
- "eta/eta_api/models/data_manage"
- "eta/eta_api/utils"
- "fmt"
- )
- func SetEdbChartPermission(source, subSource, userId int, userList []int, isSelectAll bool, dataId, noDataId []string, keyword, classify string) (err error, errMsg string) {
-
-
- if isSelectAll {
-
- noDataIdMap := make(map[string]string, 0)
- for _, v := range noDataId {
- noDataIdMap[v] = v
- }
-
- dataId = 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 {
- dataId = append(dataId, v.DataId)
- }
- }
- }
- if len(userList) <= 0 {
-
- }
- switch source {
- case 3, 4:
-
-
-
-
-
-
-
-
- err = data_manage.SetPermissionEdbChartByEdbIdList(dataId, userList)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- default:
- return
- }
- return
- }
- func SetDataIsPermission(source, subSource int, classifyIdList []int) (err error, errMsg string) {
-
- switch source {
- case 3, 4:
-
-
-
-
-
-
-
-
- err = data_manage.SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList)
-
-
- default:
- return
- }
- return
- }
- func SetEdbChartClassifyPermission(source, subSource int, userList []int, classifyIdList []int) (err error, errMsg string) {
-
- if len(classifyIdList) <= 0 {
-
- }
- switch source {
- case 3, 4:
-
-
-
-
-
-
-
-
- err = data_manage.SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList, userList)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- default:
- return
- }
- return
- }
- func GetUserEdbAndClassifyPermissionList(userId, edbInfoId, classifyId int) (edbIdList, classifyIdList []int, err error) {
- edbIdList, err = data_manage.GetPermissionEdbIdList(userId, edbInfoId)
- if err != nil {
- fmt.Println("获取授权指标列表失败, err:", err)
- return
- }
- classifyIdList, err = data_manage.GetPermissionEdbClassifyIdList(userId, classifyId)
- if err != nil {
- fmt.Println("获取授权指标分类列表失败, err:", err)
- return
- }
- return
- }
- func CheckEdbPermission(edbIsJoinPermission, edbClassifyIsJoinPermission, userId, edbInfoId, edbClassifyId int) (hasAuth bool, err error) {
- edbIdList, classifyIdList, err := GetUserEdbAndClassifyPermissionList(userId, edbInfoId, edbClassifyId)
- if err != nil {
- fmt.Println("GetUserEdbAndClassifyPermissionList err:", err)
- return
- }
- hasAuth = CheckEdbPermissionByPermissionIdList(edbIsJoinPermission, edbClassifyIsJoinPermission, edbInfoId, edbClassifyId, edbIdList, classifyIdList)
- return
- }
- func CheckEdbPermissionByPermissionIdList(edbIsJoinPermission, edbClassifyIsJoinPermission, edbInfoId, edbClassifyId int, permissionEdbInfoIdList, permissionEdbClassifyIdList []int) (hasAuth bool) {
-
-
- if edbClassifyIsJoinPermission == 1 {
-
- if !utils.InArrayByInt(permissionEdbClassifyIdList, edbClassifyId) {
- return false
- }
- }
-
- if edbIsJoinPermission == 1 {
-
- if !utils.InArrayByInt(permissionEdbInfoIdList, edbInfoId) {
- return false
- }
- }
- hasAuth = true
- return
- }
|