| | |
| | | package com.ruoyi.article.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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; |
| | | |
| | |
| | | ServiceImpl<ArticleCommentsMapper, ArticleComments> implements IArticleCommentsService { |
| | | @Resource |
| | | private IArticleCommentsService articleCommentsService; |
| | | |
| | | @Resource |
| | | private IArticleService articleService; |
| | | |
| | | @Override |
| | | public void saveMemberArticleComments(ArticleCommentsDTO articleCommentsDTO) { |
| | |
| | | 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()); |
| | | } |
| | | } |