/// <summary>
        /// 获取Json格式的数据 条件字典Key可以取固定值 selectfields orderby 框架将自动处理
        /// </summary>
        /// <param name="page">当前页码</param>
        /// <param name="limit">当前也显示条数</param>
        /// <param name="orderby">排序字段</param>
        /// <param name="dicwhere">查询条件</param>
        /// <returns>FastJsonResult&lt;List&lt;Product&gt;&gt;.</returns>
        public static FastJsonResult <List <Comment> > GetJsonListPage(int page = 1, int limit = 10, string orderby = "", Dictionary <string, object> dicwhere = null)
        {
            if (dicwhere == null)
            {
                dicwhere = new Dictionary <string, object>();
            }
            if (dicwhere.Keys.Contains(nameof(Comment.IsDeleted)))
            {
                dicwhere[nameof(Comment.IsDeleted)] = 0;
            }
            else
            {
                dicwhere.Add(nameof(Comment.IsDeleted), 0);
            }
            var ret = CommentRepository.Instance.GetJsonListPage <Comment>(limit, page, dicwhere, orderby);

            if (ret != null && ret.code.Toint() == 0 && ret.data.Count > 0)
            {
                string          blognums = string.Join(",", ret.data.Select(x => x.BlogNum).Distinct());
                List <Bloginfo> blogs    = BloginfoLogic.GetList(new Dictionary <string, object>()
                {
                    { $"{nameof(Bloginfo.BlogNum)}|i", blognums },
                });
                ret.data.ForEach((item) =>
                {
                    item.Extend4 = blogs.FirstOrDefault(x => x.BlogNum == item.BlogNum)?.Title;
                });
            }
            return(ret);
        }
Exemple #2
0
        /// <summary>
        /// 获取Json格式的数据 条件字典Key可以取固定值 selectfields orderby 框架将自动处理
        /// </summary>
        /// <param name="page">当前页码</param>
        /// <param name="limit">当前也显示条数</param>
        /// <param name="orderby">排序字段</param>
        /// <param name="dicwhere">查询条件</param>
        /// <returns>FastJsonResult&lt;List&lt;Product&gt;&gt;.</returns>
        public static FastJsonResult <List <ArticlePraise> > GetJsonListPage(int page = 1, int limit = 10, string orderby = "", Dictionary <string, object> dicwhere = null)
        {
            if (dicwhere == null)
            {
                dicwhere = new Dictionary <string, object>();
            }
            if (dicwhere.Keys.Contains(nameof(ArticlePraise.IsDeleted)))
            {
                dicwhere[nameof(ArticlePraise.IsDeleted)] = 0;
            }
            else
            {
                dicwhere.Add(nameof(ArticlePraise.IsDeleted), 0);
            }
            var ret = ArticlePraiseRepository.Instance.GetJsonListPage <ArticlePraise>(limit, page, dicwhere, orderby);

            if (ret != null && ret.code.Toint() == 0 && ret.data.Count > 0)
            {
                string        memberids = string.Join(",", ret.data.Select(x => x.MemberId).Distinct());
                string        blognums  = string.Join(",", ret.data.Select(x => x.BlogNum).Distinct());
                List <Member> members   = MemberLogic.GetList(new Dictionary <string, object>()
                {
                    { $"{nameof(Member.KID)}|i", memberids },
                });
                List <Bloginfo> blogs = BloginfoLogic.GetList(new Dictionary <string, object>()
                {
                    { $"{nameof(Bloginfo.BlogNum)}|i", blognums },
                });
                ret.data.ForEach((item) =>
                {
                    item.Extend4 = members.FirstOrDefault(x => x.KID == item.MemberId.Toint())?.UserName;
                    item.Extend5 = members.FirstOrDefault(x => x.KID == item.MemberId.Toint())?.UserAccount;
                    item.Extend6 = blogs.FirstOrDefault(x => x.BlogNum == item.BlogNum)?.Title;
                });
            }
            return(ret);
        }