Пример #1
0
        /// <summary>
        /// 根据编号精确获取单品食物
        /// </summary>
        /// <param name="dishId">单品食物编号</param>
        /// <returns></returns>
        public Result <Dish> SearchDishInfoById(int dishId)
        {
            Result <Dish> result = new Result <Dish>()
            {
                Data   = null,
                Status = true
            };

            try
            {
                IDishCache service  = ServiceObjectContainer.Get <IDishCache>();
                DishInfo   dishinfo = service.GetDishInfoById(dishId);
                if (dishinfo != null)
                {
                    result.Data   = dishinfo.Copy <Dish>();
                    result.Status = true;
                }
                else
                {
                    result.Status = false;
                }
            }
            catch (Exception ex)
            {
                result.Status     = false;
                result.Message    = "查询单品食物出错:" + ex.Message;
                result.StatusCode = "SD001";
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:SearchDishInfoById() .DishService"), LogType.ErrorLog);
            }

            return(result);
        }
Пример #2
0
        public Result <IList <Dish> > GetFavoriteDishByPhone(long phone)
        {
            Result <IList <Dish> > result = new Result <IList <Dish> >()
            {
                Status  = true,
                Message = "查找单品集合成功"
            };

            try
            {
                //收藏关系缓存
                IRelationFavoriteCache favoritecache = ServiceObjectContainer.Get <IRelationFavoriteCache>();
                //食谱缓存服务
                IDishCache dishcache = ServiceObjectContainer.Get <IDishCache>();
                if (phone == 0)
                {
                    throw new ArgumentException("获取食谱,参数非法");
                }

                //获取收藏关系
                IList <FavoriteInfo> favoritelist      = favoritecache.GetFavoriteByPhone(phone, Model.Enum.FavoriteTypeEnum.收藏单品);
                IList <int>          favoriterecipesId = favoritelist.Select(s => s.FavoriteId).ToList();

                //获取单品信息
                IList <DishInfo> favoritedishs = dishcache.GetDishInfoById(favoriterecipesId);

                if (favoritedishs != null && favoritedishs.Count > 0)
                {
                    result.Data   = favoritedishs.CopyList <DishInfo, Dish>();
                    result.Status = true;
                }
                else
                {
                    result.Status = false;
                    result.Data   = new List <Dish>();
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Data    = new List <Dish>();
                result.Message = "查找单品出错:" + ex.Message;
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:GetFavoriteDishByPhone() .DishService"), LogType.ErrorLog);
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        /// 根据食谱编号获取收藏的单品集合
        /// </summary>
        /// <param name="recipesId"></param>
        /// <returns></returns>
        public Result <IList <Dish> > GetCollectDishList(int recipesId)
        {
            Result <IList <Dish> > result = new Result <IList <Dish> >()
            {
                Data    = new List <Dish>(),
                Message = "查询单品信息集合成功",
                Status  = true
            };

            try
            {
                //获取分享关系集合
                IRelationShareInfoCache relationcache = ServiceObjectContainer.Get <IRelationShareInfoCache>();

                IList <RelationShareInfo> relationshares = relationcache.GetRelationShareByReceipId(recipesId);

                //查询单品信息
                if (relationshares != null && relationshares.Count > 0)
                {
                    IDishCache  dishcache = ServiceObjectContainer.Get <IDishCache>();
                    IList <int> dishIds   = new List <int>();
                    foreach (var share in relationshares)
                    {
                        DishInfo dish = dishcache.GetDishInfoById(share.DishId);
                        result.Data.Add(dish.Copy <Dish>());
                    }
                }
            }
            catch (Exception ex)
            {
                result.Status     = false;
                result.Message    = "查询分享单品食物出错:" + ex.Message;
                result.StatusCode = "GSD001";
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:GetCollectDishList() .DishService"), LogType.ErrorLog);
            }


            return(result);
        }