From 8c546b7afa18536ba718585ae918d3a0de96c53a Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 20 Feb 2020 09:45:28 +0800 Subject: [PATCH] project search --- .../metersphere/controller/ProjectController.java | 7 +++++-- .../controller/request/ProjectRequest.java | 13 +++++++++++++ .../java/io/metersphere/service/ProjectService.java | 11 ++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index a9d414afb4..71723e7d2e 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -6,7 +6,9 @@ import io.metersphere.base.domain.Project; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; +import io.metersphere.controller.request.ProjectRequest; import io.metersphere.service.ProjectService; +import io.metersphere.user.SessionUtils; import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; @@ -33,9 +35,10 @@ public class ProjectController { @PostMapping("/list/{goPage}/{pageSize}") @RequiresRoles(RoleConstants.TEST_MANAGER) - public Pager> getProjectList(@PathVariable int goPage, @PathVariable int pageSize) { + public Pager> getProjectList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ProjectRequest request) { + request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); Page page = PageHelper.startPage(goPage, pageSize, true); - return PageUtils.setPageInfo(page, projectService.getProjectList()); + return PageUtils.setPageInfo(page, projectService.getProjectList(request)); } @GetMapping("/delete/{projectId}") diff --git a/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java b/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java new file mode 100644 index 0000000000..af75a12bb1 --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java @@ -0,0 +1,13 @@ +package io.metersphere.controller.request; + +public class ProjectRequest { + private String workspaceId; + + public String getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(String workspaceId) { + this.workspaceId = workspaceId; + } +} diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 428bc4a641..b9fce1d079 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -4,6 +4,7 @@ import io.metersphere.base.domain.Project; import io.metersphere.base.domain.ProjectExample; import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.commons.exception.MSException; +import io.metersphere.controller.request.ProjectRequest; import io.metersphere.user.SessionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -40,9 +41,13 @@ public class ProjectService { return project; } - public List getProjectList() { - // todo 查询条件设置 - return projectMapper.selectByExample(null); + public List getProjectList(ProjectRequest request) { + ProjectExample example = new ProjectExample(); + ProjectExample.Criteria criteria = example.createCriteria(); + if (StringUtils.isNotBlank(request.getWorkspaceId())) { + criteria.andWorkspaceIdEqualTo(request.getWorkspaceId()); + } + return projectMapper.selectByExample(example); } public void deleteProject(String projectId) {