李昊 4 rokov pred
rodič
commit
9b501417cf

+ 2 - 2
gx_api/GxPress/Api/GxPress.Api/AppControllers/CommentController.cs

@@ -34,7 +34,7 @@ namespace GxPress.Api.AppControllers
         {
             // request.Content = StringUtils.RemoveEmoji(request.Content);
             request.UserId = _loginContext.AccountId;
-            if (string.IsNullOrWhiteSpace(request.Content))
+            if (string.IsNullOrWhiteSpace(request.Content) || string.IsNullOrWhiteSpace(request.JsonContent) || string.IsNullOrWhiteSpace(request.HtmlContent))
                 throw new BusinessException("评论内容为空");
             return await _commentRepository.CommentInAsync(request) > 0;
         }
@@ -65,7 +65,7 @@ namespace GxPress.Api.AppControllers
         /// <param name="request"></param>
         /// <returns></returns>
         [HttpPut("update")]
-        public async Task<bool> UpdateComment([FromBody]CommentUpdateRequest request)
+        public async Task<bool> UpdateComment([FromBody] CommentUpdateRequest request)
         {
             request.UserId = _loginContext.AccountId;
             return await _commentRepository.UpdateCommentAsync(request);

+ 1 - 1
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebCommentController.cs

@@ -36,7 +36,7 @@ namespace GxPress.Api.WebControllers
         {
             // request.Content = StringUtils.RemoveEmoji(request.Content);
             request.UserId = _loginContext.AccountId;
-            if (string.IsNullOrWhiteSpace(request.Content))
+            if (string.IsNullOrWhiteSpace(request.Content) || string.IsNullOrWhiteSpace(request.JsonContent) || string.IsNullOrWhiteSpace(request.HtmlContent))
                 throw new BusinessException("评论内容为空");
             return await _commentRepository.CommentInAsync(request) > 0;
         }

+ 4 - 0
gx_api/GxPress/Model/GxPress.Request/Comment/CommentUpdateRequest.cs

@@ -24,5 +24,9 @@ namespace GxPress.Request.Comment
         /// </summary>
         /// <value></value>
         public decimal Score { get; set; }
+        
+        public string JsonContent{get;set;}
+
+        public string HtmlContent{get;set;}
     }
 }

+ 7 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/CommentRepository.cs

@@ -321,7 +321,7 @@ namespace GxPress.Repository.Implement
         public async Task<bool> UpdateCommentAsync(CommentUpdateRequest request)
         {
             //判断类容是否为空
-            if (string.IsNullOrWhiteSpace(request.Content))
+            if (string.IsNullOrWhiteSpace(request.Content) || string.IsNullOrWhiteSpace(request.JsonContent) || string.IsNullOrWhiteSpace(request.HtmlContent))
                 throw new Common.Exceptions.BusinessException("评论不能为空!");
             //查询评论
             var comment = await _repository.GetAsync(request.CommentId);
@@ -330,6 +330,12 @@ namespace GxPress.Repository.Implement
             if (comment.UserId != request.UserId)
                 throw new Common.Exceptions.BusinessException("该评论不属于该用户!");
             //修改
+            if (!string.IsNullOrWhiteSpace(request.Content))
+                comment.Content = request.Content;
+            if (!string.IsNullOrWhiteSpace(request.HtmlContent))
+                comment.HtmlContent = request.HtmlContent;
+            if (!string.IsNullOrWhiteSpace(request.JsonContent))
+                comment.JsonContent = request.JsonContent;
             comment.Content = request.Content;
             if (request.Score > 0)
                 comment.Score = request.Score;