package data_manage_permission import ( "eta_gn/eta_api/models/data_manage/data_manage_permission" "eta_gn/eta_api/models/data_manage/excel" "eta_gn/eta_api/utils" "fmt" ) func CheckExcelPermissionByPermissionIdList(excelIsJoinPermission, excelClassifyIsJoinPermission, excelInfoId, excelClassifyId int, permissionExcelInfoIdList, permissionExcelClassifyIdList []int) (hasAuth bool) { if excelClassifyIsJoinPermission == 1 { if !utils.InArrayByInt(permissionExcelClassifyIdList, excelClassifyId) { return false } } if excelIsJoinPermission == 1 { if !utils.InArrayByInt(permissionExcelInfoIdList, excelInfoId) { return false } } hasAuth = true return } func CheckExcelClassifyPermissionByPermissionIdList(excelClassifyIsJoinPermission, excelClassifyId int, permissionExcelClassifyIdList []int) (hasAuth bool) { if excelClassifyIsJoinPermission == 1 { if !utils.InArrayByInt(permissionExcelClassifyIdList, excelClassifyId) { return } } hasAuth = true return } func GetUserExcelAndClassifyPermissionList(userId, excelInfoId, classifyId int) (excelIdList, classifyIdList []int, err error) { excelIdList, err = data_manage_permission.GetPermissionExcelIdList(userId, excelInfoId) if err != nil { fmt.Println("获取授权指标列表失败, err:", err) return } classifyIdList, err = data_manage_permission.GetPermissionExcelClassifyIdList(userId, classifyId) if err != nil { fmt.Println("获取授权指标分类列表失败, err:", err) return } return } func CheckExcelPermissionByExcelInfoId(excelInfoId, excelClassifyId, excelIsJoinPermission, userId int) (hasAuth bool, err error) { currClassify, err := excel.GetExcelClassifyById(excelClassifyId) if err != nil { return } if currClassify != nil { return CheckExcelPermission(excelIsJoinPermission, currClassify.IsJoinPermission, userId, excelInfoId, excelClassifyId) } return } func CheckExcelPermission(excelIsJoinPermission, excelClassifyIsJoinPermission, userId, excelInfoId, excelClassifyId int) (hasAuth bool, err error) { excelIdList, classifyIdList, err := GetUserExcelAndClassifyPermissionList(userId, excelInfoId, excelClassifyId) if err != nil { fmt.Println("GetUserExcelAndClassifyPermissionList err:", err) return } hasAuth = CheckExcelPermissionByPermissionIdList(excelIsJoinPermission, excelClassifyIsJoinPermission, excelInfoId, excelClassifyId, excelIdList, classifyIdList) return }