示例#1
0
        /// <summary>
        /// 分页搜索
        /// </summary>
        /// <param name="filters">查询过滤参数</param>
        /// <returns></returns>
        public async Task <PagedResult <MenuDto> > Search(MenuFilters filters)
        {
            if (filters == null)
            {
                return(new PagedResult <MenuDto>());
            }

            using (var scope = _dbContextScopeFactory.CreateReadOnly())
            {
                var db    = scope.DbContexts.Get <JuCheapContext>();
                var query = db.Menus
                            .WhereIf(filters.keywords.IsNotBlank(), x => x.Name.Contains(filters.keywords))
                            .WhereIf(filters.ExcludeType.HasValue, x => x.Type != (byte)filters.ExcludeType.Value);

                return(await query.OrderByCustom(filters.sidx, filters.sord)
                       .Select(item => new MenuDto
                {
                    Id = item.Id,
                    ParentId = item.ParentId,
                    Name = item.Name,
                    Url = item.Url,
                    Order = item.Order,
                    Type = (MenuType)item.Type,
                    Icon = item.Icon,
                    CreateDateTime = item.CreateDateTime
                }).PagingAsync(filters.page, filters.rows));
            }
        }
示例#2
0
        /// <summary>
        /// 分页搜索
        /// </summary>
        /// <param name="filters">查询过滤参数</param>
        /// <returns></returns>
        public async Task <PagedResult <MenuDto> > SearchAsync(MenuFilters filters)
        {
            if (filters == null)
            {
                return(new PagedResult <MenuDto>());
            }

            var query = _context.Menus.AsQueryable();

            if (filters.keywords.IsNotBlank())
            {
                query = query.Where(x => x.Name.Contains(filters.keywords));
            }
            if (filters.ExcludeType.HasValue)
            {
                query = query.Where(x => x.Type != (byte)filters.ExcludeType.Value);
            }

            return(await query.OrderByDescending(item => item.CreateDateTime)
                   .Select(item => new MenuDto
            {
                Id = item.Id,
                ParentId = item.ParentId,
                Name = item.Name,
                Url = item.Url,
                Order = item.Order,
                Type = (MenuType)item.Type
            }).PagingAsync(filters.page, filters.rows));
        }
示例#3
0
        /// <summary>
        /// 获取导出数据
        /// </summary>
        /// <param name="filters">查询过滤参数</param>
        /// <returns></returns>
        public async Task <List <MenuDto> > QueryExportDatas(MenuFilters filters)
        {
            using (var scope = _dbContextScopeFactory.CreateReadOnly())
            {
                var db    = scope.DbContexts.Get <JuCheapContext>();
                var query = db.Menus.Where(item => !item.IsDeleted);

                if (filters.keywords.IsNotBlank())
                {
                    query = query.Where(item => item.Name.Contains(filters.keywords));
                }
                if (filters.ExcludeType.HasValue)
                {
                    query = query.Where(item => item.Type != (byte)filters.ExcludeType.Value);
                }

                return(await query.OrderByCustom(filters.sidx, filters.sord)
                       .Select(item => new MenuDto
                {
                    Id = item.Id,
                    Name = item.Name,
                    Url = item.Url
                }).ToListAsync());
            }
        }
        public async Task <JsonResult> GetListWithPager(MenuFilters filter, AdvanceFilter advanceFilter)
        {
            var result = await _menuService.Search(filter);

            //var result = _menuService.AdvanceSearch(advanceFilter);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        /// <summary>
        /// 分页搜索
        /// </summary>
        /// <param name="filters">查询过滤参数</param>
        /// <returns></returns>
        public async Task <PagedResult <MenuDto> > SearchAsync(MenuFilters filters)
        {
            if (filters == null)
            {
                return(new PagedResult <MenuDto>());
            }

            using (var scope = _dbContextScopeFactory.CreateReadOnly())
            {
                var db    = scope.DbContexts.Get <JuCheapContext>();
                var dbSet = db.Set <MenuEntity>();
                var query = dbSet.Where(item => !item.IsDeleted);

                if (filters.keywords.IsNotBlank())
                {
                    query = query.Where(item => item.Name.Contains(filters.keywords));
                }
                if (filters.ExcludeType.HasValue)
                {
                    query = query.Where(item => item.Type != (byte)filters.ExcludeType.Value);
                }

                return(await query.OrderBy(item => item.CreateDateTime)
                       .Select(item => new MenuDto
                {
                    Id = item.Id,
                    ParentId = item.ParentId,
                    Name = item.Name,
                    Url = item.Url,
                    Order = item.Order,
                    Type = (MenuType)item.Type
                }).PagingAsync(filters.page, filters.rows));
            }
        }
示例#6
0
        public async Task <IActionResult> GetListWithKeywords(MenuFilters filters)
        {
            filters.page        = 1;
            filters.rows        = 10;
            filters.ExcludeType = MenuType.Action;
            var result = await _menuService.SearchAsync(filters);

            return(Json(new { value = result.rows }));
        }
        public async Task <JsonResult> GetListWithKeywords(MenuFilters filters)
        {
            filters.page        = 1;
            filters.rows        = 10;
            filters.ExcludeType = MenuType.Button;
            var result = await _menuService.Search(filters);

            return(Json(new { value = result.rows }, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        public async Task <IActionResult> GetListWithPager(MenuFilters filters)
        {
            var result = await _menuService.SearchAsync(filters);

            return(Json(result));
        }
        public async Task <JsonResult> GetSubGridListWithPager(MenuFilters filter)
        {
            var result = await _menuService.Search(filter);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#10
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="condition">查询参数</param>
        public async void Index_Print(MenuFilters condition)
        {
            var menus = await _menuService.QueryExportDatas(condition);

            SpireHelper.ExportToPdf("菜单", menus, true);
        }
示例#11
0
        /// <summary>
        /// 导出到Excel
        /// </summary>
        /// <param name="condition">查询参数</param>
        public async void Index_Exports(MenuFilters condition)
        {
            var menus = await _menuService.QueryExportDatas(condition);

            SpireHelper.ExportToExcel("菜单", menus);
        }
示例#12
0
        public JsonResult GetListWithPager(MenuFilters filters)
        {
            var result = _menuService.Search(filters);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }