コード例 #1
0
        public ActionResult <GetPageDatasOutput> GetPageDatas([FromBody] Dto.GetPageDatasInput input)
        {
            IEnumerable <string> permissionNames = _claimManager.GetPermissionsForClaims(User.Claims);
            var permissions = _permissionManager.GetPermissionsForCache().Where(e => permissionNames.Contains(e.Name));

            Services.ManageHome.CMS.Pages.Dto.GetPageDatasInput appServiceInput = new Services.ManageHome.CMS.Pages.Dto.GetPageDatasInput();
            appServiceInput.PageIndex = input.PageIndex;
            appServiceInput.PageSize  = input.PageSize;
            appServiceInput.SearchKey = input.SearchKey;
            appServiceInput.Top       = input.Top;
            appServiceInput.Tags      = input.Tags;
            appServiceInput.Orderby   = input.Orderby;
            appServiceInput.PageName  = input.PageName;

            // 如果用户具有 Page 域 的权限,则用户具有所有页面的访问权限
            if (_checkPermissionService.IsAllowAccess(ApiScopeProvider.Page, true, permissions))
            {
                appServiceInput.EnablePageFilter = false;
            }
            else
            {
                appServiceInput.EnablePageFilter = true;

                appServiceInput.FilterPageNames = _pageManager.GetPagesForQueryPermission(permissions).Select(e => e.Name).ToList();
            }

            return(_pageDataQueryAppService.GetPageDatas(appServiceInput));
        }
コード例 #2
0
        public ActionResult <GetPageDatasOutput> GetPageDatas([FromBody] Dto.GetPageDatasInput input)
        {
            //if (!string.IsNullOrWhiteSpace(input.PageName) && !IsCanAccess(input.PageName))
            //{
            //    throw new Abp.Authorization.AbpAuthorizationException("未授权操作");
            //}

            IEnumerable <string> permissionNames = _claimManager.GetPermissionsForClaims(User.Claims);
            var permissions = _permissionManager.GetPermissionsForCache().Where(e => permissionNames.Contains(e.Name));

            Services.ManageHome.CMS.Pages.Dto.GetPageDatasInput appServiceInput = new Services.ManageHome.CMS.Pages.Dto.GetPageDatasInput();
            appServiceInput.PageIndex = input.PageIndex;
            appServiceInput.PageSize  = input.PageSize;
            appServiceInput.SearchKey = input.SearchKey;
            appServiceInput.Top       = input.Top;
            appServiceInput.Tags      = input.Tags;
            appServiceInput.Orderby   = input.Orderby;
            // 如果用户具有 Page域 的管理权限,则用户具有所有页面的管理权限
            if (_checkPermissionService.IsAllowAccess(ApiScopeProvider.Page, false, permissions))
            {
                appServiceInput.EnablePageFilter = false;
            }
            else
            {
                appServiceInput.EnablePageFilter = true;

                if (!string.IsNullOrWhiteSpace(input.PageName))
                {
                    appServiceInput.PageIds = _pageManager.GetPagesForQueryPermission(permissions).Where(e => e.Name == input.PageName).Select(e => e.Id).ToList();
                }
                else
                {
                    appServiceInput.PageIds = _pageManager.GetPagesForQueryPermission(permissions).Select(e => e.Id).ToList();
                }
            }

            return(_pageDataQueryAppService.GetPageDatas(appServiceInput));
        }