diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java index 8e92fc7..245e95d 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java @@ -283,7 +283,8 @@ public class CommentController extends BaseController { String userId = userLoginDto.getUserId(); String content =sensitiveWordBs.findFirst(commentVo.getContent()); if (StringUtils.isNotEmpty(content)) { - return Result.forbidden(StatusCode.USER_SENSITIVE_INFO); + return Result.failed(StatusCode.COMMENT_SENSITIVE_INFO); + } Comment comment = new Comment(); BeanUtils.copyProperties(commentVo, comment); diff --git a/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordAllow.java b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordAllow.java index c690ef0..135f170 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordAllow.java +++ b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordAllow.java @@ -1,4 +1,4 @@ -package com.luoo.comment.sensitiveWord; +package com.luoo.comment.sensitiveword; import com.github.houbb.sensitive.word.api.IWordAllow; import org.springframework.stereotype.Component; diff --git a/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordDeny.java b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordDeny.java index c470896..c2f63aa 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordDeny.java +++ b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordDeny.java @@ -1,6 +1,7 @@ -package com.luoo.comment.sensitiveWord; +package com.luoo.comment.sensitiveword; import com.github.houbb.sensitive.word.api.IWordDeny; +import constants.SensitiveWords; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.stereotype.Component; @@ -16,17 +17,15 @@ import java.util.List; @Component public class MyDdWordDeny implements IWordDeny { + String DENY_WORDS= SensitiveWords.DENY_WORDS; @Override public List deny() { List list = new ArrayList<>(); - list.add("落网"); - Resource mySensitiveWords = new ClassPathResource("denyWords.txt"); - try { - Path mySensitiveWordsPath = Paths.get(mySensitiveWords.getFile().getPath()); - list = Files.readAllLines(mySensitiveWordsPath, StandardCharsets.UTF_8); +// list.add("落网"); - } catch (IOException e) { - throw new RuntimeException(e); + String[] s = DENY_WORDS.split("\n"); + for(String denyWord:s) { + list.add(denyWord); } return list; diff --git a/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java b/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java index 2444753..e1cde52 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java +++ b/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java @@ -4,10 +4,7 @@ package com.luoo.comment.service; import com.luoo.comment.client.JournalClient; import com.luoo.comment.dao.CommentDao; import com.luoo.comment.dao.CommentHisDao; -import com.luoo.comment.pojo.Comment; -import com.luoo.comment.pojo.CommentHis; -import com.luoo.comment.pojo.JournalRespDTO; -import com.luoo.comment.pojo.PublicationLike; +import com.luoo.comment.pojo.*; import constants.Constants; import dto.UserLoginDto; import dto.UserMessageDto; @@ -54,6 +51,9 @@ public class CommentService { @Autowired private CacheChannel cacheChannel; + @Autowired + private UserInfoService userInfoService; + public List findAll(){ return commentDao.findAll(); } @@ -105,8 +105,10 @@ public class CommentService { comment.setRootId(parentComment.getRootId()); comment.setRootJournalId(parentComment.getRootJournalId()); comment.setRootJournalName(parentComment.getRootJournalName()); - comment.setReplyToNickname(parentComment.getNickName()); +// comment.setReplyToNickname(parentComment.getNickName()); comment.setReplyToUserId(parentComment.getUserId()); + UserInfo userInfo = userInfoService.findById(parentComment.getUserId()); + comment.setReplyToNickname(userInfo.getNickName()); Query query = new Query(); query.addCriteria(Criteria.where("_id").is(comment.getRootId())); Update update = new Update();