From fc13d832e58e42e241aa827e930651a28ca357e1 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期五, 31 五月 2024 11:48:43 +0800 Subject: [PATCH] Merge branch 'mitao-dev' --- ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleCommentsServiceImpl.java | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 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 f241b86..3e82b6e 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 @@ -1,10 +1,12 @@ package com.ruoyi.article.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.article.domain.pojo.ArticleComments; +import com.ruoyi.article.domain.Article; +import com.ruoyi.article.domain.ArticleComments; import com.ruoyi.article.dto.ArticleCommentsDTO; import com.ruoyi.article.mapper.ArticleCommentsMapper; import com.ruoyi.article.service.IArticleCommentsService; +import com.ruoyi.article.service.IArticleService; import com.ruoyi.common.core.exception.ServiceException; import org.springframework.stereotype.Service; @@ -23,6 +25,9 @@ ServiceImpl<ArticleCommentsMapper, ArticleComments> implements IArticleCommentsService { @Resource private IArticleCommentsService articleCommentsService; + + @Resource + private IArticleService articleService; @Override public void saveMemberArticleComments(ArticleCommentsDTO articleCommentsDTO) { @@ -46,11 +51,20 @@ articleComments.setBmemberId(articleCommentsDTO.getBmemberId()); articleComments.setType(2); } + Article byId = articleService.getById(articleCommentsDTO.getArticleId()); + byId.setCommentCount(byId.getCommentCount()+1); + articleService.saveOrUpdate(byId); articleCommentsService.saveOrUpdate(articleComments); } @Override public void delMemberArticleComments(ArticleCommentsDTO articleCommentsDTO) { + ArticleComments byId1 = articleCommentsService.getById(articleCommentsDTO.getId()); + + Article byId = articleService.getById(byId1.getArticleId()); + byId.setCommentCount(byId.getCommentCount()-1); + articleService.saveOrUpdate(byId); + articleCommentsService.removeById(articleCommentsDTO.getId()); } } -- Gitblit v1.7.1