lin
2024-02-26 6cf4cea4bd8214245926dab0d081d30fa13ed9f0
文章评论过滤
4 files modified
55 ■■■■ changed files
src/main/java/org/springblade/modules/answerRecord/service/impl/AnswerRecordServiceImpl.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/controller/ArticleCommentController.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/service/IArticleCommentService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/service/impl/ArticleCommentServiceImpl.java 31 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/answerRecord/service/impl/AnswerRecordServiceImpl.java
@@ -76,7 +76,7 @@
    @Override
    public Boolean saveAnswer(List<SubjectChoicesVO> subjectChoicesVO) {
        BigDecimal bigDecimal = BigDecimal.valueOf(0);
        List<AnswerRecordEntity> objects = new ArrayList<>();
        List<AnswerRecordEntity> answerRecordEntityList = new ArrayList<>();
        // 遍历题目和选项
        for (SubjectChoicesVO choicesVO : subjectChoicesVO) {
            List<SubjectOptionVO> subjectOptionList = choicesVO.getSubjectOptionList();
@@ -97,7 +97,7 @@
                        answerRecordDTO.setSubjectChoicesId(choicesVO.getId());
                        answerRecordDTO.setSubjectChoicesType(1);
                        answerRecordDTO.setSubjectOptionId(subjectOptionVO.getId());
                        objects.add(answerRecordDTO);
                        answerRecordEntityList.add(answerRecordDTO);
                        bigDecimal = bigDecimal.add(subjectOptionVO.getScore());
                        break;
                    }
@@ -110,7 +110,7 @@
                    answerRecordDTO.setAnswer(subjectOptionVO.getNumbers());
                    answerRecordDTO.setSubjectOptionId(subjectOptionVO.getId());
                    answerRecordDTO.setSubjectChoicesType(3);
                    objects.add(answerRecordDTO);
                    answerRecordEntityList.add(answerRecordDTO);
                    BigDecimal multiply = BigDecimal.valueOf(subjectOptionVO.getNumbers()).multiply(subjectOptionVO.getScore());
                    bigDecimal = bigDecimal.subtract(multiply);
                }
@@ -129,7 +129,9 @@
            one.setPartyBuildingInfoScore(bigDecimal);
            bean.update(Wrappers.<PropertyCompanyEntity>lambdaUpdate().set(PropertyCompanyEntity::getPartyBuildingInfoScore, bigDecimal)
                .eq(PropertyCompanyEntity::getId, subjectChoicesVO.get(0).getPropertyId()));
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("企业良好行为")) {
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("街道社区")) {
            one.setStreetScore(bigDecimal);
        }else if (subjectChoicesVO.get(0).getSubclassName().equals("企业良好行为")) {
            one.setGoodCorporateScore(bigDecimal);
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("项目良好行为")) {
            one.setGoodProjectScore(bigDecimal);
@@ -144,10 +146,11 @@
            .add(one.getGoodCorporateScore())
            .add(one.getGoodProjectScore())
            .add(one.getLllegalAndIrregularScore())
            .add(one.getEvaluateScore());
            .add(one.getEvaluateScore())
            .add(one.getStreetScore());
        one.setAllScore(getAllScore(add));
        bean.updateById(one);
        return saveBatch(objects);
        return saveBatch(answerRecordEntityList);
    }
    /**
src/main/java/org/springblade/modules/article/controller/ArticleCommentController.java
@@ -7,6 +7,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.apache.logging.log4j.util.Strings;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@@ -75,6 +76,7 @@
    @ApiOperation(value = "分页", notes = "传入articleComment")
    public R<IPage<ArticleCommentVO>> page(ArticleCommentVO articleComment, Query query) {
        articleComment.setUserId(AuthUtil.getUserId());
        articleComment.setCheckStatus(2);
        IPage<ArticleCommentVO> pages = articleCommentService.selectArticleCommentPage(Condition.getPage(query), articleComment);
        return R.data(pages);
    }
@@ -87,7 +89,11 @@
    @ApiOperation(value = "新增", notes = "传入articleComment")
    public R save(@Valid @RequestBody ArticleCommentEntity articleComment) {
        articleComment.setUserId(AuthUtil.getUserId());
        return R.status(articleCommentService.save(articleComment));
        String msg = articleCommentService.saveComment(articleComment);
        if (!Strings.isBlank(msg)){
            return R.data(201,"",msg);
        }
        return R.data(200,"",msg);
    }
    /**
src/main/java/org/springblade/modules/article/service/IArticleCommentService.java
@@ -23,4 +23,5 @@
    IPage<ArticleCommentVO> selectArticleCommentPage(IPage<ArticleCommentVO> page, ArticleCommentVO noticeComment);
    String saveComment(ArticleCommentEntity articleComment);
}
src/main/java/org/springblade/modules/article/service/impl/ArticleCommentServiceImpl.java
@@ -24,9 +24,12 @@
import org.springblade.modules.article.mapper.ArticleCommentMapper;
import org.springblade.modules.article.service.IArticleCommentService;
import org.springblade.modules.article.vo.ArticleCommentVO;
import org.springblade.modules.words.WorksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * 通知评论表 服务实现类
@@ -36,6 +39,9 @@
 */
@Service
public class ArticleCommentServiceImpl extends ServiceImpl<ArticleCommentMapper, ArticleCommentEntity> implements IArticleCommentService {
    @Autowired
    private WorksService worksService;
    @Override
    public IPage<ArticleCommentVO> selectArticleCommentPage(IPage<ArticleCommentVO> page, ArticleCommentVO noticeComment) {
@@ -51,5 +57,28 @@
        return page.setRecords(baseMapper.selectArticleCommentPage(page, noticeComment));
    }
    @Override
    public String saveComment(ArticleCommentEntity articleComment) {
        boolean flag = false;
        // 先进行敏感词过滤
        Map<String, Object> map = worksService.interceptWords(articleComment.getContent());
        // 获取敏感词校验结果
        String iswords = map.get("iswords").toString();
        if (iswords.equals("false")){
            // 审核通过
            articleComment.setCheckStatus(2);
            flag = save(articleComment);
            // 返回
            return "操作成功";
        }else {
            // 审核不通过
            articleComment.setCheckStatus(3);
            // 设置审核不通过的说明
            articleComment.setCheckRemark(map.get("words").toString());
            // 保存
            save(articleComment);
            // 返回
            return "当前评论内容中带有敏感词,当前评论无法生效!";
        }
    }
}