use of com.dimple.project.blog.domain.Comment in project DimpleBlog by martin-chips.
the class CommentServiceImpl method selectCommentListByPageId.
@Override
public List<Comment> selectCommentListByPageId(Long id) {
// 查询获取所有的comment
List<Comment> commentList = commentMapper.selectCommentListByPageId(id);
List<Comment> result = commentList.stream().filter(e -> e.getParentId() == null).collect(Collectors.toList());
// CommentId和NickName的映射Map
Map<Long, String> commentIdAndNickNameMap = commentList.stream().collect(Collectors.toMap(Comment::getId, Comment::getNickName));
for (Comment comment : result) {
Long commentId = comment.getId();
comment.setSubCommentList(commentList.stream().filter(e -> commentId.equals(e.getParentId())).collect(Collectors.toList()));
// 设置replyNickName
if (ObjectUtils.isNotEmpty(comment.getSubCommentList())) {
for (Comment temp : comment.getSubCommentList()) {
if (temp.getReplyId() != null) {
temp.setReplyNickName(commentIdAndNickNameMap.get(temp.getReplyId()));
}
}
}
}
return result;
}
use of com.dimple.project.blog.domain.Comment in project DimpleBlog by martin-chips.
the class AddressUpdateTask method updateCommentAddress.
private String updateCommentAddress() {
List<Comment> commentList = commentMapper.selectCommentList(new Comment());
Integer count = 0;
for (Comment comment : commentList) {
String ip = comment.getIp();
if (StringUtils.isNotEmpty(ip)) {
count++;
String cityInfoByIp = AddressUtils.getCityInfoByIp(ip);
comment.setLocation(cityInfoByIp);
commentMapper.updateComment(comment);
}
}
return "Comment总数:" + commentList.size() + ";更新总数:" + count;
}
use of com.dimple.project.blog.domain.Comment in project DimpleBlog by martin-chips.
the class FrontServiceImpl method selectCommentListByPageId.
@Override
public List<Comment> selectCommentListByPageId(Long id) {
// 查询获取所有的comment
List<Comment> commentList = frontMapper.selectCommentListByPageId(id);
List<Comment> result = commentList.stream().filter(e -> e.getParentId() == null).collect(Collectors.toList());
// CommentId和NickName的映射Map
Map<Long, String> commentIdAndNickNameMap = commentList.stream().collect(Collectors.toMap(Comment::getId, Comment::getNickName));
for (Comment comment : result) {
Long commentId = comment.getId();
comment.setSubCommentList(commentList.stream().filter(e -> commentId.equals(e.getParentId())).collect(Collectors.toList()));
// 设置replyNickName
if (ObjectUtils.isNotEmpty(comment.getSubCommentList())) {
for (Comment temp : comment.getSubCommentList()) {
if (temp.getReplyId() != null) {
temp.setReplyNickName(commentIdAndNickNameMap.get(temp.getReplyId()));
}
}
}
}
return result;
}
use of com.dimple.project.blog.domain.Comment in project DimpleBlog by martin-chips.
the class FrontServiceImpl method insertComment.
@Override
public int insertComment(Comment comment) {
comment.setAdminReply(SecurityUtils.isAdmin());
final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
comment.setOs(userAgent.getOperatingSystem().getName());
comment.setBrowser(userAgent.getBrowser().getName());
comment.setDisplay(true);
comment.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
comment.setLocation(AddressUtils.getCityInfoByIp(comment.getIp()));
if (comment.getParentId() != null) {
Comment tempComment = frontMapper.selectCommentById(comment.getParentId());
String title = frontMapper.selectBlogTitleById(comment.getPageId());
if (tempComment.getReply()) {
ReplayEmail replayEmail = new ReplayEmail();
replayEmail.setCreateTime(tempComment.getCreateTime());
replayEmail.setOriginContent(tempComment.getHtmlContent());
replayEmail.setReplyContent(comment.getHtmlContent());
replayEmail.setUrl(comment.getUrl());
replayEmail.setTitle(title);
AsyncManager.me().execute(AsyncFactory.sendReplyEmail(comment.getUrl(), comment.getHtmlContent(), comment.getNickName(), tempComment.getEmail(), replayEmail));
}
}
return frontMapper.insertComment(comment);
}
use of com.dimple.project.blog.domain.Comment in project DimpleBlog by martin-chips.
the class CommentController method edit.
@PreAuthorize("@permissionService.hasPermission('blog:comment:edit')")
@Log(title = "评论管理", businessType = BusinessType.UPDATE)
@PutMapping("/{id}/display/{display}")
public AjaxResult edit(@PathVariable Long id, @PathVariable Boolean display) {
Comment comment = new Comment();
comment.setDisplay(display);
comment.setId(id);
comment.setUpdateBy(SecurityUtils.getUsername());
return toAjax(commentService.updateComment(comment));
}
Aggregations