Commit bc6cb6a7 by 段启岩

优化项目Service

parent 6a86d0c5
...@@ -160,7 +160,6 @@ public class ProjectApi { ...@@ -160,7 +160,6 @@ public class ProjectApi {
* @param pageForm * @param pageForm
* @return * @return
*/ */
@Anonymous
@ApiOperation("我的项目列表") @ApiOperation("我的项目列表")
@GetMapping("/my/projects") @GetMapping("/my/projects")
public Response<PageVO<Project>> getMyProjects(@Valid PageForm pageForm, @CurrentSubject Subject subject) { public Response<PageVO<Project>> getMyProjects(@Valid PageForm pageForm, @CurrentSubject Subject subject) {
......
...@@ -20,6 +20,7 @@ import org.springframework.beans.BeanUtils; ...@@ -20,6 +20,7 @@ import org.springframework.beans.BeanUtils;
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.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
...@@ -54,6 +55,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -54,6 +55,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public void publishProject(Project project, String detail) throws ProjectServiceException { public void publishProject(Project project, String detail) throws ProjectServiceException {
Assert.notNull(project, "project must not be null");
Assert.hasText(project.getUserId(), "userId must not be empty");
// 1.检查项目类别是否存在 // 1.检查项目类别是否存在
Integer categoryId = project.getCategoryId(); Integer categoryId = project.getCategoryId();
ProjectCategory projectCategory = projectCategoryMapper.selectById(categoryId); ProjectCategory projectCategory = projectCategoryMapper.selectById(categoryId);
...@@ -75,6 +79,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -75,6 +79,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
public void deleteProject(String projectId, String userId) throws ProjectServiceException { public void deleteProject(String projectId, String userId) throws ProjectServiceException {
Assert.notNull(projectId, "projectId must not be null");
Assert.notNull(userId, "userId must not be null");
// 1.判断自己有没有发过这个项目 // 1.判断自己有没有发过这个项目
QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>(); QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>();
projectQueryWrapper projectQueryWrapper
...@@ -103,6 +110,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -103,6 +110,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
public ProjectDetail getProject(String projectId) throws ProjectServiceException { public ProjectDetail getProject(String projectId) throws ProjectServiceException {
Assert.notNull(projectId, "projectId must not be null");
// 1.获取项目 // 1.获取项目
Project project = getById(projectId); Project project = getById(projectId);
...@@ -130,6 +138,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -130,6 +138,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
public void updateProject(Project project, String projectDetail) throws ProjectServiceException { public void updateProject(Project project, String projectDetail) throws ProjectServiceException {
Assert.notNull(project, "project must not be null");
Assert.hasText(project.getUserId(), "userId must not be empty");
Assert.notNull(project.getProjectId(), "projectId must not be null");
// 1.判断自己有没有发过这个项目 // 1.判断自己有没有发过这个项目
Project projectInDb = getById(project); Project projectInDb = getById(project);
// 若找不到该项目,则抛出业务异常 // 若找不到该项目,则抛出业务异常
......
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