Add filter ip address service in BaseCommentService

pull/172/head
johnniang 2019-05-30 02:21:35 +08:00
parent bd7b87aa50
commit 427a0b86e7
2 changed files with 44 additions and 0 deletions

View File

@ -214,4 +214,25 @@ public interface BaseCommentService<COMMENT extends BaseComment> extends CrudSer
*/
@NonNull
List<COMMENT> listChildrenBy(@NonNull Integer targetId, @NonNull Long commentParentId, @NonNull CommentStatus status, @NonNull Sort sort);
/**
* Filters comment ip address.
*
* @param comment comment dto must not be null
*/
void filterIpAddress(@NonNull BaseCommentDTO comment);
/**
* Filters comment ip address.
*
* @param comments comment dto list
*/
void filterIpAddress(@Nullable List<BaseCommentDTO> comments);
/**
* Filters comment ip address.
*
* @param commentPage comment page
*/
void filterIpAddress(@NonNull Page<BaseCommentDTO> commentPage);
}

View File

@ -470,6 +470,29 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extend
return childrenList;
}
@Override
public void filterIpAddress(BaseCommentDTO comment) {
Assert.notNull(comment, "Base comment dto must not be null");
// Clear ip address
comment.setIpAddress("");
}
@Override
public void filterIpAddress(List<BaseCommentDTO> comments) {
if (CollectionUtils.isEmpty(comments)) {
return;
}
comments.forEach(this::filterIpAddress);
}
@Override
public void filterIpAddress(Page<BaseCommentDTO> commentPage) {
Assert.notNull(commentPage, "Comment page must not be null");
commentPage.forEach(this::filterIpAddress);
}
/**
* Get children comments recursively.
*