Commit b7ce8f31 by 段启岩

优化项目评论Service

parent bc6cb6a7
...@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
/** /**
* <p> * <p>
...@@ -35,6 +36,9 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper, ...@@ -35,6 +36,9 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper,
@Override @Override
public void publishComment(Integer projectId, Integer parentId, String comment, String userId) throws ProjectCommentServiceException { public void publishComment(Integer projectId, Integer parentId, String comment, String userId) throws ProjectCommentServiceException {
Assert.notNull(projectId, "projectId must not be null");
Assert.hasText(comment, "comment must not be empty");
// 1. 查询项目是否存在 // 1. 查询项目是否存在
Project project = projectService.getById(projectId); Project project = projectService.getById(projectId);
if (null == project) { if (null == project) {
...@@ -77,6 +81,9 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper, ...@@ -77,6 +81,9 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper,
@Override @Override
public void deleteComment(Integer commentId, String userId) throws ProjectCommentServiceException { public void deleteComment(Integer commentId, String userId) throws ProjectCommentServiceException {
Assert.notNull(commentId, "commentId must not be null");
Assert.notNull(userId, "userId must not be null");
//1.查找评论是否存在 //1.查找评论是否存在
ProjectComment projectComment = getById(commentId); ProjectComment projectComment = getById(commentId);
if (null == projectComment) { if (null == projectComment) {
...@@ -104,6 +111,7 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper, ...@@ -104,6 +111,7 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper,
@Override @Override
public IPage<ProjectComment> getCommentPage(Integer pageNumber, Integer pageSize, Integer projectId, Integer parentId) throws ProjectCommentServiceException { public IPage<ProjectComment> getCommentPage(Integer pageNumber, Integer pageSize, Integer projectId, Integer parentId) throws ProjectCommentServiceException {
Assert.notNull(projectId, "projectId must not be null");
IPage<ProjectComment> page = new Page<>(pageNumber, pageSize); IPage<ProjectComment> page = new Page<>(pageNumber, pageSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment