fix: comment replyToName error

main
wangqing 9 months ago
parent dd03ea8753
commit 4c81e6c54f

@ -283,7 +283,8 @@ public class CommentController extends BaseController {
String userId = userLoginDto.getUserId(); String userId = userLoginDto.getUserId();
String content =sensitiveWordBs.findFirst(commentVo.getContent()); String content =sensitiveWordBs.findFirst(commentVo.getContent());
if (StringUtils.isNotEmpty(content)) { if (StringUtils.isNotEmpty(content)) {
return Result.forbidden(StatusCode.USER_SENSITIVE_INFO); return Result.failed(StatusCode.COMMENT_SENSITIVE_INFO);
} }
Comment comment = new Comment(); Comment comment = new Comment();
BeanUtils.copyProperties(commentVo, comment); BeanUtils.copyProperties(commentVo, comment);

@ -1,4 +1,4 @@
package com.luoo.comment.sensitiveWord; package com.luoo.comment.sensitiveword;
import com.github.houbb.sensitive.word.api.IWordAllow; import com.github.houbb.sensitive.word.api.IWordAllow;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

@ -1,6 +1,7 @@
package com.luoo.comment.sensitiveWord; package com.luoo.comment.sensitiveword;
import com.github.houbb.sensitive.word.api.IWordDeny; import com.github.houbb.sensitive.word.api.IWordDeny;
import constants.SensitiveWords;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -16,17 +17,15 @@ import java.util.List;
@Component @Component
public class MyDdWordDeny implements IWordDeny { public class MyDdWordDeny implements IWordDeny {
String DENY_WORDS= SensitiveWords.DENY_WORDS;
@Override @Override
public List<String> deny() { public List<String> deny() {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add("落网"); // list.add("落网");
Resource mySensitiveWords = new ClassPathResource("denyWords.txt");
try {
Path mySensitiveWordsPath = Paths.get(mySensitiveWords.getFile().getPath());
list = Files.readAllLines(mySensitiveWordsPath, StandardCharsets.UTF_8);
} catch (IOException e) { String[] s = DENY_WORDS.split("\n");
throw new RuntimeException(e); for(String denyWord:s) {
list.add(denyWord);
} }
return list; return list;

@ -4,10 +4,7 @@ package com.luoo.comment.service;
import com.luoo.comment.client.JournalClient; import com.luoo.comment.client.JournalClient;
import com.luoo.comment.dao.CommentDao; import com.luoo.comment.dao.CommentDao;
import com.luoo.comment.dao.CommentHisDao; import com.luoo.comment.dao.CommentHisDao;
import com.luoo.comment.pojo.Comment; import com.luoo.comment.pojo.*;
import com.luoo.comment.pojo.CommentHis;
import com.luoo.comment.pojo.JournalRespDTO;
import com.luoo.comment.pojo.PublicationLike;
import constants.Constants; import constants.Constants;
import dto.UserLoginDto; import dto.UserLoginDto;
import dto.UserMessageDto; import dto.UserMessageDto;
@ -54,6 +51,9 @@ public class CommentService {
@Autowired @Autowired
private CacheChannel cacheChannel; private CacheChannel cacheChannel;
@Autowired
private UserInfoService userInfoService;
public List<Comment> findAll(){ public List<Comment> findAll(){
return commentDao.findAll(); return commentDao.findAll();
} }
@ -105,8 +105,10 @@ public class CommentService {
comment.setRootId(parentComment.getRootId()); comment.setRootId(parentComment.getRootId());
comment.setRootJournalId(parentComment.getRootJournalId()); comment.setRootJournalId(parentComment.getRootJournalId());
comment.setRootJournalName(parentComment.getRootJournalName()); comment.setRootJournalName(parentComment.getRootJournalName());
comment.setReplyToNickname(parentComment.getNickName()); // comment.setReplyToNickname(parentComment.getNickName());
comment.setReplyToUserId(parentComment.getUserId()); comment.setReplyToUserId(parentComment.getUserId());
UserInfo userInfo = userInfoService.findById(parentComment.getUserId());
comment.setReplyToNickname(userInfo.getNickName());
Query query = new Query(); Query query = new Query();
query.addCriteria(Criteria.where("_id").is(comment.getRootId())); query.addCriteria(Criteria.where("_id").is(comment.getRootId()));
Update update = new Update(); Update update = new Update();

Loading…
Cancel
Save