Esempio n. 1
0
        public ModelPager <VueCommentReply> loadMoreComment_Reply(QComment_Reply query)
        {
            if (string.IsNullOrEmpty(query.reqUserId))
            {
                throw new Exception("非法操作!");
            }

            return(_commentReplyResRepository.GetReplysByCommentId(query).Result);
        }
        public async Task <ModelPager <VueCommentReply> > GetReplysByCommentId(QComment_Reply query)
        {
            ModelPager <VueCommentReply> result = new ModelPager <VueCommentReply>(query.pageIndex, query.pageSize);
            var qOwn = Db.Queryable <EPraize_CommentReply>().Where(c => c.commentId == query.commentId && c.userId == query.reqUserId);
            var q    = base.Db.Queryable <ECommentReply_Res, EUserInfo>((c, u) => new object[]
            {
                JoinType.Inner, c.authorId == u.Id
            })
                       .Where(c => c.commentId == query.commentId)
                       .Select((c, u) => new VueCommentReply
            {
                CreateDateTime  = c.CreateDateTime,// c.CreateDateTime.ToString("yyyy-MM-dd hh:MM"),
                authorId        = u.Id,
                authorName      = u.NickName,
                replyId         = c.Id,
                content         = c.content,
                goodNum         = c.goodNum,
                headerUrl       = u.HeaderUrl,
                replyAuthorId   = c.replyAuthorId,
                replyAuthorName = c.replyName,
                bookCode        = c.bookCode,
            });

            var orderByPraize = $"case when j1.goodNum <{ SysRules.OrderByPraizeStartNum} then 0 else j1.goodNum end desc";

            var orderByFixedReply = $"case when j1.replyId = '{query.fixedReplyId}' then 0 else  j1.replyId end";

            var mainSql = Db.Queryable(q, qOwn, JoinType.Left, (j1, j2) => j1.replyId == j2.replyId)
                          .OrderByIF(query.fixedReplyId > 0, orderByFixedReply)
                          .OrderBy(orderByPraize)
                          .OrderBy(j1 => j1.CreateDateTime, OrderByType.Desc)
                          .Select((j1, j2) => new VueCommentReply
            {
                CreateDateTime  = j1.CreateDateTime,
                authorId        = j1.authorId,
                authorName      = j1.authorName,
                replyId         = j1.replyId,
                content         = j1.content,
                goodNum         = j1.goodNum,
                headerUrl       = j1.headerUrl,
                replyAuthorId   = j1.replyAuthorId,
                replyAuthorName = j1.replyAuthorName,
                userPraizeType  = j2.PraizeType,
                bookCode        = j1.bookCode
            });

            RefAsync <int> totalNumber = new RefAsync <int>();

            result.datas = await mainSql.ToPageListAsync(query.pageIndex, query.pageSize, totalNumber);

            result.totalCount = totalNumber;
            return(result);
        }
        public ResultPager <VueCommentReply> loadMore_Reply(QComment_Reply query)
        {
            ResultPager <VueCommentReply> result = new ResultPager <VueCommentReply>();

            try
            {
                query.reqUserId = this.getUserId();
                result.PageData = _commentServices.loadMoreComment_Reply(query);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(result);
        }