Ejemplo n.º 1
0
        /// <summary>
        /// [内容] -- 点赞
        /// </summary>

        private EMsgContent_Praize praizeToContent(MsgSubmitPraize msgSubmitPraize)
        {
            var submitPraize = msgSubmitPraize.SubmitPraize;
            var bi           = _bookRepository.getBookSimple_ByCode(submitPraize.bookCode);

            if (bi == null)
            {
                throw new Exception("消息服务[praizeToContent]:没有找到书本Code");
            }

            EMsgContent_Praize msgContent = new EMsgContent_Praize
            {
                BookCode     = bi.Code,
                BookName     = bi.Title,
                BookUrl      = bi.CoverUrl,
                PraizeTarget = submitPraize.praizeTarget,
            };
            string    content = "";
            ResSimple res     = null;

            switch (msgContent.PraizeTarget)
            {
            case PraizeTarget.Resource:
                res = _resourceReponsitory.getSimpleByCode(submitPraize.refCode);
                //   content = res.ResType == ResType.BookOss ?$"[文件]-{res.OrigFileName}" :$"[URL]-{res.Url}";
                msgContent.RefId = res.Code;
                break;

            case PraizeTarget.Comment:
                EComment_Res comment = _commentRepository.GetByKey(Convert.ToInt64(submitPraize.refCode)).Result;
                content                = comment.content;
                msgContent.RefId       = comment.Id.ToString();
                msgContent.CommentId   = comment.Id;
                msgContent.OrigContent = content;
                res = _resourceReponsitory.getSimpleByCode(submitPraize.parentRefCode);
                break;

            case PraizeTarget.CommentReply:
                ECommentReply_Res reply = _commentReplyRepository.GetByKey(Convert.ToInt64(submitPraize.refCode)).Result;
                content = reply.content;
                msgContent.CommentId   = reply.commentId;
                msgContent.ReplyId     = reply.Id;
                msgContent.RefId       = reply.Id.ToString();
                msgContent.OrigContent = content;
                res = _resourceReponsitory.getSimpleByCommentId(Convert.ToInt64(submitPraize.parentRefCode));
                break;
            }
            if (res == null)
            {
                throw new Exception("消息服务[praizeToContent]:没有找到资源信息");
            }
            msgContent.ResCode = res.Code;
            msgContent.ResName = res.ShowName;
            return(msgContent);
        }
Ejemplo n.º 2
0
        public long submitCommentReply(SubmitReply submitReply)
        {
            if (string.IsNullOrEmpty(submitReply.userId))
            {
                throw new Exception("非法操作!");
            }
            if (string.IsNullOrEmpty(submitReply.bookCode))
            {
                throw new Exception("书Code没有,无法操作!");
            }

            long result = -1;

            ECommentReply_Res reply = new ECommentReply_Res
            {
                authorId  = submitReply.userId,
                content   = submitReply.content,
                commentId = submitReply.commentId,
                bookCode  = submitReply.bookCode,
                replyType = ReplyType.Normal,
            };

            if (submitReply.replyId > 0)
            {
                reply.replyId       = submitReply.replyId;
                reply.replyAuthorId = submitReply.replyAuthorId;
                reply.replyName     = submitReply.replyAuthorName;
            }
            var transResult = _commentResRepository.Db.Ado.UseTran(() =>
            {
                _commentResRepository.UpdateComment_ReplyNum(submitReply.commentId, OperationDirection.plus);
                result = _commentReplyResRepository.Add_Sync(reply);
            });

            if (!transResult.IsSuccess)
            {
                throw new Exception(transResult.ErrorMessage);
            }
            return(result);
        }