Пример #1
0
        /// <summary>
        /// 根据用户获取功能菜单
        /// </summary>
        /// <param name="user">用户实体</param>
        /// <returns></returns>
        public HandleResult <List <SysMenuDto> > GetMenusBy(SysUser user)
        {
            var listMenuDto = new List <SysMenuDto>();

            listMenuDtos = Mapper.Map <List <SysMenuDto> >(((List <SysAuthority>)(sysAuthorityBLL.GetSysAuthorities(user, AuthorityType.Type_Menu).Data)).Select(t => t.sysMenu).ToList());
            //找出所有一级菜单
            listMenuDto.AddRange(listMenuDtos.Where(t => Guid.Empty.ToString().Equals(t.ParentMenuId)).OrderByDescending(t => t.MenuSort).ThenBy(t => t.CreateTime));
            foreach (var item in listMenuDto)
            {
                item.children = GetMenuChildren(item.MenuId);
            }
            return(new HandleResult <List <SysMenuDto> >
            {
                Data = listMenuDto
            });
        }
Пример #2
0
        /// <summary>
        /// 根据用户获取功能菜单
        /// </summary>
        /// <param name="user">用户实体</param>
        /// <returns></returns>
        public MessageModel GetMenusBy(SysUser user, SysEnum.Enum_AuthorityType mType)
        {
            var listMenuDto = new List <SysMenuDto>();

            listMenuDtos = Mapper.Map <List <SysMenuDto> >(((List <SysAuthority>)(sysAuthorityBLL.GetSysAuthorities(user, mType).Data)).Select(t => t.SysMenu).ToList());
            //找出所有一级菜单
            listMenuDto.AddRange(listMenuDtos.Where(t => t.ParentMenuId.Equals(Guid.Empty.ToString())).OrderBy(t => t.MenuSort).ThenBy(t => t.CreateTime));
            foreach (var item in listMenuDto)
            {
                item.children = GetMenuChildren(item.MenuId);
            }
            return(new MessageModel
            {
                Data = listMenuDto
            });
        }