|
@@ -2,8 +2,14 @@ package com.yonge.cooleshow.bbs.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.yonge.cooleshow.bbs.dao.BbsArticleDao;
|
|
|
|
+import com.yonge.cooleshow.bbs.dao.BbsReplyAuthRecordDao;
|
|
import com.yonge.cooleshow.bbs.dto.ReplyAuditDto;
|
|
import com.yonge.cooleshow.bbs.dto.ReplyAuditDto;
|
|
|
|
+import com.yonge.cooleshow.bbs.entity.BbsArticle;
|
|
|
|
+import com.yonge.cooleshow.bbs.entity.BbsReplyAuthRecord;
|
|
import com.yonge.cooleshow.bbs.enums.ArticleEnum;
|
|
import com.yonge.cooleshow.bbs.enums.ArticleEnum;
|
|
|
|
+import com.yonge.cooleshow.bbs.enums.YesOrNoEnum;
|
|
|
|
+import com.yonge.cooleshow.bbs.service.BbsArticleService;
|
|
import com.yonge.cooleshow.bbs.service.BbsReplyAuthRecordService;
|
|
import com.yonge.cooleshow.bbs.service.BbsReplyAuthRecordService;
|
|
import com.yonge.cooleshow.bbs.vo.BbsReplyAuditVo;
|
|
import com.yonge.cooleshow.bbs.vo.BbsReplyAuditVo;
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
@@ -22,17 +28,20 @@ import com.yonge.cooleshow.bbs.service.BbsReplyService;
|
|
public class BbsReplyServiceImpl extends ServiceImpl<BbsReplyDao, BbsReply> implements BbsReplyService {
|
|
public class BbsReplyServiceImpl extends ServiceImpl<BbsReplyDao, BbsReply> implements BbsReplyService {
|
|
private final static Logger log = LoggerFactory.getLogger(BbsReplyServiceImpl.class);
|
|
private final static Logger log = LoggerFactory.getLogger(BbsReplyServiceImpl.class);
|
|
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private BbsReplyAuthRecordService replyAuthRecordService;
|
|
private BbsReplyAuthRecordService replyAuthRecordService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BbsReplyAuthRecordDao authRecordDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BbsArticleDao articleDao;
|
|
|
|
|
|
- @Override
|
|
|
|
|
|
+ @Override
|
|
public BbsReplyVo detail(Long id) {
|
|
public BbsReplyVo detail(Long id) {
|
|
return baseMapper.detail(id);
|
|
return baseMapper.detail(id);
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public IPage<BbsReplyVo> selectPage(IPage<BbsReplyVo> page, BbsReplySearch query){
|
|
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<BbsReplyVo> selectPage(IPage<BbsReplyVo> page, BbsReplySearch query) {
|
|
return page.setRecords(baseMapper.selectPage(page, query));
|
|
return page.setRecords(baseMapper.selectPage(page, query));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -55,10 +64,10 @@ public class BbsReplyServiceImpl extends ServiceImpl<BbsReplyDao, BbsReply> impl
|
|
public boolean audit(ReplyAuditDto auditDto) {
|
|
public boolean audit(ReplyAuditDto auditDto) {
|
|
BbsReply bbsReply = this.getById(auditDto.getReplyId());
|
|
BbsReply bbsReply = this.getById(auditDto.getReplyId());
|
|
if (bbsReply == null) {
|
|
if (bbsReply == null) {
|
|
- throw new BizException("未找到当前评论信息");
|
|
|
|
|
|
+ throw new BizException("未找到当前评论信息");
|
|
}
|
|
}
|
|
- if(!ArticleEnum.DOING.getCode().equals(bbsReply.getStatus().getCode())) {
|
|
|
|
- throw new BizException("评论已经审核");
|
|
|
|
|
|
+ if (!ArticleEnum.DOING.getCode().equals(bbsReply.getStatus().getCode())) {
|
|
|
|
+ throw new BizException("评论已经审核");
|
|
}
|
|
}
|
|
bbsReply.setStatus(auditDto.getStatus());
|
|
bbsReply.setStatus(auditDto.getStatus());
|
|
this.updateById(bbsReply);
|
|
this.updateById(bbsReply);
|
|
@@ -66,4 +75,30 @@ public class BbsReplyServiceImpl extends ServiceImpl<BbsReplyDao, BbsReply> impl
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @Description: 评论文章
|
|
|
|
+ * @Author: cy
|
|
|
|
+ * @Date: 2022/6/14
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void replyArticle(BbsReply reply) {
|
|
|
|
+ BbsArticle article = articleDao.selectById(reply.getArticleId());
|
|
|
|
+ if (article == null) {
|
|
|
|
+ throw new BizException("评论的文章不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String paramValue = baseMapper.selectConfig("bbs_reply_audit");
|
|
|
|
+ if (paramValue != null && paramValue.equals(YesOrNoEnum.YES.getCode().toString())) {//需审核
|
|
|
|
+ reply.setStatus(ArticleEnum.DOING);
|
|
|
|
+ baseMapper.insert(reply);
|
|
|
|
+
|
|
|
|
+ BbsReplyAuthRecord authRecord = new BbsReplyAuthRecord();
|
|
|
|
+ authRecord.setReplyId(reply.getId());
|
|
|
|
+ authRecord.setAuditState(ArticleEnum.DOING);
|
|
|
|
+ authRecordDao.insert(authRecord);
|
|
|
|
+ } else {//不用审核
|
|
|
|
+ reply.setStatus(ArticleEnum.PASS);
|
|
|
|
+ baseMapper.insert(reply);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|