Exemple #1
0
        /// <summary>
        /// 获取按钮权限信息
        /// </summary>
        /// <param name="buttons"></param>
        /// <param name="permission"></param>
        /// <returns></returns>
        public List <TButtonsModel> GetButtons(List <TButtonsModel> buttons, TTenantPermissionsModel permission)
        {
            var buttonIdList = permission.ButtonIds.Split(",").ToList();
            var result       = new List <TButtonsModel>();

            buttonIdList.ForEach(p => result.Add(buttons.Where(p1 => p1.Id == int.Parse(p)).FirstOrDefault()));
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 向上获取树
        /// </summary>
        /// <param name="menus"></param>
        /// <param name="menuTree"></param>
        /// <param name="permission"></param>
        /// <returns></returns>
        private MenuTreeModel GetTree(List <TPMMenusDbModel> menus, MenuTreeModel menuTree, TTenantPermissionsModel permission)
        {
            var parent = menus.Where(p => p.Id == menuTree.ParentID).FirstOrDefault();

            if (parent == null)
            {
                return(null);
            }
            var parentMenu = GetMenuTreeModel(parent);

            parentMenu.Children.Add(menuTree);
            if (parentMenu.ParentID != -1)
            {
                return(GetTree(menus, parentMenu, permission));
            }
            return(parentMenu);
        }