示例#1
0
        public async Task <ApiRequestResult> GetProductByFeature([FromQuery] ProductsParam param)
        {
            var filter = param.SearchLambda <Products, ProductsParam>();
            var result = await _productRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            return(ApiRequestResult.Success(result, ""));
        }
示例#2
0
        public async Task <string> QueryPagedAsync([FromQuery] ProductsParam param)
        {
            var filter = param.SearchLambda <Products, ProductsParam>();
            var result = await _productRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var list = new List <ProductDto>();

            foreach (var item in result.Items)
            {
                var dto = item.EntityMap <Products, ProductDto>();
                //
                var memberList = await _productMemberPriceRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.MemberPriceList = memberList.Select(c => c.EntityMap <ProductMemberPrice, ProductMemberPriceDto>()).ToList();

                //
                var fullReductionList = await _productFullReductionRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.ProductFullReductionList = fullReductionList.Select(c => c.EntityMap <ProductFullReduction, ProductFullReductionDto>()).ToList();

                //
                var ladderList = await _productLadderRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.ProductLadderList = ladderList.Select(c => c.EntityMap <ProductLadder, ProductLadderDto>()).ToList();

                //
                var attributeValueList = await _productAttributeValueRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.ProductAttributeValueList = attributeValueList.Select(c => c.EntityMap <ProductAttributeValue, ProductAttributeValueDto>()).ToList();

                //
                var skuStockList = await _productSkuStockRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.SkuStockList = skuStockList.Select(c => c.EntityMap <ProductSkuStock, ProductSkuStockDto>()).ToList();

                list.Add(dto);
            }
            var pageData = new PagedDto <ProductDto>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = list
            };
            var json = pageData.ToString();

            return(json);
        }
示例#3
0
        public async Task <string> QuerySimpleAsync([FromQuery] ProductsParam param)
        {
            var filter = param.SearchLambda <Products, ProductsParam>();
            var result = await _productRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <Products>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }