コード例 #1
0
ファイル: ButtonServer.cs プロジェクト: ztxyzu/Uwl.Admin.Core
        /// <summary>
        /// 分页获取按钮列表
        /// </summary>
        /// <param name="baseQuery"></param>
        /// <param name="Total"></param>
        /// <returns></returns>
        public (List <ButtonViewMoel>, int) GetQueryByPage(ButtonQuery buttonQuery)
        {
            var query = ExpressionBuilder.True <SysButton>();

            query = query.And(menu => menu.IsDrop == false);
            var menuquery = ExpressionBuilder.True <SysMenu>();

            menuquery = menuquery.And(menu => menu.IsDrop == false);
            if (!buttonQuery.Name.IsNullOrEmpty())
            {
                query = query.And(m => m.Name.Contains(buttonQuery.Name.Trim()));
            }
            if (!buttonQuery.JSKeyCode.IsNullOrEmpty())
            {
                query = query.And(m => m.KeyCode.Contains(buttonQuery.JSKeyCode.Trim()));
            }
            if (!buttonQuery.APIAddress.IsNullOrEmpty())
            {
                query = query.And(m => m.APIAddress.Contains(buttonQuery.APIAddress.Trim()));
            }
            if (!buttonQuery.MenuName.IsNullOrEmpty())
            {
                menuquery = menuquery.And(m => m.Name.Contains(buttonQuery.MenuName.Trim()));
            }
            var list = (from a in _buttonRepositoty.GetAll(query)
                        join b in _menuRepositoty.GetAll(menuquery) on a.MenuId equals b.Id
                        select new ButtonViewMoel
            {
                Id = a.Id,
                Name = a.Name,
                APIAddress = a.APIAddress,
                KeyCode = a.KeyCode,
                Memo = a.Memo,
                ButtonStyle = a.ButtonStyle,
                IsShow = a.IsShow,
                CreatedDate = a.CreatedDate,
                MenuId = b.Id,
                MenuName = b.Name,
            });
            int Total = list.Count();//查询符合添加的总数执行一次

            //添加排序
            OrderCondition <ButtonViewMoel>[] orderConditions = new OrderCondition <ButtonViewMoel>[]
            {
                new OrderCondition <ButtonViewMoel>(x => x.CreatedDate, SortDirectionEnum.Descending)
            };
            Parameters parameters = new Parameters();

            parameters.PageIndex = buttonQuery.PageIndex;
            parameters.PageSize  = buttonQuery.PageSize;

            parameters.OrderConditions = orderConditions;
            return(list.PageBy(parameters).ToList(), Total); //再查询符合条件的数据在查一次
        }
コード例 #2
0
        public async Task <RoleAssigMenuViewModel> GetRoleAssigMenuViewModels(Guid RoleId)
        {
            #region 获取所有的菜单和按钮
            var list          = this._menuRepositoty.GetAll(x => x.IsDrop == false).ToList(); //获取所有的菜单列表
            var RoleAssigMenu = MyMappers.ObjectMapper.Map <List <SysMenu>, List <RoleAssigMenuViewModel> >(list);
            var buttonlist    = _buttonRepositoty.GetAll(x => x.IsDrop == false);             //获取所有的按钮列表
            //var RoleAssigButton = MyMappers.ObjectMapper.Map<List<SysButton>, List<RoleAssigButtonViewModel>>(buttonlist);
            RoleAssigMenuViewModel roleAssigMenuView = new RoleAssigMenuViewModel()
            {
                Id       = Guid.Empty,
                expand   = true,
                title    = "根节点",
                disabled = false,
                @checked = false,
            };
            var SysbuttonList = await _buttonRepositoty.GetAllListAsync(x => x.IsDrop == false);//获取所有的菜单按钮列表

            #endregion


            #region 获取该角色下的所有权限
            var roleRight = await _roleRightAssigRepository.GetAllListAsync(x => x.RoleId == RoleId);

            #endregion

            //调用递归事件
            CreateRoleAssigTree(RoleAssigMenu, roleAssigMenuView, SysbuttonList, roleRight);

            //dynamic var =  LinqTosql();

            return(roleAssigMenuView);
        }
コード例 #3
0
        /// <summary>
        /// 分页获取按钮列表
        /// </summary>
        /// <param name="baseQuery"></param>
        /// <param name="Total"></param>
        /// <returns></returns>
        public (List <ButtonViewMoel>, int) GetQueryByPage(ButtonQuery buttonQuery)
        {
            var query = ExpressionBuilder.True <SysButton>();

            query = query.And(menu => menu.IsDrop == false);
            var menuquery = ExpressionBuilder.True <SysMenu>();

            menuquery = menuquery.And(menu => menu.IsDrop == false);
            if (!buttonQuery.Name.IsNullOrEmpty())
            {
                query = query.And(m => m.Name.Contains(buttonQuery.Name.Trim()));
            }
            if (!buttonQuery.JSKeyCode.IsNullOrEmpty())
            {
                query = query.And(m => m.KeyCode.Contains(buttonQuery.JSKeyCode.Trim()));
            }
            if (!buttonQuery.APIAddress.IsNullOrEmpty())
            {
                query = query.And(m => m.APIAddress.Contains(buttonQuery.APIAddress.Trim()));
            }
            if (!buttonQuery.MenuName.IsNullOrEmpty())
            {
                menuquery = menuquery.And(m => m.Name.Contains(buttonQuery.MenuName.Trim()));
            }

            var list = (from a in _buttonRepositoty.GetAll(query)
                        join b in _menuRepositoty.GetAll(menuquery) on a.MenuId equals b.Id
                        select new ButtonViewMoel
            {
                Id = a.Id,
                Name = a.Name,
                APIAddress = a.APIAddress,
                KeyCode = a.KeyCode,
                Memo = a.Memo,
                ButtonStyle = a.ButtonStyle,
                IsShow = a.IsShow,
                CreatedDate = a.CreatedDate,
                MenuId = b.Id,
                MenuName = b.Name,
            });
            int Total = list.Count();                                                                                      //查询符合添加的总数执行一次

            return(list.PageBy(buttonQuery.PageSize, buttonQuery.PageSize * (buttonQuery.PageIndex - 1)).ToList(), Total); //再查询符合条件的数据在查一次
        }
コード例 #4
0
 /// <summary>
 /// 获取所有的按钮列表
 /// </summary>
 /// <returns></returns>
 public List <SysButton> GetButtonAllList()
 {
     return(_buttonRepositoty.GetAll().ToList());
 }