public async Task <List <TreeItem <ViewMenu> > > GetUserTreeMenuAsync(int iUserId) { List <ViewMenu> lstViewMenu = new List <ViewMenu>(); List <Menu> lstUserMenu = new List <Menu>(); //查询角色所拥有的菜单集合 lstUserMenu = await RedisMethod.GetUserMenuAsync(iUserId, -1, () => _MenuService.GetRoleMenuListAsync(iUserId)); if (lstUserMenu?.Count > 0) { //排序 lstUserMenu = lstUserMenu.OrderBy(x => x.Isort).ToList(); lstUserMenu.ForEach(entityMenu => { ViewMenu entityViewMenu = new ViewMenu(); entityViewMenu.Id = entityMenu.Id; entityViewMenu.ParentId = entityMenu.IparentId == -1 ? 0 : entityMenu.IparentId; entityViewMenu.DisplayName = entityMenu.Sname; entityViewMenu.IconUrl = entityMenu.SiconUrl; entityViewMenu.LinkUrl = entityMenu.SlinkUrl; entityViewMenu.Target = ""; lstViewMenu.Add(entityViewMenu); }); } return(lstViewMenu.GenerateTree(x => x.Id, x => x.ParentId).ToList()); }
public async Task <bool> CheckUserMenuPowerAsync(int iUserId, int iMenuId) { UserInfo entityUserInfo = await _userInfoService.SelectAsync(iUserId); Menu entityMenu = await _menuRepository.SelectAsync(iMenuId); if (entityUserInfo != null && entityMenu != null) { List <Menu> lstUserMenu = await RedisMethod.GetUserMenuAsync(entityUserInfo.Id, -1, () => GetRoleMenuListAsync(iUserId)); if (lstUserMenu?.Count > 0) { if (lstUserMenu.Any(x => x.Id == entityMenu.Id)) { return(true); } } } return(false); }