Beispiel #1
0
        public async Task <IResultModel> MenuTree(string id)
        {
            var menus = await _menuRepository.GetListAsync(m => m.IsDel == false);

            var menuButtons = await _menuButtonRepository.GetListAsync(m => m.IsDel == false);

            var roleMenus = await _roleMenuRepository.GetListAsync(m => m.RoleId == id && m.MenuChecked == true && m.IsDel == false);

            var roleMenuButtons = await _rolePermissionRepository.GetListAsync(m => m.RoleId == id && m.IsDel == false);

            var all = _mapper.Map <List <RoleMenuPermissionTreeModel> >(menus);

            all.ForEach(m =>
            {
                m.Buttons = _mapper.Map <List <RoleMenuButtons> >(menuButtons.Where(b => b.MenuId == m.MenuId).OrderBy(b => b.Sort));
                m.Buttons.ForEach(t =>
                {
                    t.Checked  = roleMenuButtons.Any(r => r.PermissionCode == t.PermissionCode);
                    t.Disabled = !roleMenus.Any(o => o.MenuId == t.MenuId);
                });
            });

            var result = new RoleMenuPermissionResultModel()
            {
                Menus       = ResolveMenuTree(all, Guid.Empty.ToString("N")),
                RoleMenuIds = roleMenus.Select(m => m.MenuId).ToList()
            };

            return(ResultModel.Success(result));
        }
Beispiel #2
0
        public async Task <DataResult <MenuButtonList> > GetButtonByMenuIdAsync(Guid id)
        {
            var result = new DataResult <MenuButtonList>();

            List <MenuButton> menuButtons = await _menuButtonRepository.GetListAsync(Specification <MenuButton> .Eval(d => d.MenuId == id));

            var buttonids = menuButtons.Select(d => d.ButtonId).ToArray();

            result.data = new MenuButtonList {
                ButtonIds = buttonids
            };
            return(result);
        }
        public async Task <IResultModel> QueryByMenuId(string menuId)
        {
            var result = await _repository.GetListAsync(m => m.MenuId == menuId && m.IsDel == false);

            return(ResultModel.Success(result.OrderBy(o => o.Sort)));
        }