Beispiel #1
0
        /// <summary>
        /// 查询权限
        /// </summary>
        /// <returns></returns>
        public Response QueryRolePermissions(int id)
        {
            //List<PermissionTree> trees = new List<PermissionTree>();
            //PermissionTree tree = new PermissionTree
            //{
            //    Title = "系统权限",
            //    Expand = true,
            //    Category = "root",
            //    Id = 0,
            //    Children = new List<PermissionTree>()
            //};
            ////查询职务下模块
            //IList<CommonBO> modules = BaseDataDao.QueryRoleHasModules(id);
            //List<int> modulesId = new List<int>();
            //foreach (var item in modules)
            //{
            //    modulesId.Add(item.FID);
            //}
            //if (modulesId.Any())
            //{
            //    return new Response
            //    {
            //        Result = trees
            //    };
            //}
            ////查询模块下页面
            //IList<CommonBO> pages = BaseDataDao.QueryPagesOfModules(modulesId.ToArray());
            //List<int> pagesId = new List<int>();
            //foreach (var item in pages)
            //{
            //    pagesId.Add(item.FID);
            //}
            //if (pagesId.Any())
            //{
            //    return new Response
            //    {
            //        Result = trees
            //    };
            //}
            ////查询页面下权限
            //IList<CommonBO> permissions = BaseDataDao.QueryPagesHasPermissionsAndRoleHasPermissions(id, pagesId.ToArray());
            //if (permissions.Any())
            //{
            //    return new Response
            //    {
            //        Result = trees
            //    };
            //}
            //// 组合数据
            //foreach (var item in modules)
            //{
            //    PermissionTree childModule = new PermissionTree
            //    {
            //        Title = item.FNAME,
            //        Expand = true,
            //        Id = item.FID,
            //        Category = "module",
            //        Children = new List<PermissionTree>()
            //    };
            //    childModule.Children = pages.Where(x => x.PARENTID == item.FID).Select(x => new PermissionTree
            //    {
            //        Title = x.FNAME,
            //        Expand = true,
            //        Id = x.FID,
            //        Category = "page",
            //        Children = permissions.Where(o => o.PARENTID == x.FID).Select(p => new PermissionTree
            //        {
            //            Title = p.FNAME,
            //            Id = p.FID,
            //            Category = "per",
            //            Checked = p.FROLEID > 0
            //        }).ToList()
            //    }).ToList();
            //    tree.Children.Add(childModule);
            //}
            //trees.Add(tree);
            var result = AuthorityService.QueryRolePermissionForTree(id);

            return(new Response
            {
                Result = result
            });
        }