Exemple #1
0
        /// <summary>
        /// 获取OperatorTree的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ListResultDto <OperatorTreeListDto> > GetOperatorTrees(FilterInputDto input)
        {
            var current = await AbpSession.CurrentAsync();

            var query = _operatortreeRepository.GetAll();

            query = query.WhereIf(!input.Filter.IsNullOrWhiteSpace(), c => c.TreeCode.Contains(input.Filter))
                    .WhereIf(!current.TreeCode.IsNullOrWhiteSpace(),
                             c => c.TreeCode.Contains(current.TreeCode));
            var operatortrees = await query
                                .ToListAsync();

            var operatortreeListDtos = operatortrees.MapTo <List <OperatorTreeListDto> >();

            if (!current.IsAdmin && !current.TreeCode.IsNullOrWhiteSpace())
            {
                var node = operatortreeListDtos.FirstOrDefault(c => c.TreeCode == current.TreeCode);
                if (node != null)
                {
                    node.ParentId = null;
                }
            }
            return(new ListResultDto <OperatorTreeListDto>(
                       operatortreeListDtos
                       ));
        }
Exemple #2
0
        /// <summary>
        /// 获取商品列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <dsc_Goods> > GetPagedGoods(GetGoodsInput input)
        {
            var current = await AbpSession.CurrentAsync();

            var otre = await _treeRepository.FirstOrDefaultAsync(c => c.TreeCode.Equals(current.TreeCode));

            var ht = await _deviceRepository.GetAllIncluding(c => c.DeviceGoods)
                     .FirstOrDefaultAsync(c => c.Id == input.DeviceId);

            var result = await _cacheManager.GetCache(SchoolCache.GoodsCache)
                         .GetAsync(SchoolCache.GoodsCache, GetGoodsFromCache);

            var temp = result.Items
                       .Where(c => c.user_id == otre.ShopId)
                       .WhereIf(!input.Name.IsNullOrWhiteSpace(), c => c.goods_name.Contains(input.Name))
                       .WhereIf(!input.Sn.IsNullOrWhiteSpace(), c => c.goods_sn.Contains(input.Sn))
                       .WhereIf(!input.Cate.IsNullOrWhiteSpace(), c => c.cat_name.Contains(input.Cate));
            var arr = ht == null || !ht.DeviceGoods.Any() ? new List <DeviceGood>() : ht.DeviceGoods.ToList();
            var t   = from c in temp
                      join d in arr on c.goods_id equals d.GoodsId into h
                      from tt in h.DefaultIfEmpty()
                      select new { c, tt };

            t = t.WhereIf(input.IsSeal.HasValue && input.IsSeal.Value, c => c.tt != null)
                .WhereIf(input.IsSeal.HasValue && !input.IsSeal.Value, c => c.tt == null);
            var count = t.Count();

            var list = t.OrderBy(c => c.c.goods_name).Skip(input.SkipCount).Take(input.MaxResultCount).ToList();
            var res  = new List <dsc_Goods>();

            foreach (var goodse in list)
            {
                var te = goodse.c;
                te.IsSeal = goodse.tt != null;
                te.Price  = goodse.tt != null ? goodse.tt.Price : 0;
                res.Add(te);
            }
            return(new PagedResultDto <dsc_Goods>(count, res));
        }