From e59e26244b2a07b9d8360551cbab75c6fd8a1248 Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期五, 31 五月 2024 15:15:21 +0800
Subject: [PATCH] 修改循环注入

---
 ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleCommentsServiceImpl.java |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleCommentsServiceImpl.java b/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleCommentsServiceImpl.java
index 3e82b6e..70bd3e4 100644
--- a/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleCommentsServiceImpl.java
+++ b/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleCommentsServiceImpl.java
@@ -5,6 +5,7 @@
 import com.ruoyi.article.domain.ArticleComments;
 import com.ruoyi.article.dto.ArticleCommentsDTO;
 import com.ruoyi.article.mapper.ArticleCommentsMapper;
+import com.ruoyi.article.mapper.ArticleMapper;
 import com.ruoyi.article.service.IArticleCommentsService;
 import com.ruoyi.article.service.IArticleService;
 import com.ruoyi.common.core.exception.ServiceException;
@@ -23,17 +24,15 @@
 @Service
 public class ArticleCommentsServiceImpl extends
         ServiceImpl<ArticleCommentsMapper, ArticleComments> implements IArticleCommentsService {
-    @Resource
-    private  IArticleCommentsService articleCommentsService;
 
     @Resource
-    private IArticleService articleService;
+    private ArticleMapper articleMapper;
 
     @Override
     public void saveMemberArticleComments(ArticleCommentsDTO articleCommentsDTO) {
         ArticleComments articleComments=new ArticleComments();
         if (articleCommentsDTO.getId()!=null){
-            articleComments=  articleCommentsService.getById(articleCommentsDTO.getId());
+            articleComments=  this.getById(articleCommentsDTO.getId());
         }
         if (articleCommentsDTO.getMemberId()==null){
             throw new ServiceException("用户id错误");
@@ -51,20 +50,20 @@
             articleComments.setBmemberId(articleCommentsDTO.getBmemberId());
             articleComments.setType(2);
         }
-        Article byId = articleService.getById(articleCommentsDTO.getArticleId());
+        Article byId = articleMapper.selectById(articleCommentsDTO.getArticleId());
         byId.setCommentCount(byId.getCommentCount()+1);
-        articleService.saveOrUpdate(byId);
-        articleCommentsService.saveOrUpdate(articleComments);
+        articleMapper.updateById(byId);
+        this.saveOrUpdate(articleComments);
     }
 
     @Override
     public void delMemberArticleComments(ArticleCommentsDTO articleCommentsDTO) {
-        ArticleComments byId1 = articleCommentsService.getById(articleCommentsDTO.getId());
+        ArticleComments byId1 = this.getById(articleCommentsDTO.getId());
 
-        Article byId = articleService.getById(byId1.getArticleId());
+        Article byId = articleMapper.selectById(byId1.getArticleId());
         byId.setCommentCount(byId.getCommentCount()-1);
-        articleService.saveOrUpdate(byId);
+        articleMapper.updateById(byId);
 
-        articleCommentsService.removeById(articleCommentsDTO.getId());
+        this.removeById(articleCommentsDTO.getId());
     }
 }

--
Gitblit v1.7.1