Example #1
0
        /// <summary>
        /// 商品分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <PageModelDto <ProductDto> > GetPagedAsync(ProductSearchPagedDto search)
        {
            Expression <Func <Product, bool> > whereCondition = x => true;

            if (!search.Id.IsNullOrEmpty())
            {
                whereCondition = whereCondition.And(x => x.Id == search.Id.ToLong());
            }
            var pagedEntity = await _productRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.Id);

            var pagedDto = _mapper.Map <PageModelDto <ProductDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合商品状态信息
                var rpcReuslt = await _maintRpcSrv.GetDictAsync(DictConsts.ProdunctStatusId);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusDescription = dicts.FirstOrDefault(d => d.Name == x.StatusCode.ToString())?.Value;
                    });
                }
            }
            return(pagedDto);
        }
Example #2
0
        /// <summary>
        /// 订单分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <PageModelDto <OrderDto> > GetPagedAsync(OrderSearchPagedDto search)
        {
            Expression <Func <Order, bool> > whereCondition = x => true;

            if (search.Id > 0)
            {
                whereCondition = whereCondition.And(x => x.Id == search.Id);
            }
            var pagedEntity = await _orderRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.Id);

            var pagedDto = _mapper.Map <PageModelDto <OrderDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合订单状态信息
                var rpcReuslt = await _maintRpc.GetDictAsync(DictConsts.OrderStatusId);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusChangesReason = dicts.FirstOrDefault(d => d.Name == x.StatusCode.ToSafeString())?.Name;
                    });
                }
            }
            return(pagedDto);
        }
Example #3
0
        /// <summary>
        /// 商品分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <AppSrvResult <PageModelDto <ProductDto> > > GetPaged(ProductSearchDto search)
        {
            Expression <Func <Product, bool> > whereCondition = x => true;

            if (search.Id > 0)
            {
                whereCondition = whereCondition.And(x => x.ID == search.Id);
            }
            var pagedEntity = _productRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.CreateTime);

            var pagedDto = _mapper.Map <PageModelDto <ProductDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合商品状态信息
                var rpcReuslt = await _maintRpcSrv.GetDictAsync(10000);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusName = dicts.FirstOrDefault(d => d.Name == x.Status.ToSafeString())?.Name;
                    });
                }
            }
            return(pagedDto);
        }
Example #4
0
        public async Task <ActionResult <DictRto> > TestCallRpcService()
        {
            var jwtToken = await _contextAccessor.HttpContext.GetTokenAsync("access_token");

            if (jwtToken == null)
            {
                var authRpcResult = await _authRpcServcie.LoginAsync(new LoginRto { Account = "alpha2008", Password = "******" });

                if (authRpcResult.IsSuccessStatusCode)
                {
                    jwtToken = authRpcResult.Content.Token;
                }
                return(NotFound());
            }
            var dictRpcResult = await _maintRpcServcie.GetDictAsync(29);

            if (dictRpcResult.IsSuccessStatusCode)
            {
                return(dictRpcResult.Content);
            }

            var apiError = ((Refit.ValidationApiException)dictRpcResult.Error).Content;

            return(Problem(apiError.Detail, dictRpcResult.Error.Uri.ToString(), apiError.Status, apiError.Title, apiError.Type));
        }
Example #5
0
        /// <summary>
        /// 商品分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <PageModelDto <ProductDto> > GetPagedAsync(ProductSearchPagedDto search)
        {
            var whereCondition = ExpressionCreator
                                 .New <Product>()
                                 .AndIf(search.Id > 0, x => x.Id == search.Id);

            var pagedEntity = await _productRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.Id);

            var pagedDto = Mapper.Map <PageModelDto <ProductDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合商品状态信息
                var rpcReuslt = await _maintRpcSrv.GetDictAsync(Consts.ProdunctStatusId);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusDescription = dicts.FirstOrDefault(d => d.Value == x.StatusCode.ToString())?.Name;
                    });
                }
            }
            return(pagedDto);
        }