Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/wip/controller/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ public APIResponse comment(HttpServletRequest request, HttpServletResponse respo
return APIResponse.fail("请输入正确的网址格式");
}

if (content.length() < 5) {
return APIResponse.fail("请输入5个字符及以上的评价");
}

if (content.length() > 200) {
return APIResponse.fail("请输入200个字符以内的评价");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,7 @@ public void addComment(CommentDomain comments) {
if (StringUtils.isBlank(comments.getAuthor())) {
comments.setAuthor("热心网友");
}
if (StringUtils.isNotBlank(comments.getEmail()) && !TaleUtils.isEmail(comments.getEmail())) {
msg = "请输入正确的邮箱格式";
}
if (StringUtils.isBlank(comments.getContent())) {
msg = "评论内容不能为空";
}
if (comments.getContent().length() < 5 || comments.getContent().length() > 2000) {
msg = "评论字数在5-2000个字符";
}
if (null == comments.getCid()) {
msg = "评论文章不能为空";
}

if (msg != null)
throw BusinessException.withErrorCode(msg);

Expand Down