12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package data_manage_permission
- import (
- "eta_gn/eta_api/models/data_manage"
- "eta_gn/eta_api/models/data_manage/data_manage_permission"
- "eta_gn/eta_api/utils"
- "fmt"
- )
- func CheckChartPermissionByPermissionIdList(chartIsJoinPermission, chartClassifyIsJoinPermission, chartInfoId, chartClassifyId int, permissionChartInfoIdList, permissionChartClassifyIdList []int) (hasAuth bool) {
- if chartClassifyIsJoinPermission == 1 {
- if !utils.InArrayByInt(permissionChartClassifyIdList, chartClassifyId) {
- return false
- }
- }
- if chartIsJoinPermission == 1 {
- if !utils.InArrayByInt(permissionChartInfoIdList, chartInfoId) {
- return false
- }
- }
- hasAuth = true
- return
- }
- func CheckChartClassifyPermissionByPermissionIdList(chartClassifyIsJoinPermission, chartClassifyId int, permissionChartClassifyIdList []int) (hasAuth bool) {
- if chartClassifyIsJoinPermission == 1 {
- if !utils.InArrayByInt(permissionChartClassifyIdList, chartClassifyId) {
- return
- }
- }
- hasAuth = true
- return
- }
- func GetUserChartAndClassifyPermissionList(userId, chartInfoId, classifyId int) (chartIdList, classifyIdList []int, err error) {
- chartIdList, err = data_manage_permission.GetPermissionChartIdList(userId, chartInfoId)
- if err != nil {
- fmt.Println("获取授权指标列表失败, err:", err)
- return
- }
- classifyIdList, err = data_manage_permission.GetPermissionChartClassifyIdList(userId, classifyId)
- if err != nil {
- fmt.Println("获取授权指标分类列表失败, err:", err)
- return
- }
- return
- }
- func GetUserChartClassifyPermissionList(userId, classifyId int) (classifyIdList []int, err error) {
- classifyIdList, err = data_manage_permission.GetPermissionChartClassifyIdList(userId, classifyId)
- if err != nil {
- fmt.Println("获取授权指标分类列表失败, err:", err)
- return
- }
- return
- }
- func CheckChartPermissionByChartInfoId(chartInfoId, chartClassifyId, chartIsJoinPermission, userId int) (hasAuth bool, err error) {
- currClassify, err := data_manage.GetChartClassifyById(chartClassifyId)
- if err != nil {
- return
- }
- if currClassify != nil {
- return CheckChartPermission(chartIsJoinPermission, currClassify.IsJoinPermission, userId, chartInfoId, chartClassifyId)
- }
- return
- }
- func CheckChartPermission(chartIsJoinPermission, chartClassifyIsJoinPermission, userId, chartInfoId, chartClassifyId int) (hasAuth bool, err error) {
- chartIdList, classifyIdList, err := GetUserChartAndClassifyPermissionList(userId, chartInfoId, chartClassifyId)
- if err != nil {
- fmt.Println("GetUserChartAndClassifyPermissionList err:", err)
- return
- }
- hasAuth = CheckChartPermissionByPermissionIdList(chartIsJoinPermission, chartClassifyIsJoinPermission, chartInfoId, chartClassifyId, chartIdList, classifyIdList)
- return
- }
|